svn commit: trunk/uClibc: extra/Configs libc/pwd_grp libc/unistd

pkj at uclibc.org pkj at uclibc.org
Fri Apr 13 08:32:20 UTC 2007


Author: pkj
Date: 2007-04-13 01:32:18 -0700 (Fri, 13 Apr 2007)
New Revision: 18424

Log:
Patch by Ricard Wanderlof <ricardw at axis dot com>:
* Add configurable buffer sizes for getpwnam() and getgrnam().
  The default buffer size is, as before, 256 (glibc seems to use
  1024 by default).


Modified:
   trunk/uClibc/extra/Configs/Config.in
   trunk/uClibc/libc/pwd_grp/pwd_grp.c
   trunk/uClibc/libc/unistd/sysconf.c


Changeset:
Modified: trunk/uClibc/extra/Configs/Config.in
===================================================================
--- trunk/uClibc/extra/Configs/Config.in	2007-04-13 02:43:28 UTC (rev 18423)
+++ trunk/uClibc/extra/Configs/Config.in	2007-04-13 08:32:18 UTC (rev 18424)
@@ -596,6 +596,30 @@
 
 endmenu
 
+menu "Advanced Library Settings"
+
+config UCLIBC_PWD_BUFFER_SIZE
+	int "Buffer size for getpwnam() and friends"
+	default 256
+	range 256 1024
+	help
+	  This sets the value of the buffer size for getpwnam() and friends.
+	  By default, this is 256. (For reference, glibc uses 1024).
+	  The value can be found using sysconf() with the _SC_GETPW_R_SIZE_MAX
+	  parameter.
+
+config UCLIBC_GRP_BUFFER_SIZE
+	int "Buffer size for getgrnam() and friends"
+	default 256
+	range 256 1024
+	help
+	  This sets the value of the buffer size for getgrnam() and friends.
+	  By default, this is 256. (For reference, glibc uses 1024).
+	  The value can be found using sysconf() with the _SC_GETGR_R_SIZE_MAX
+	  parameter.
+
+endmenu
+
 menu "Networking Support"
 
 config UCLIBC_HAS_IPV6

Modified: trunk/uClibc/libc/pwd_grp/pwd_grp.c
===================================================================
--- trunk/uClibc/libc/pwd_grp/pwd_grp.c	2007-04-13 02:43:28 UTC (rev 18423)
+++ trunk/uClibc/libc/pwd_grp/pwd_grp.c	2007-04-13 08:32:18 UTC (rev 18424)
@@ -55,14 +55,6 @@
 #endif
 
 /**********************************************************************/
-/* Sizes for statically 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
-
-/**********************************************************************/
 /* Prototypes for internal functions. */
 
 extern int __parsepwent(void *pw, char *line) attribute_hidden;
