libc: minor minix changes for new netbsd files

This commit is contained in:
Ben Gras 2010-06-09 12:09:39 +00:00
parent 60d52d68da
commit ba9990cc00
7 changed files with 57 additions and 24 deletions

View 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

View 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;
}

View 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

View 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;
}

View 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);

View 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)

View 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_ */