summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-07-15 09:09:24 +0000
committerEric Andersen <andersen@codepoet.org>2004-07-15 09:09:24 +0000
commita43573507b0845a19ee63a619d470b31531f7df0 (patch)
tree39deb8f71ce55c3e7b56d61871bac67d9a0505c3 /libc
parenta4b98042e64a172e9a595b7df9ff9a160604255a (diff)
Cleanup a few of the more egregiously broken sysconf values to
actually match reality. In particular, _SC_GETPW_R_SIZE_MAX and _SC_GETGR_R_SIZE_MAX were causing us problems with programs such as libglib, since they were always returning -1, which is a bit smaller than the actual passwd and group max buffer sizes. -Erik
Diffstat (limited to 'libc')
-rw-r--r--libc/pwd_grp/pwd_grp.c2
-rw-r--r--libc/termios/ttyname.c2
-rw-r--r--libc/unistd/sysconf.c46
3 files changed, 19 insertions, 31 deletions
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index 90b4eafd6..91c0d83f5 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/libc/pwd_grp/pwd_grp.c
@@ -49,6 +49,8 @@
/**********************************************************************/
/* Sizes for staticly allocated buffers. */
+/* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
+ * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
#define PWD_BUFFER_SIZE 256
#define GRP_BUFFER_SIZE 256
diff --git a/libc/termios/ttyname.c b/libc/termios/ttyname.c
index abd1beb95..7b937fb0b 100644
--- a/libc/termios/ttyname.c
+++ b/libc/termios/ttyname.c
@@ -21,6 +21,8 @@
* However, there is no need to waste space and support non-standard
* tty names either. So we compromise and use the following buffer
* length. (Erik and Manuel agreed that 32 was more than reasonable.)
+ *
+ * If you change this, also change _SC_TTY_NAME_MAX in libc/unistd/sysconf.c
*/
#define TTYNAME_BUFLEN 32
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index daf0e6144..f5b49a10f 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -103,11 +103,7 @@ long int __sysconf(int name)
#endif
case _SC_OPEN_MAX:
-#if 1
RETURN_FUNCTION(getdtablesize());
-#else
- RETURN_NEG_1;
-#endif
case _SC_STREAM_MAX:
#ifdef STREAM_MAX
@@ -117,12 +113,7 @@ long int __sysconf(int name)
#endif
case _SC_TZNAME_MAX:
-#if 0
- RETURN_FUNCTION(tzname_max ());
-#else
-/* RETURN_NEG_1; */
return _POSIX_TZNAME_MAX;
-#endif
case _SC_JOB_CONTROL:
#ifdef _POSIX_JOB_CONTROL
@@ -559,46 +550,39 @@ long int __sysconf(int name)
/* POSIX 1003.1c (POSIX Threads). */
case _SC_THREADS:
-#ifdef _POSIX_THREADS
+#ifdef __UCLIBC_HAS_THREADS__
return 1;
#else
RETURN_NEG_1;
#endif
case _SC_THREAD_SAFE_FUNCTIONS:
-#ifdef _POSIX_THREAD_SAFE_FUNCTIONS
+#ifdef __UCLIBC_HAS_THREADS__
return 1;
#else
RETURN_NEG_1;
#endif
+/* If you change these, also change libc/pwd_grp/pwd_grp.c to match */
+#define PWD_BUFFER_SIZE 256
+#define GRP_BUFFER_SIZE 256
case _SC_GETGR_R_SIZE_MAX:
-#ifdef NSS_BUFLEN_GROUP
- return NSS_BUFLEN_GROUP;
-#else
- RETURN_NEG_1;
-#endif
+ return GRP_BUFFER_SIZE;
case _SC_GETPW_R_SIZE_MAX:
-#ifdef NSS_BUFLEN_PASSWD
- return NSS_BUFLEN_PASSWD;
-#else
- RETURN_NEG_1;
-#endif
+ return PWD_BUFFER_SIZE;
+/* getlogin() is a worthless interface. In uClibc we let the user specify
+ * whatever they want via the LOGNAME environment variable, or we return NULL
+ * if getenv() fails to find anything. So this is merely how large a env
+ * variable can be. Lets use 256 */
case _SC_LOGIN_NAME_MAX:
-#ifdef _POSIX_LOGIN_NAME_MAX
- return _POSIX_LOGIN_NAME_MAX;
-#else
- RETURN_NEG_1;
-#endif
+ return 256;
+/* If you change this, also change _SC_TTY_NAME_MAX in libc/unistd/sysconf.c */
+#define TTYNAME_BUFLEN 32
case _SC_TTY_NAME_MAX:
-#ifdef _POSIX_TTY_NAME_MAX
- return _POSIX_TTY_NAME_MAX;
-#else
- RETURN_NEG_1;
-#endif
+ return TTYNAME_BUFLEN;
case _SC_THREAD_DESTRUCTOR_ITERATIONS:
#ifdef _POSIX_THREAD_DESTRUCTOR_ITERATIONS