]> Zhao Yanbai Git Server - minix.git/commitdiff
libc: minor minix changes for new netbsd files
authorBen Gras <ben@minix3.org>
Wed, 9 Jun 2010 12:09:39 +0000 (12:09 +0000)
committerBen Gras <ben@minix3.org>
Wed, 9 Jun 2010 12:09:39 +0000 (12:09 +0000)
lib/libc/other/Makefile.inc
lib/libc/other/getprogname.c
lib/libc/other/namespace.h
lib/libc/other/pwcache.c
lib/libc/other/setmode.c
lib/libc/other/strmode.c
lib/libc/other/un-namespace.h

index 1411f7ced9bf080ef86766e1985aa3eafdfe2d97..cc653441c3702950308936d4275c1791c6ca80cd 100644 (file)
@@ -45,6 +45,8 @@ SRCS+=  \
        cuserid.c \
        dirname.c \
        environ.c \
+       err.c \
+       errx.c \
        errno.c \
        fdopen.c \
        ffs.c \
@@ -57,6 +59,7 @@ SRCS+=  \
        getopt_long.c \
        getpagesize.c \
        getpass.c \
+       getprogname.c \
        getpwent.c \
        getttyent.c \
        getw.c \
@@ -78,16 +81,19 @@ SRCS+=  \
        popen.c \
        putenv.c \
        putw.c \
+       pwcache.c \
        random.c \
        realpath.c \
        rindex.c \
        rlimit.c \
        setenv.c \
+       setmode.c \
        settimeofday.c \
        stderr.c \
        strdup.c \
        strlcat.c \
        strlcpy.c \
+       strmode.c \
        strtok_r.c \
        strtoll.c \
        swab.c \
@@ -102,5 +108,9 @@ SRCS+=  \
        v8regexp.c \
        v8regsub.c \
        vectorio.c \
+       verr.c \
+       verrx.c \
+       vwarn.c \
        vwarnx.c \
+       warn.c \
        warnx.c
index 417d3349ad0d6155a8b52be0622b7a6df8ce695d..c9b52ae8c9e45445f9ab4b4490a84258f44b6397 100644 (file)
@@ -43,15 +43,13 @@ __RCSID("$NetBSD: getprogname.c,v 1.3 2003/07/26 19:24:42 salo Exp $");
 
 #include <stdlib.h>
 
-#ifdef __weak_alias
-__weak_alias(getprogname,_getprogname)
-#endif
-
-extern const char *__progname;
+extern const char **__prognamep;       /* Copy of argv[]. */
+extern int __argc;                     /* Copy of argc. */
 
 const char *
 getprogname(void)
 {
-
-       return (__progname);
+       if(__argc > 0 && __prognamep)
+               return __prognamep[0];
+       return NULL;
 }
index 1e59c6c708cdacdb1f06738e7b5e9dbd04df297e..628da34cdbb1486139d801cb9594883acbf88fdf 100644 (file)
@@ -40,8 +40,6 @@
  * ISO C (C90) section.  Most names in libc aren't in ISO C, so they
  * should be here.  Most aren't here...
  */
-#define                err                             _err
-#define                warn                            _warn
 #define                nsdispatch                      _nsdispatch
 
 /*
@@ -72,7 +70,6 @@
 #define                getdirentries                   _getdirentries
 #define                getlogin                        _getlogin
 #define                getpeername                     _getpeername
-#define                getprogname                     _getprogname
 #define                getsockname                     _getsockname
 #define                getsockopt                      _getsockopt
 #define                ioctl                           _ioctl
index e8df922b0a7097255c3482984f1c7a7a9be05bc9..bf3f366d90e653f81be76fb95fc778c2ef215ae8 100644 (file)
@@ -118,11 +118,16 @@ __weak_alias(pwcache_groupdb,_pwcache_groupdb)
  * function pointers to various name lookup routines.
  * these may be changed as necessary.
  */
+#ifndef __minix
 static int             (*_pwcache_setgroupent)(int)            = setgroupent;
+static int             (*_pwcache_setpassent)(int)             = setpassent;
+#else
+static int             (*_pwcache_setgroupent)(int)            = NULL;
+static int             (*_pwcache_setpassent)(int)             = NULL;
+#endif
 static void            (*_pwcache_endgrent)(void)              = endgrent;
 static struct group *  (*_pwcache_getgrnam)(const char *)      = getgrnam;
 static struct group *  (*_pwcache_getgrgid)(gid_t)             = getgrgid;
-static int             (*_pwcache_setpassent)(int)             = setpassent;
 static void            (*_pwcache_endpwent)(void)              = endpwent;
 static struct passwd * (*_pwcache_getpwnam)(const char *)      = getpwnam;
 static struct passwd * (*_pwcache_getpwuid)(uid_t)             = getpwuid;
@@ -149,6 +154,7 @@ static      int     gidtb_start(void);
 static int     usrtb_start(void);
 static int     grptb_start(void);
 
+#define _DIAGASSERT assert
 
 static u_int
 st_hash(const char *name, size_t len, int tabsz)
@@ -287,6 +293,8 @@ user_from_uid(uid_t uid, int noname)
        if (!pwopn) {
                if (_pwcache_setpassent != NULL)
                        (*_pwcache_setpassent)(1);
+               else
+                       setpwent();
                ++pwopn;
        }
 