@@ -165,7 +157,7 @@
 
 struct passwd *fgetpwent(FILE *stream)
 {
-	static char buffer[PWD_BUFFER_SIZE];
+	static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct passwd resultbuf;
 	struct passwd *result;
 
@@ -183,7 +175,7 @@
 
 struct group *fgetgrent(FILE *stream)
 {
-	static char buffer[GRP_BUFFER_SIZE];
+	static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
 	static struct group resultbuf;
 	struct group *result;
 
@@ -200,7 +192,7 @@
 
 struct spwd *fgetspent(FILE *stream)
 {
-	static char buffer[PWD_BUFFER_SIZE];
+	static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct spwd resultbuf;
 	struct spwd *result;
 
@@ -220,7 +212,7 @@
 
 	*result = NULL;
 
-	if (buflen < PWD_BUFFER_SIZE) {
+	if (buflen < __UCLIBC_PWD_BUFFER_SIZE__) {
 	DO_ERANGE:
 		__set_errno(rv);
 		goto DONE;
@@ -306,7 +298,7 @@
 
 struct passwd *getpwuid(uid_t uid)
 {
-	static char buffer[PWD_BUFFER_SIZE];
+	static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct passwd resultbuf;
 	struct passwd *result;
 
@@ -322,7 +314,7 @@
 
 struct group *getgrgid(gid_t gid)
 {
-	static char buffer[GRP_BUFFER_SIZE];
+	static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
 	static struct group resultbuf;
 	struct group *result;
 
@@ -348,7 +340,7 @@
 	int rv;
 	struct passwd *pp;
 	struct passwd password;
-	char pwd_buff[PWD_BUFFER_SIZE];
+	char pwd_buff[__UCLIBC_PWD_BUFFER_SIZE__];
 
 	*result = NULL;
 	if (!(rv = getpwuid_r(uid, &password, pwd_buff, sizeof(pwd_buff), &pp))) {
@@ -369,7 +361,7 @@
 
 struct spwd *getspuid(uid_t uid)
 {
-	static char buffer[PWD_BUFFER_SIZE];
+	static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct spwd resultbuf;
 	struct spwd *result;
 
@@ -385,7 +377,7 @@
 
 struct passwd *getpwnam(const char *name)
 {
-	static char buffer[PWD_BUFFER_SIZE];
+	static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct passwd resultbuf;
 	struct passwd *result;
 
@@ -401,7 +393,7 @@
 
 struct group *getgrnam(const char *name)
 {
-	static char buffer[GRP_BUFFER_SIZE];
+	static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
 	static struct group resultbuf;
 	struct group *result;
 
@@ -417,7 +409,7 @@
 
 struct spwd *getspnam(const char *name)
 {
-	static char buffer[PWD_BUFFER_SIZE];
+	static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct spwd resultbuf;
 	struct spwd *result;
 
@@ -435,7 +427,7 @@
 {
 	struct passwd resultbuf;
 	struct passwd *result;
-	char buffer[PWD_BUFFER_SIZE];
+	char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
 
 	if (!buf) {
 		__set_errno(EINVAL);
@@ -634,7 +626,7 @@
 
 struct passwd *getpwent(void)
 {
-	static char line_buff[PWD_BUFFER_SIZE];
+	static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct passwd pwd;
 	struct passwd *result;
 
@@ -650,7 +642,7 @@
 
 struct group *getgrent(void)
 {
-	static char line_buff[GRP_BUFFER_SIZE];
+	static char line_buff[__UCLIBC_GRP_BUFFER_SIZE__];
 	static struct group gr;
 	struct group *result;
 
@@ -666,7 +658,7 @@
 
 struct spwd *getspent(void)
 {
-	static char line_buff[PWD_BUFFER_SIZE];
+	static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct spwd spwd;
 	struct spwd *result;
 
@@ -682,7 +674,7 @@
 
 struct spwd *sgetspent(const char *string)
 {
-	static char line_buff[PWD_BUFFER_SIZE];
+	static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
 	static struct spwd spwd;
 	struct spwd *result;
 
@@ -705,7 +697,7 @@
 	int num_groups, rv;
 	char **m;
 	struct group group;
-	char buff[PWD_BUFFER_SIZE];
+	char buff[__UCLIBC_PWD_BUFFER_SIZE__];
 
 	rv = -1;
 
@@ -1134,7 +1126,7 @@
 	int rv = ERANGE;
 	__STDIO_AUTO_THREADLOCK_VAR;
 
-	if (buflen < PWD_BUFFER_SIZE) {
+	if (buflen < __UCLIBC_PWD_BUFFER_SIZE__) {
 		__set_errno(rv);
 	} else {
 		__STDIO_AUTO_THREADLOCK(f);

Modified: trunk/uClibc/libc/unistd/sysconf.c
===================================================================
--- trunk/uClibc/libc/unistd/sysconf.c	2007-04-13 02:43:28 UTC (rev 18423)
+++ trunk/uClibc/libc/unistd/sysconf.c	2007-04-13 08:32:18 UTC (rev 18424)
@@ -568,13 +568,11 @@
 #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:
-      return GRP_BUFFER_SIZE;
+      return __UCLIBC_GRP_BUFFER_SIZE__;
 
     case _SC_GETPW_R_SIZE_MAX:
-      return PWD_BUFFER_SIZE;
+      return __UCLIBC_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




More information about the uClibc-cvs mailing list