tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[PATCH] implement a few constants for sysconf()
Implement a set of the constants which expandes sysconf() functionality.
getconf has been updated accordingly.
Affected constans are:
_SC_HOST_NAME_MAX
_SC_PASS_MAX
_SC_REGEXP
_SC_SHELL
_SC_SYMLOOP_MAX
---
lib/libc/gen/sysconf.c | 11 +++++++++++
sys/sys/unistd.h | 21 +++++++++++++++++++++
usr.bin/getconf/getconf.c | 7 +++++++
3 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c
index cd3ed56..7b977ef 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)
@@ -394,6 +395,16 @@ yesno: if (sysctl(mib, mib_len, &value, &len,
NULL, 0) == -1)
return -1;
case _SC_TTY_NAME_MAX:
return pathconf(_PATH_DEV, _PC_NAME_MAX);
+ 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;
default:
errno = EINVAL;
return (-1);
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