[Midnightbsd-cvs] src [11539] U trunk/usr.bin/getconf: sync with freebsd.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jul 7 16:37:18 EDT 2018


Revision: 11539
          http://svnweb.midnightbsd.org/src/?rev=11539
Author:   laffer1
Date:     2018-07-07 16:37:18 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync with freebsd.

Modified Paths:
--------------
    trunk/usr.bin/getconf/Makefile
    trunk/usr.bin/getconf/confstr.gperf
    trunk/usr.bin/getconf/fake-gperf.awk
    trunk/usr.bin/getconf/getconf.1
    trunk/usr.bin/getconf/getconf.c
    trunk/usr.bin/getconf/getconf.h
    trunk/usr.bin/getconf/limits.gperf
    trunk/usr.bin/getconf/pathconf.gperf
    trunk/usr.bin/getconf/progenv.gperf
    trunk/usr.bin/getconf/sysconf.gperf

Property Changed:
----------------
    trunk/usr.bin/getconf/confstr.gperf
    trunk/usr.bin/getconf/fake-gperf.awk
    trunk/usr.bin/getconf/getconf.1
    trunk/usr.bin/getconf/limits.gperf
    trunk/usr.bin/getconf/pathconf.gperf
    trunk/usr.bin/getconf/progenv.gperf
    trunk/usr.bin/getconf/sysconf.gperf

Modified: trunk/usr.bin/getconf/Makefile
===================================================================
--- trunk/usr.bin/getconf/Makefile	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/Makefile	2018-07-07 20:37:18 UTC (rev 11539)
@@ -1,5 +1,8 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/getconf/Makefile 319385 2017-06-01 06:41:27Z ngie $
 
+.include <bsd.own.mk>
+
 PROG=	getconf
 
 SRCS=	confstr.c getconf.c limits.c pathconf.c progenv.c sysconf.c
@@ -13,8 +16,9 @@
 
 all:	conflicts
 
-.gperf.c:
-	LC_ALL=C awk -f ${.CURDIR}/fake-gperf.awk ${.IMPSRC} >${.TARGET}
+FAKE_GPERF=	${.CURDIR}/fake-gperf.awk
+.gperf.c: ${FAKE_GPERF}
+	LC_ALL=C awk -f ${FAKE_GPERF} ${.IMPSRC} >${.TARGET}
 
 .gperf.names:
 	LC_ALL=C awk '/^[_A-Z]/ { print; }' ${.IMPSRC} | \
@@ -34,4 +38,8 @@
 unique.names:		conflicting.names
 	LC_ALL=C sort -u ${.ALLSRC} >${.TARGET}
 
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
+
 .include <bsd.prog.mk>

Modified: trunk/usr.bin/getconf/confstr.gperf
===================================================================
--- trunk/usr.bin/getconf/confstr.gperf	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/confstr.gperf	2018-07-07 20:37:18 UTC (rev 11539)
@@ -3,6 +3,7 @@
  * Copyright is disclaimed as to the contents of this file.
  *
  * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/getconf/confstr.gperf 324124 2017-09-30 17:30:22Z jhb $
  */
 
 #include <sys/types.h>
@@ -68,3 +69,14 @@
 	}
 	return 0;
 }
+
+void
+foreach_confstr(void (*func)(const char *, int))
+{
+	const struct map *mp;
+
+	for (mp = wordlist; mp->name != NULL; mp++) {
+		if (mp->valid)
+			func(mp->name, mp->key);
+	}
+}


Property changes on: trunk/usr.bin/getconf/confstr.gperf
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/getconf/fake-gperf.awk
===================================================================
--- trunk/usr.bin/getconf/fake-gperf.awk	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/fake-gperf.awk	2018-07-07 20:37:18 UTC (rev 11539)
@@ -1,5 +1,7 @@
 #!/usr/bin/awk -f
+# $FreeBSD: stable/10/usr.bin/getconf/fake-gperf.awk 321151 2017-07-18 18:33:05Z ngie $
 # $MidnightBSD$