@@ -356,6 +364,8 @@ group_from_gid(gid_t gid, int noname)
        if (!gropn) {
                if (_pwcache_setgroupent != NULL)
                        (*_pwcache_setgroupent)(1);
+               else
+                       setgrent();
                ++gropn;
        }
 
@@ -425,6 +435,8 @@ uid_from_user(const char *name, uid_t *uid)
        if (!pwopn) {
                if (_pwcache_setpassent != NULL)
                        (*_pwcache_setpassent)(1);
+               else
+                       setpwent();
                ++pwopn;
        }
 
@@ -489,6 +501,8 @@ gid_from_group(const char *name, gid_t *gid)
        if (!gropn) {
                if (_pwcache_setgroupent != NULL)
                        (*_pwcache_setgroupent)(1);
+               else
+                       setgrent();
                ++gropn;
        }
 
index 83dd752b9979bb7d0ca4a402bd2daff7a9758082..45972852c06b4821d0560f140b6cc379c2d5386f 100644 (file)
@@ -77,10 +77,12 @@ typedef struct bitcmd {
 #define        CMD2_OBITS      0x08
 #define        CMD2_UBITS      0x10
 
-static BITCMD  *addcmd __P((BITCMD *, mode_t, mode_t, mode_t, mode_t));
-static void     compress_mode __P((BITCMD *));
+#define _DIAGASSERT assert
+
+static BITCMD  *addcmd (BITCMD *, mode_t, mode_t, mode_t, mode_t);
+static void     compress_mode (BITCMD *);
 #ifdef SETMODE_DEBUG
-static void     dumpmode __P((BITCMD *));
+static void     dumpmode (BITCMD *);
 #endif
 
 /*
@@ -227,12 +229,20 @@ setmode(p)
                }
                if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
                        goto out;
-               if (lval & ~(STANDARD_BITS|S_ISTXT)) {
+               if (lval & ~(STANDARD_BITS
+#ifdef S_ISTXT
+               |S_ISTXT
+#endif
+               )) {
                        errno = EINVAL;
                        goto out;
                }
                perm = (mode_t)lval;
-               ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask);
+               ADDCMD('=', (STANDARD_BITS
+#ifdef S_ISTXT
+               |S_ISTXT
+#endif
+               ), perm, mask);
                set->cmd = 0;
                return (saveset);
        }
@@ -242,6 +252,7 @@ setmode(p)
         * each clause of the symbolic mode.
         */
        for (;;) {
+
                /* First, find out which bits might be modified. */
                for (who = 0;; ++p) {
                        switch (*p) {
@@ -261,15 +272,19 @@ setmode(p)
                                goto getop;
                        }
                }
-
-getop:         if ((op = *p++) != '+' && op != '-' && op != '=') {
+getop:
+               op = *p;
+               p++;
+               if (op != '+' && op != '-' && op != '=') {
                        errno = EINVAL;
                        goto out;
                }
                if (op == '=')
                        equalopdone = 0;
 
+#ifdef S_ISTXT
                who &= ~S_ISTXT;
+#endif
                for (perm = 0, permXbits = 0;; ++p) {
                        switch (*p) {
                        case 'r':
@@ -283,6 +298,7 @@ getop:              if ((op = *p++) != '+' && op != '-' && op != '=') {
                                if (who == 0 || (who & ~S_IRWXO))
                                        perm |= S_ISUID|S_ISGID;
                                break;
+#ifdef S_ISTXT
                        case 't':
                                /*
                                 * If specific bits where requested and 
@@ -292,6 +308,7 @@ getop:              if ((op = *p++) != '+' && op != '-' && op != '=') {
                                        who |= S_ISTXT;
                                        perm |= S_ISTXT;
                                }
+#endif
                                break;
                        case 'w':
                                perm |= S_IWUSR|S_IWGRP|S_IWOTH;
@@ -367,9 +384,7 @@ out:
 }
 
 static BITCMD *
-addcmd(set, op, who, oparg, mask)
-       BITCMD *set;
-       mode_t oparg, who, op, mask;
+addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask)
 {
 
        _DIAGASSERT(set != NULL);
index 6d7bd1f529d4f4ef5753e0ec46b29bd6d4f1c385..9a2aa6ce9957d5654aba03cbc56e7259b3d6b3a7 100644 (file)
@@ -49,6 +49,8 @@ __RCSID("$NetBSD: strmode.c,v 1.18 2006/10/07 22:04:18 apb Exp $");
 #include <assert.h>
 #include <unistd.h>
 
+#define _DIAGASSERT assert
+
 #if !HAVE_STRMODE
 void
 strmode(mode, p)
index 067e22d224c24dde5896f323fc6c75242eda6ff6..5d2c0fedec2de9b5696e2d478ee872a588e20aa9 100644 (file)
@@ -53,7 +53,6 @@
 #undef         getdirentries
 #undef         getlogin
 #undef         getpeername
-#undef         getprogname
 #undef         getsockname
 #undef         getsockopt
 #undef         ioctl
@@ -146,8 +145,6 @@ int         _kevent(int, const struct kevent *, int, struct kevent *,
 int            _flock(int, int);
 #endif
 
-#undef         err
-#undef         warn
 #undef         nsdispatch
 
 #endif /* _UN_NAMESPACE_H_ */