aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-10-06 22:41:48 -0500
committerRob Landley <rob@landley.net>2018-10-06 22:41:48 -0500
commit1c336a9e7dec14c1bef0f34c949720bbe14756a8 (patch)
tree94660da323b5d6062b972ee3b2cf123cb4ed7c4a
parent0ba371384f4d46ca7d00b73a3ade4420910bb1cf (diff)
downloadtoybox-1c336a9e7dec14c1bef0f34c949720bbe14756a8.tar.gz
getconf: add missing names used by AOSP.
-rw-r--r--toys/posix/getconf.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/toys/posix/getconf.c b/toys/posix/getconf.c
index 5e3e08af..56324730 100644
--- a/toys/posix/getconf.c
+++ b/toys/posix/getconf.c
@@ -31,7 +31,7 @@ config GETCONF
struct config {
char *name;
- int value;
+ long long value;
};
// Lists of symbols getconf can query, broken down by whether we call sysconf(),
@@ -62,7 +62,7 @@ struct config sysconfs[] = {
/* POSIX.2 */
#undef CONF
-#define CONF(n) {"_POSIX2_" #n,_SC_2_ ## n}
+#define CONF(n) {"POSIX2_" #n,_SC_2_ ## n}
CONF(C_BIND), CONF(C_DEV), CONF(CHAR_TERM), CONF(FORT_DEV), CONF(FORT_RUN),
CONF(LOCALEDEF), CONF(PBS), CONF(PBS_ACCOUNTING), CONF(PBS_CHECKPOINT),
CONF(PBS_LOCATE), CONF(PBS_MESSAGE), CONF(PBS_TRACK), CONF(SW_DEV),
@@ -79,20 +79,25 @@ struct config sysconfs[] = {
#define CONF(n) {#n,_SC_ ## n}
CONF(AIO_LISTIO_MAX), CONF(AIO_MAX), CONF(AIO_PRIO_DELTA_MAX), CONF(ARG_MAX),
CONF(ATEXIT_MAX), CONF(BC_BASE_MAX), CONF(BC_DIM_MAX), CONF(BC_SCALE_MAX),
- CONF(BC_STRING_MAX), CONF(CHILD_MAX), CONF(COLL_WEIGHTS_MAX),
+ CONF(BC_STRING_MAX), CONF(CHILD_MAX), CONF(CLK_TCK), CONF(COLL_WEIGHTS_MAX),
CONF(DELAYTIMER_MAX), CONF(EXPR_NEST_MAX), CONF(HOST_NAME_MAX),
CONF(IOV_MAX), CONF(LINE_MAX), CONF(LOGIN_NAME_MAX), CONF(NGROUPS_MAX),
CONF(MQ_OPEN_MAX), CONF(MQ_PRIO_MAX), CONF(OPEN_MAX), CONF(PAGE_SIZE),
- CONF(PAGESIZE),
+ CONF(PAGESIZE), CONF(RAW_SOCKETS), CONF(RE_DUP_MAX), CONF(RTSIG_MAX),
+ CONF(SEM_NSEMS_MAX), CONF(SEM_VALUE_MAX), CONF(SIGQUEUE_MAX),
+ CONF(STREAM_MAX), CONF(SYMLOOP_MAX), CONF(TIMER_MAX), CONF(TTY_NAME_MAX),
+ CONF(TZNAME_MAX),
+
+ /* Names that just don't match the symbol, do it by hand */
+ {"_AVPHYS_PAGES", _SC_AVPHYS_PAGES}, {"_PHYS_PAGES", _SC_PHYS_PAGES},
+ {"_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF},
+ {"_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN},
+
/* There's a weird "PTHREAD" vs "THREAD" mismatch here. */
{"PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS},
{"PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX},
{"PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN},
{"PTHREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX},
- CONF(RE_DUP_MAX), CONF(RTSIG_MAX), CONF(SEM_NSEMS_MAX), CONF(SEM_VALUE_MAX),
- CONF(SIGQUEUE_MAX), CONF(STREAM_MAX), CONF(SYMLOOP_MAX), CONF(TIMER_MAX),
- CONF(TTY_NAME_MAX), CONF(TZNAME_MAX), CONF(NPROCESSORS_CONF),
- CONF(NPROCESSORS_ONLN)
};
// Probe the live system with a path
@@ -102,7 +107,8 @@ struct config pathconfs[] = {
CONF(ASYNC_IO), CONF(CHOWN_RESTRICTED), CONF(FILESIZEBITS), CONF(LINK_MAX),
CONF(MAX_CANON), CONF(MAX_INPUT), CONF(NAME_MAX), CONF(NO_TRUNC),
CONF(PATH_MAX), CONF(PIPE_BUF), CONF(PRIO_IO), CONF(SYMLINK_MAX),
- CONF(SYNC_IO), CONF(VDISABLE),
+ CONF(SYNC_IO),
+ {"_POSIX_VDISABLE", _PC_VDISABLE},
};
// Strings out of a header
@@ -128,10 +134,19 @@ struct config limits[] = {
CONF(_POSIX_THREAD_DESTRUCTOR_ITERATIONS), CONF(_POSIX_THREAD_KEYS_MAX),
CONF(_POSIX_THREAD_THREADS_MAX), CONF(_POSIX_TIMER_MAX),
CONF(_POSIX_TTY_NAME_MAX), CONF(_POSIX_TZNAME_MAX),
- CONF(_POSIX2_BC_BASE_MAX), CONF(_POSIX2_BC_DIM_MAX),
- CONF(_POSIX2_BC_SCALE_MAX), CONF(_POSIX2_BC_STRING_MAX),
- CONF(_POSIX2_CHARCLASS_NAME_MAX), CONF(_POSIX2_COLL_WEIGHTS_MAX),
- CONF(_POSIX2_EXPR_NEST_MAX), CONF(_POSIX2_LINE_MAX), CONF(_POSIX2_RE_DUP_MAX)
+ CONF(CHAR_MAX), CONF(CHAR_MIN), CONF(INT_MAX), CONF(INT_MIN), CONF(SCHAR_MAX),
+ CONF(SCHAR_MIN), CONF(SHRT_MAX), CONF(SHRT_MIN), CONF(SSIZE_MAX),
+ CONF(UCHAR_MAX), CONF(UINT_MAX), CONF(ULONG_MAX), CONF(USHRT_MAX),
+ CONF(UIO_MAXIOV), CONF(CHAR_BIT),
+ /* Not available in glibc without _GNU_SOURCE. */
+ {"LONG_BIT", 8*sizeof(long)},
+ {"WORD_BIT", 8*sizeof(int)},
+#undef CONF
+#define CONF(n) {#n,_ ## n}
+ CONF(POSIX2_BC_BASE_MAX), CONF(POSIX2_BC_DIM_MAX),
+ CONF(POSIX2_BC_SCALE_MAX), CONF(POSIX2_BC_STRING_MAX),
+ CONF(POSIX2_CHARCLASS_NAME_MAX), CONF(POSIX2_COLL_WEIGHTS_MAX),
+ CONF(POSIX2_EXPR_NEST_MAX), CONF(POSIX2_LINE_MAX), CONF(POSIX2_RE_DUP_MAX),
};
// Names we need to handle ourselves (default to blank but shouldn't error)
@@ -184,7 +199,7 @@ void getconf_main(void)
else if (i==2) {
confstr(c->value, toybuf, sizeof(toybuf));
puts(toybuf);
- } else if (i==3) printf("%d\n", c->value);
+ } else if (i==3) printf("%lld\n", c->value);
// LFS_CFLAGS on 32 bit should enable Large File Support (kernel build cares)
else if (sizeof(long)==4 && !j)
puts("-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64");