+
 BEGIN {
   state = 0;
   struct_seen = "";
@@ -36,7 +38,8 @@
   state = 3;
   print "\t{ NULL, 0, 0 }";
   print "};";
-  print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
+  print "#include <sys/param.h>";
+  print "#define\tNWORDS\t(nitems(wordlist) - 1)";
   print "static const struct map *";
   print "in_word_set(const char *word)";
   print "{";


Property changes on: trunk/usr.bin/getconf/fake-gperf.awk
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/getconf/getconf.1
===================================================================
--- trunk/usr.bin/getconf/getconf.1	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/getconf.1	2018-07-07 20:37:18 UTC (rev 11539)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"
 .\" Copyright 2000 Massachusetts Institute of Technology
 .\"
@@ -26,9 +27,9 @@
 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/getconf/getconf.1 324124 2017-09-30 17:30:22Z jhb $
 .\"
-.Dd September 18, 2002
+.Dd September 15, 2017
 .Dt GETCONF 1
 .Os
 .Sh NAME
@@ -36,6 +37,9 @@
 .Nd retrieve standard configuration variables
 .Sh SYNOPSIS
 .Nm
+.Fl a
+.Op Ar file
+.Nm
 .Op Fl v Ar environment
 .Ar path_var
 .Ar file
@@ -45,20 +49,35 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility prints the value of a
+utility prints the values of
 .Tn POSIX
 or
 .Tn X/Open
-path or system configuration variable to the standard output.
-If the specified variable is undefined, the string
+path or system configuration variables to the standard output.
+If a variable is undefined, the string
 .Dq Li undefined
 is output.
 .Pp
-The first form of the command, with two mandatory
+The first form of the command displays all of the path or system configuration
+variables to standard output.
+If
+.Ar file
+is provided,
+all path configuration variables are reported for
+.Ar file
+using
+.Xr pathconf 2 .
+Otherwise,
+all system configuration variables are reported using
+.Xr confstr 3
+and
+.Xr sysconf 3.
+.Pp
+The second form of the command, with two mandatory
 arguments, retrieves file- and file system-specific
 configuration variables using
 .Xr pathconf 2 .
-The second form, with a single argument, retrieves system
+The third form, with a single argument, retrieves system
 configuration variables using
 .Xr confstr 3
 and
@@ -122,7 +141,7 @@
 .It Li POSIX_V6_LP64_OFF64
 Exactly 32-bit integer; exactly 64-bit long, pointer, and file offset.
 .Sy Supported platforms :
-.Tn Alpha ,
+.Tn AMD64 ,
 .Tn SPARC64 .
 .It Li POSIX_V6_LPBIG_OFFBIG
 At least 32-bit integer; at least 64-bit long, pointer, and file offset.


Property changes on: trunk/usr.bin/getconf/getconf.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/getconf/getconf.c
===================================================================
--- trunk/usr.bin/getconf/getconf.c	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/getconf.c	2018-07-07 20:37:18 UTC (rev 11539)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright 2000 Massachusetts Institute of Technology
  *
@@ -28,12 +29,13 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/getconf/getconf.c 324124 2017-09-30 17:30:22Z jhb $");
 
 #include <sys/types.h>
 
 #include <err.h>
 #include <errno.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sysexits.h>
@@ -41,6 +43,8 @@
 
 #include "getconf.h"
 
+static void	do_allsys(void);
+static void	do_allpath(const char *path);
 static void	do_confstr(const char *name, int key);
 static void	do_sysconf(const char *name, int key);
 static void	do_pathconf(const char *name, int key, const char *path);
@@ -49,7 +53,8 @@
 usage(void)
 {
 	fprintf(stderr,
-"usage: getconf [-v prog_env] system_var\n"
+"usage: getconf -a [pathname]\n"
+"       getconf [-v prog_env] system_var\n"
 "       getconf [-v prog_env] path_var pathname\n");
 	exit(EX_USAGE);
 }
@@ -57,13 +62,18 @@
 int
 main(int argc, char **argv)
 {
+	bool aflag;
 	int c, key, valid;
 	const char *name, *vflag, *alt_path;
 	intmax_t limitval;
 
+	aflag = false;
 	vflag = NULL;
-	while ((c = getopt(argc, argv, "v:")) != -1) {
+	while ((c = getopt(argc, argv, "av:")) != -1) {
 		switch (c) {
+		case 'a':
+			aflag = true;
+			break;
 		case 'v':
 			vflag = optarg;
 			break;
@@ -73,6 +83,16 @@
 		}
 	}
 
+	if (aflag) {
+		if (vflag != NULL)
+			usage();
+		if (argv[optind] == NULL)
+			do_allsys();
+		else
+			do_allpath(argv[optind]);
+		return (0);
+	}
+
 	if ((name = argv[optind]) == NULL)
 		usage();
 
@@ -109,13 +129,13 @@
 				do_confstr(name, key);
 			else
 				printf("undefined\n");
-		} else {		
+		} else {
 			valid = find_sysconf(name, &key);
 			if (valid > 0) {
 				do_sysconf(name, key);
 			} else if (valid < 0) {
 				printf("undefined\n");
-			} else 
+			} else
 				errx(EX_USAGE,
 				     "no such configuration parameter `%s'",
 				     name);
@@ -136,6 +156,77 @@
 }
 
 static void
+do_onestr(const char *name, int key)
+{
+	size_t len;
+
+	errno = 0;
+	len = confstr(key, 0, 0);
+	if (len == 0 && errno != 0) {
+		warn("confstr: %s", name);
+		return;
+	}
+	printf("%s: ", name);
+	if (len == 0)
+		printf("undefined\n");
+	else {
+		char buf[len + 1];
+
+		confstr(key, buf, len);
+		printf("%s\n", buf);
+	}
+}
+
+static void
+do_onesys(const char *name, int key)
+{
+	long value;
+
+	errno = 0;
+	value = sysconf(key);
+	if (value == -1 && errno != 0) {
+		warn("sysconf: %s", name);
+		return;
+	}
+	printf("%s: ", name);
+	if (value == -1)
+		printf("undefined\n");
+	else
+		printf("%ld\n", value);
+}
+
+static void
+do_allsys(void)
+{
+
+	foreach_confstr(do_onestr);
+	foreach_sysconf(do_onesys);
+}
+
+static void
+do_onepath(const char *name, int key, const char *path)
+{
+	long value;
+
+	errno = 0;
+	value = pathconf(path, key);
+	if (value == -1 && errno != EINVAL && errno != 0)
+		warn("pathconf: %s", name);
+	printf("%s: ", name);
+	if (value == -1)
+		printf("undefined\n");
+	else
+		printf("%ld\n", value);
+}
+
+static void
+do_allpath(const char *path)
+{
+
+	foreach_pathconf(do_onepath, path);
+}
+
+static void
 do_confstr(const char *name, int key)
 {
 	size_t len;

Modified: trunk/usr.bin/getconf/getconf.h
===================================================================
--- trunk/usr.bin/getconf/getconf.h	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/getconf.h	2018-07-07 20:37:18 UTC (rev 11539)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright 2000 Massachusetts Institute of Technology
  *
@@ -26,7 +27,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/getconf/getconf.h 324124 2017-09-30 17:30:22Z jhb $
  */
 
 #ifdef STABLE
@@ -41,3 +42,7 @@
 int	find_pathconf(const char *name, int *key);
 int	find_progenv(const char *name, const char **alt_path);
 int	find_sysconf(const char *name, int *key);
+void	foreach_confstr(void (*func)(const char *, int));
+void	foreach_pathconf(void (*func)(const char *, int, const char *),
+	    const char *path);
+void	foreach_sysconf(void (*func)(const char *, int));

Modified: trunk/usr.bin/getconf/limits.gperf
===================================================================
--- trunk/usr.bin/getconf/limits.gperf	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/limits.gperf	2018-07-07 20:37:18 UTC (rev 11539)
@@ -3,6 +3,7 @@
  * Copyright is disclaimed as to the contents of this file.
  *
  * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/getconf/limits.gperf 119312 2003-08-22 17:32:07Z markm $
  */
 
 #include <sys/types.h>


Property changes on: trunk/usr.bin/getconf/limits.gperf
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/getconf/pathconf.gperf
===================================================================
--- trunk/usr.bin/getconf/pathconf.gperf	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/pathconf.gperf	2018-07-07 20:37:18 UTC (rev 11539)
@@ -3,6 +3,7 @@
  * Copyright is disclaimed as to the contents of this file.
  *
  * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/getconf/pathconf.gperf 324124 2017-09-30 17:30:22Z jhb $
  */
 
 #include <sys/types.h>
@@ -20,10 +21,17 @@
 %}
 struct map { const char *name; int key; int valid; };
 %%
+ACL_EXTENDED, _PC_ACL_EXTENDED
+ACL_NFS4, _PC_ACL_NFS4
+ACL_PATH_MAX, _PC_ACL_PATH_MAX
+CAP_PRESENT, _PC_CAP_PRESENT
 FILESIZEBITS, _PC_FILESIZEBITS
+INF_PRESENT, _PC_INF_PRESENT
 LINK_MAX, _PC_LINK_MAX
+MAC_PRESENT, _PC_MAC_PRESENT
 MAX_CANON, _PC_MAX_CANON
 MAX_INPUT, _PC_MAX_INPUT
+MIN_HOLE_SIZE, _PC_MIN_HOLE_SIZE
 NAME_MAX, _PC_NAME_MAX
 PATH_MAX, _PC_PATH_MAX
 PIPE_BUF, _PC_PIPE_BUF
@@ -34,6 +42,7 @@
 POSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN
 SYMLINK_MAX, _PC_SYMLINK_MAX
 TRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED
+TRUSTEDBSD_ACL_NFS4, _PC_ACL_NFS4
 TRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX
 TRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT
 TRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT
@@ -60,3 +69,15 @@
 	}
 	return 0;
 }
