tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[PATCH] implement a few constants for sysconf(3)
Implement a set of the constants which expandes sysconf(3) functionality.
getconf(1) has been updated accordingly.
Affected constans are:
_SC_HOST_NAME_MAX
_SC_PASS_MAX
_SC_REGEXP
_SC_SHELL
_SC_SYMLOOP_MAX
Additionally get rid of useless code.
---
lib/libc/gen/sysconf.3 | 14 ++++++++++++++
lib/libc/gen/sysconf.c | 15 +++++++++++++--
sys/sys/unistd.h | 21 +++++++++++++++++++++
usr.bin/getconf/getconf.c | 7 +++++++
4 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3
index 0e18c8f..04c9358 100644
--- a/lib/libc/gen/sysconf.3
+++ b/lib/libc/gen/sysconf.3
@@ -87,6 +87,8 @@ The number of clock ticks per second.
.It Li _SC_FSYNC
Return 1 if the File Synchronization Option is available on this system,
otherwise \-1.
+.It Li _SC_HOST_NAME_MAX
+The maximum size of a hostname, including NULL.
.It Li _SC_IOV_MAX
The maximum number of
.Va iovec
@@ -127,6 +129,8 @@ The maximum number of supplemental groups.
The maximum number of open files per process.
.It Li _SC_PAGESIZE
The size of a system page in bytes.
+.It Li _SC_PASS_MAX
+The maximum length of the password, not counting NULL.
.It Li _SC_READER_WRITER_LOCKS
The version of
.St -p1003.1
@@ -134,6 +138,10 @@ and its
Read-Write Locks
option to which the system attempts to conform,
otherwise \-1.
+.It Li _SC_REGEXP
+Return 1 if
+.Tn POSIX
+regular expressions are available on this system, otherwise \-1.
.It Li _SC_SEMAPHORES
The version of
.St -p1003.1
@@ -147,6 +155,10 @@ Semaphores
option depends on the
.Li P1003_1B_SEMAPHORE
kernel option.
+.It Li _SC_SHELL
+Return 1 if
+.Tn POSIX
+shell is available on this system, otherwise \-1.
.It Li _SC_SPIN_LOCKS
The version of
.St -p1003.1
@@ -157,6 +169,8 @@ otherwise \-1.
.It Li _SC_STREAM_MAX
The minimum maximum number of streams that a process may have open
at any one time.
+.It Li _SC_SYMLOOP_MAX
+The maximum number of symbolic links that may be expanded in a path name.
.It Li _SC_SYNCHRONIZED_IO
Return 1 if the Synchronized I/O Option is available on this system,
otherwise \-1.
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c
index cd3ed56..dca8f35 100644
--- a/lib/libc/gen/sysconf.c
+++ b/lib/libc/gen/sysconf.c
@@ -52,6 +52,7 @@ __RCSID("$NetBSD$");
#include <time.h>
#include <unistd.h>
#include <paths.h>
+#include <pwd.h>
#ifdef __weak_alias
__weak_alias(sysconf,__sysconf)
@@ -336,13 +337,23 @@ sysconf(int name)
case _SC_GETPW_R_SIZE_MAX:
return _GETPW_R_SIZE_MAX;
+/* Unsorted */
+ case _SC_HOST_NAME_MAX:
+ return MAXHOSTNAMELEN;
+ case _SC_PASS_MAX:
+ return _PASSWORD_LEN;
+ case _SC_REGEXP:
+ return _POSIX_REGEXP;
+ case _SC_SHELL:
+ return _POSIX_SHELL;
+ case _SC_SYMLOOP_MAX:
+ return MAXSYMLINKS;
+
yesno: if (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1)
return (-1);
if (value == 0)
return (-1);
return (value);
- /*NOTREACHED*/
- break;
/* Extensions */
case _SC_NPROCESSORS_CONF:
diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h
index 4b79d5c..96503e3 100644
--- a/sys/sys/unistd.h
+++ b/sys/sys/unistd.h
@@ -109,6 +109,10 @@
#define _POSIX_READER_WRITER_LOCKS 200112L
/* XPG4.2 shared memory */
#define _XOPEN_SHM 0
+ /* shell */
+#define _POSIX_SHELL 1
+ /* regular expressions */
+#define _POSIX_REGEXP 1
/* access function */
#define F_OK 0 /* test for existence of file */
@@ -227,6 +231,23 @@
#define _SC_THREAD_PROCESS_SHARED 66
#define _SC_THREAD_SAFE_FUNCTIONS 67
#define _SC_TTY_NAME_MAX 68
+#define _SC_HOST_NAME_MAX 69
+#define _SC_PASS_MAX 70
+#define _SC_REGEXP 71
+#define _SC_SHELL 72
+#define _SC_SYMLOOP_MAX 73
+
+/* Actually, they are not supported or implemented yet */
+#define _SC_V6_ILP32_OFF32 74
+#define _SC_V6_ILP32_OFFBIG 75
+#define _SC_V6_LP64_OFF64 76
+#define _SC_V6_LPBIG_OFFBIG 77
+#define _SC_2_PBS 80
+#define _SC_2_PBS_ACCOUNTING 81
+#define _SC_2_PBS_CHECKPOINT 82
+#define _SC_2_PBS_LOCATE 83
+#define _SC_2_PBS_MESSAGE 84
+#define _SC_2_PBS_TRACK 85
#ifdef _NETBSD_SOURCE
/* Commonly provided sysconf() extensions */
diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c
index 3a4241f..ddac924 100644
--- a/usr.bin/getconf/getconf.c
+++ b/usr.bin/getconf/getconf.c
@@ -176,6 +176,13 @@ static const struct conf_variable conf_table[] =
{ "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX
},
{ "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX
},
+ /* Unsorted POSIX Configurable System Variables */
+ { "HOST_NAME_MAX", SYSCONF, _SC_HOST_NAME_MAX },
+ { "PASS_MAX", SYSCONF, _SC_PASS_MAX
},
+ { "SYMLOOP_MAX", SYSCONF, _SC_SYMLOOP_MAX },
+ { "_POSIX_REGEXP", SYSCONF, _SC_REGEXP },
+ { "_POSIX_SHELL", SYSCONF, _SC_SHELL },
+
#ifdef _NETBSD_SOURCE
/* Commonly provided extensions */
{ "NPROCESSORS_CONF", SYSCONF, _SC_NPROCESSORS_CONF
},
--
1.5.2.5
Home |
Main Index |
Thread Index |
Old Index