+
+void
+foreach_pathconf(void (*func)(const char *, int, const char *),
+    const char *path)
+{
+	const struct map *mp;
+
+	for (mp = wordlist; mp->name != NULL; mp++) {
+		if (mp->valid)
+			func(mp->name, mp->key, path);
+	}
+}


Property changes on: trunk/usr.bin/getconf/pathconf.gperf
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/getconf/progenv.gperf
===================================================================
--- trunk/usr.bin/getconf/progenv.gperf	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/progenv.gperf	2018-07-07 20:37:18 UTC (rev 11539)
@@ -30,7 +30,7 @@
  * be updated.  (We cheat here and define the supported environments
  * statically.)
  */
-#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
+#if defined(__sparc64__) || defined(__amd64__)
 #define	have_LP64_OFF64		NULL
 #endif
 


Property changes on: trunk/usr.bin/getconf/progenv.gperf
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/getconf/sysconf.gperf
===================================================================
--- trunk/usr.bin/getconf/sysconf.gperf	2018-07-07 20:35:09 UTC (rev 11538)
+++ trunk/usr.bin/getconf/sysconf.gperf	2018-07-07 20:37:18 UTC (rev 11539)
@@ -1,8 +1,8 @@
 %{
 /*
  * Copyright is disclaimed as to the contents of this file.
- *
  * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/getconf/sysconf.gperf 324124 2017-09-30 17:30:22Z jhb $
  */
 
 #include <sys/types.h>
@@ -121,7 +121,7 @@
 _POSIX_V6_ILP32_OFF32, _SC_V6_ILP32_OFF32
 _POSIX_V6_ILP32_OFFBIG, _SC_V6_ILP32_OFFBIG
 _POSIX_V6_LP64_OFF64, _SC_V6_LP64_OFF64
-_POSIX_V6_LP64_OFFBIG, _SC_V6_LP64_OFFBIG
+_POSIX_V6_LPBIG_OFFBIG, _SC_V6_LPBIG_OFFBIG
 _XOPEN_CRYPT, _SC_XOPEN_CRYPT
 _XOPEN_ENH_I18N, _SC_XOPEN_ENH_I18N
 _XOPEN_LEGACY, _SC_XOPEN_LEGACY
@@ -147,3 +147,14 @@
 	}
 	return 0;
 }
+
+void
+foreach_sysconf(void (*func)(const char *, int))
+{
+	const struct map *mp;
+
+	for (mp = wordlist; mp->name != NULL; mp++) {
+		if (mp->valid)
+			func(mp->name, mp->key);
+	}
+}


Property changes on: trunk/usr.bin/getconf/sysconf.gperf
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list