merge/update to lite-2
This commit is contained in:
parent
2f7fe0fea0
commit
08b0946f73
@ -1,26 +1,29 @@
|
||||
# $NetBSD: Makefile.inc,v 1.85 1997/12/20 20:23:16 kleink Exp $
|
||||
# @(#)Makefile.inc 8.3 (Berkeley) 4/16/94
|
||||
# $NetBSD: Makefile.inc,v 1.86 1998/02/02 02:41:17 perry Exp $
|
||||
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
|
||||
|
||||
# gen sources
|
||||
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/gen ${.CURDIR}/gen
|
||||
|
||||
SRCS+= _errno.c alarm.c assert.c basename.c clock.c closedir.c confstr.c \
|
||||
ctermid.c ctype_.c daemon.c devname.c dirname.c disklabel.c err.c \
|
||||
errx.c errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
|
||||
fnmatch.c fstab.c ftok.c __fts13.c fts.c getbsize.c getcap.c \
|
||||
getcwd.c getdomainname.c getgrent.c getgrouplist.c gethostname.c \
|
||||
getloadavg.c getlogin.c getmntinfo.c getnetgrent.c getpagesize.c \
|
||||
getpass.c getpwent.c getsubopt.c getttyent.c getusershell.c __glob13.c \
|
||||
glob.c \
|
||||
initgroups.c isatty.c isctype.c lockf.c nice.c nlist.c nlist_aout.c \
|
||||
nlist_ecoff.c nlist_elf32.c nlist_elf64.c opendir.c pause.c \
|
||||
popen.c psignal.c pwcache.c raise.c readdir.c rewinddir.c scandir.c \
|
||||
seekdir.c setdomainname.c sethostname.c setjmperr.c setmode.c \
|
||||
# XXX add getvfsbyname.c
|
||||
SRCS+= _errno.c alarm.c assert.c basename.c clock.c closedir.c \
|
||||
confstr.c ctermid.c ctype_.c daemon.c devname.c dirname.c \
|
||||
disklabel.c err.c errx.c errlist.c errno.c execl.c execle.c \
|
||||
execlp.c execv.c execvp.c fnmatch.c fstab.c ftok.c __fts13.c \
|
||||
fts.c getbsize.c getcap.c getcwd.c getdomainname.c getgrent.c \
|
||||
getgrouplist.c gethostname.c getloadavg.c getlogin.c \
|
||||
getmntinfo.c getnetgrent.c getpagesize.c getpass.c getpwent.c \
|
||||
getsubopt.c getttyent.c getusershell.c \
|
||||
__glob13.c glob.c initgroups.c isatty.c isctype.c lockf.c \
|
||||
nice.c nlist.c nlist_aout.c nlist_ecoff.c nlist_elf32.c \
|
||||
nlist_elf64.c opendir.c pause.c popen.c psignal.c pwcache.c \
|
||||
raise.c readdir.c rewinddir.c scandir.c seekdir.c \
|
||||
setdomainname.c sethostname.c setjmperr.c setmode.c \
|
||||
setproctitle.c siginterrupt.c siglist.c signal.c signame.c \
|
||||
sigsetops.c sleep.c stringlist.c sysconf.c sysctl.c syslog.c telldir.c \
|
||||
time.c times.c timezone.c tolower_.c ttyname.c ttyslot.c toupper_.c \
|
||||
ualarm.c uname.c unvis.c usleep.c utime.c valloc.c vis.c wait.c \
|
||||
wait3.c waitpid.c warn.c warnx.c vwarn.c vwarnx.c verr.c verrx.c
|
||||
sigsetops.c sleep.c stringlist.c sysconf.c sysctl.c syslog.c \
|
||||
telldir.c time.c times.c timezone.c tolower_.c ttyname.c \
|
||||
ttyslot.c toupper_.c ualarm.c uname.c unvis.c usleep.c utime.c \
|
||||
valloc.c vis.c wait.c wait3.c waitpid.c warn.c warnx.c vwarn.c \
|
||||
vwarnx.c verr.c verrx.c
|
||||
|
||||
# indirect reference stubs, to be removed soon.
|
||||
SRCS+= _err.c _errx.c _sys_errlist.c _sys_nerr.c _sys_siglist.c \
|
||||
@ -33,20 +36,22 @@ SRCS+= _err.c _errx.c _sys_errlist.c _sys_nerr.c _sys_siglist.c \
|
||||
|
||||
.include "${.CURDIR}/arch/${MACHINE_ARCH}/gen/Makefile.inc"
|
||||
|
||||
MAN+= alarm.3 basename.3 clock.3 confstr.3 ctermid.3 ctype.3 daemon.3 \
|
||||
devname.3 directory.3 dirname.3 err.3 exec.3 fnmatch.3 frexp.3 ftok.3 \
|
||||
fts.3 getbsize.3 getcap.3 getcwd.3 getdomainname.3 getdiskbyname.3 \
|
||||
getfsent.3 getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \
|
||||
getmntinfo.3 getnetgrent.3 getpagesize.3 getpass.3 getpwent.3 \
|
||||
getsubopt.3 getttyent.3 getusershell.3 glob.3 initgroups.3 isalnum.3 \
|
||||
isalpha.3 isascii.3 isblank.3 iscntrl.3 isdigit.3 isgraph.3 isinf.3 \
|
||||
islower.3 isprint.3 ispunct.3 isspace.3 isupper.3 isxdigit.3 \
|
||||
ldexp.3 lockf.3 modf.3 nice.3 nlist.3 pause.3 popen.3 psignal.3 pwcache.3 \
|
||||
raise.3 scandir.3 setjmp.3 setmode.3 setproctitle.3 siginterrupt.3 \
|
||||
signal.3 sigsetops.3 sleep.3 stringlist.3 sysconf.3 sysctl.3 syslog.3 \
|
||||
time.3 times.3 timezone.3 toascii.3 \
|
||||
tolower.3 toupper.3 ttyname.3 ualarm.3 uname.3 unvis.3 \
|
||||
usleep.3 utime.3 valloc.3 vis.3
|
||||
# XXX add getvfsbyname.3
|
||||
MAN+= alarm.3 basename.3 clock.3 confstr.3 ctermid.3 ctype.3 \
|
||||
daemon.3 devname.3 directory.3 dirname.3 err.3 exec.3 \
|
||||
fnmatch.3 frexp.3 ftok.3 fts.3 getbsize.3 getcap.3 getcwd.3 \
|
||||
getdomainname.3 getdiskbyname.3 getfsent.3 getgrent.3 \
|
||||
getgrouplist.3 gethostname.3 getloadavg.3 getmntinfo.3 \
|
||||
getnetgrent.3 getpagesize.3 getpass.3 getpwent.3 getsubopt.3 \
|
||||
getttyent.3 getusershell.3 glob.3 initgroups.3 \
|
||||
isalnum.3 isalpha.3 isascii.3 isblank.3 iscntrl.3 isdigit.3 \
|
||||
isgraph.3 isinf.3 islower.3 isprint.3 ispunct.3 isspace.3 \
|
||||
isupper.3 isxdigit.3 ldexp.3 lockf.3 modf.3 nice.3 nlist.3 \
|
||||
pause.3 popen.3 psignal.3 pwcache.3 raise.3 scandir.3 setjmp.3 \
|
||||
setmode.3 setproctitle.3 siginterrupt.3 signal.3 sigsetops.3 \
|
||||
sleep.3 stringlist.3 sysconf.3 sysctl.3 syslog.3 time.3 \
|
||||
times.3 timezone.3 toascii.3 tolower.3 toupper.3 ttyname.3 \
|
||||
ualarm.3 uname.3 unvis.3 usleep.3 utime.3 valloc.3 vis.3
|
||||
|
||||
MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \
|
||||
directory.3 readdir.3 directory.3 rewinddir.3 directory.3 seekdir.3 \
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: devname.3,v 1.3 1997/12/23 22:46:27 hubertf Exp $
|
||||
.\" $NetBSD: devname.3,v 1.4 1998/02/02 02:41:18 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -31,9 +31,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)devname.3 8.1 (Berkeley) 6/4/93
|
||||
.\" @(#)devname.3 8.2 (Berkeley) 4/29/95
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd April 29, 1995
|
||||
.Dt DEVNAME 3
|
||||
.Os BSD 4.4
|
||||
.Sh NAME
|
||||
@ -56,9 +56,11 @@ and a file type matching the one encoded in
|
||||
.Fa type
|
||||
which must be one of S_IFBLK or S_IFCHR.
|
||||
If no device matches the specified values, or no information is
|
||||
available, the string
|
||||
.Dq ??
|
||||
is returned.
|
||||
available, NULL is returned.
|
||||
.Pp
|
||||
The traditional display for applications when no device is
|
||||
found is the string
|
||||
.Dq ?? .
|
||||
.Sh SEE ALSO
|
||||
.Xr stat 2 ,
|
||||
.Xr dev_mkdb 8
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: devname.c,v 1.6 1997/07/21 14:06:52 jtc Exp $ */
|
||||
/* $NetBSD: devname.c,v 1.7 1998/02/02 02:41:19 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -36,9 +36,9 @@
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)devname.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: devname.c,v 1.6 1997/07/21 14:06:52 jtc Exp $");
|
||||
__RCSID("$NetBSD: devname.c,v 1.7 1998/02/02 02:41:19 perry Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@ -77,7 +77,7 @@ devname(dev, type)
|
||||
failure = 1;
|
||||
}
|
||||
if (failure)
|
||||
return ("??");
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* Keys are a mode_t followed by a dev_t. The former is the type of
|
||||
@ -89,5 +89,5 @@ devname(dev, type)
|
||||
bkey.type = type;
|
||||
key.data = &bkey;
|
||||
key.size = sizeof(bkey);
|
||||
return ((db->get)(db, &key, &data, 0) ? "??" : (char *)data.data);
|
||||
return ((db->get)(db, &key, &data, 0) ? NULL : (char *)data.data);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: disklabel.c,v 1.15 1997/07/21 14:06:53 jtc Exp $ */
|
||||
/* $NetBSD: disklabel.c,v 1.16 1998/02/02 02:41:20 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1987, 1993
|
||||
@ -36,9 +36,9 @@
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)disklabel.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 5/3/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.15 1997/07/21 14:06:53 jtc Exp $");
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.16 1998/02/02 02:41:20 perry Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@ -46,6 +46,7 @@ __RCSID("$NetBSD: disklabel.c,v 1.15 1997/07/21 14:06:53 jtc Exp $");
|
||||
#include <sys/param.h>
|
||||
#define DKTYPENAMES
|
||||
#include <sys/disklabel.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: fnmatch.3,v 1.11 1997/04/23 07:14:51 cjs Exp $
|
||||
.\" $NetBSD: fnmatch.3,v 1.12 1998/02/02 02:41:21 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -33,9 +33,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)fnmatch.3 8.2 (Berkeley) 4/16/94
|
||||
.\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95
|
||||
.\"
|
||||
.Dd April 16, 1994
|
||||
.Dd April 28, 1995
|
||||
.Dt FNMATCH 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: getcap.3,v 1.5 1997/05/29 01:48:12 cgd Exp $
|
||||
.\" $NetBSD: getcap.3,v 1.6 1998/02/02 02:41:22 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1992, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -34,9 +34,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)getcap.3 8.3 (Berkeley) 4/19/94
|
||||
.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94
|
||||
.\"
|
||||
.Dd April 19, 1994
|
||||
.Dd "May 13, 1994"
|
||||
.Dt GETCAP 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -75,7 +75,7 @@
|
||||
.Fn cgetclose "void"
|
||||
.Sh DESCRIPTION
|
||||
.Fn Cgetent
|
||||
extracts the capability rec
|
||||
extracts the capability
|
||||
.Fa name
|
||||
from the database specified by the
|
||||
.Dv NULL
|
||||
|
@ -1,9 +1,12 @@
|
||||
/* $NetBSD: getcwd.c,v 1.7 1997/07/21 14:07:04 jtc Exp $ */
|
||||
/* $NetBSD: getcwd.c,v 1.8 1998/02/02 02:41:23 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993
|
||||
* Copyright (c) 1989, 1991, 1993, 1995
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Jan-Simon Pendry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -36,17 +39,19 @@
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getcwd.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: getcwd.c,v 1.7 1997/07/21 14:07:04 jtc Exp $");
|
||||
__RCSID("$NetBSD: getcwd.c,v 1.8 1998/02/02 02:41:23 perry Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -56,6 +61,8 @@ __RCSID("$NetBSD: getcwd.c,v 1.7 1997/07/21 14:07:04 jtc Exp $");
|
||||
__weak_alias(getcwd,_getcwd);
|
||||
#endif
|
||||
|
||||
static char *getcwd_physical __P((char *, size_t));
|
||||
|
||||
#define ISDOT(dp) \
|
||||
(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
|
||||
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
|
||||
@ -64,6 +71,154 @@ char *
|
||||
getcwd(pt, size)
|
||||
char *pt;
|
||||
size_t size;
|
||||
{
|
||||
char *pwd;
|
||||
size_t pwdlen;
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
struct stat s;
|
||||
|
||||
/* Check $PWD -- if it's right, it's fast. */
|
||||
if ((pwd = getenv("PWD")) != NULL && pwd[0] == '/' && !stat(pwd, &s)) {
|
||||
dev = s.st_dev;
|
||||
ino = s.st_ino;
|
||||
if (!stat(".", &s) && dev == s.st_dev && ino == s.st_ino) {
|
||||
pwdlen = strlen(pwd);
|
||||
if (size != 0) {
|
||||
if (pwdlen + 1 > size) {
|
||||
errno = ERANGE;
|
||||
return (NULL);
|
||||
}
|
||||
} else if ((pt = malloc(pwdlen + 1)) == NULL)
|
||||
return (NULL);
|
||||
memmove(pt, pwd, pwdlen);
|
||||
pt[pwdlen] = '\0';
|
||||
return (pt);
|
||||
}
|
||||
}
|
||||
|
||||
return (getcwd_physical(pt, size));
|
||||
}
|
||||
|
||||
/*
|
||||
* char *realpath(const char *path, char resolved_path[MAXPATHLEN]);
|
||||
*
|
||||
* Find the real name of path, by removing all ".", ".." and symlink
|
||||
* components. Returns (resolved) on success, or (NULL) on failure,
|
||||
* in which case the path which caused trouble is left in (resolved).
|
||||
*/
|
||||
char *
|
||||
realpath(path, resolved)
|
||||
const char *path;
|
||||
char *resolved;
|
||||
{
|
||||
struct stat sb;
|
||||
int fd, n, rootd, serrno;
|
||||
char *p, *q, wbuf[MAXPATHLEN];
|
||||
|
||||
/* Save the starting point. */
|
||||
if ((fd = open(".", O_RDONLY)) < 0) {
|
||||
(void)strcpy(resolved, ".");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the dirname and basename from the path to be resolved.
|
||||
* Change directory to the dirname component.
|
||||
* lstat the basename part.
|
||||
* if it is a symlink, read in the value and loop.
|
||||
* if it is a directory, then change to that directory.
|
||||
* get the current directory name and append the basename.
|
||||
*/
|
||||
(void)strncpy(resolved, path, MAXPATHLEN - 1);
|
||||
resolved[MAXPATHLEN - 1] = '\0';
|
||||
loop:
|
||||
q = strrchr(resolved, '/');
|
||||
if (q != NULL) {
|
||||
p = q + 1;
|
||||
if (q == resolved)
|
||||
q = "/";
|
||||
else {
|
||||
do {
|
||||
--q;
|
||||
} while (q > resolved && *q == '/');
|
||||
q[1] = '\0';
|
||||
q = resolved;
|
||||
}
|
||||
if (chdir(q) < 0)
|
||||
goto err1;
|
||||
} else
|
||||
p = resolved;
|
||||
|
||||
/* Deal with the last component. */
|
||||
if (lstat(p, &sb) == 0) {
|
||||
if (S_ISLNK(sb.st_mode)) {
|
||||
n = readlink(p, resolved, MAXPATHLEN);
|
||||
if (n < 0)
|
||||
goto err1;
|
||||
resolved[n] = '\0';
|
||||
goto loop;
|
||||
}
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
if (chdir(p) < 0)
|
||||
goto err1;
|
||||
p = "";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the last component name and get the full pathname of
|
||||
* the current directory.
|
||||
*/
|
||||
(void)strcpy(wbuf, p);
|
||||
|
||||
/*
|
||||
* Call the inernal internal version of getcwd which
|
||||
* does a physical search rather than using the $PWD short-cut
|
||||
*/
|
||||
if (getcwd_physical(resolved, MAXPATHLEN) == 0)
|
||||
goto err1;
|
||||
|
||||
/*
|
||||
* Join the two strings together, ensuring that the right thing
|
||||
* happens if the last component is empty, or the dirname is root.
|
||||
*/
|
||||
if (resolved[0] == '/' && resolved[1] == '\0')
|
||||
rootd = 1;
|
||||
else
|
||||
rootd = 0;
|
||||
|
||||
if (*wbuf) {
|
||||
if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) {
|
||||
errno = ENAMETOOLONG;
|
||||
goto err1;
|
||||
}
|
||||
if (rootd == 0)
|
||||
(void)strcat(resolved, "/");
|
||||
(void)strcat(resolved, wbuf);
|
||||
}
|
||||
|
||||
/* Go back to where we came from. */
|
||||
if (fchdir(fd) < 0) {
|
||||
serrno = errno;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
/* It's okay if the close fails, what's an fd more or less? */
|
||||
(void)close(fd);
|
||||
return (resolved);
|
||||
|
||||
err1: serrno = errno;
|
||||
(void)fchdir(fd);
|
||||
err2: (void)close(fd);
|
||||
errno = serrno;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static char *
|
||||
getcwd_physical(pt, size)
|
||||
char *pt;
|
||||
size_t size;
|
||||
{
|
||||
register struct dirent *dp;
|
||||
register DIR *dir;
|
||||
@ -101,7 +256,7 @@ getcwd(pt, size)
|
||||
/*
|
||||
* Allocate bytes (1024 - malloc space) for the string of "../"'s.
|
||||
* Should always be enough (it's 340 levels). If it's not, allocate
|
||||
* as necessary. Special * case the first stat, it's ".", not "..".
|
||||
* as necessary. Special case the first stat, it's ".", not "..".
|
||||
*/
|
||||
if ((up = malloc(upsize = 1024 - 4)) == NULL)
|
||||
goto err;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getgrouplist.c,v 1.7 1997/07/21 14:07:06 jtc Exp $ */
|
||||
/* $NetBSD: getgrouplist.c,v 1.8 1998/02/02 02:41:23 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -36,9 +36,9 @@
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getgrouplist.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: getgrouplist.c,v 1.7 1997/07/21 14:07:06 jtc Exp $");
|
||||
__RCSID("$NetBSD: getgrouplist.c,v 1.8 1998/02/02 02:41:23 perry Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getpwent.c,v 1.23 1997/07/21 14:07:13 jtc Exp $ */
|
||||
/* $NetBSD: getpwent.c,v 1.24 1998/02/02 02:41:25 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@ -37,9 +37,9 @@
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getpwent.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: getpwent.c,v 1.23 1997/07/21 14:07:13 jtc Exp $");
|
||||
__RCSID("$NetBSD: getpwent.c,v 1.24 1998/02/02 02:41:25 perry Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@ -73,6 +73,12 @@ __weak_alias(setpassent,_setpassent);
|
||||
__weak_alias(setpwent,_setpwent);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The lookup techniques and data extraction code here must be kept
|
||||
* in sync with that in `pwd_mkdb'.
|
||||
*/
|
||||
|
||||
static struct passwd _pw_passwd; /* password structure */
|
||||
static DB *_pw_db; /* password database */
|
||||
static int _pw_keynum; /* key counter */
|
||||
@ -668,12 +674,8 @@ pwnam_netgrp:
|
||||
}
|
||||
|
||||
struct passwd *
|
||||
#ifdef __STDC__
|
||||
getpwuid(uid_t uid)
|
||||
#else
|
||||
getpwuid(uid)
|
||||
uid_t uid;
|
||||
#endif
|
||||
{
|
||||
DBT key;
|
||||
char bf[sizeof(_pw_keynum) + 1];
|
||||
@ -936,27 +938,24 @@ __hashpw(key)
|
||||
if (data.size > max && !(line = realloc(line, (max += 1024))))
|
||||
return(0);
|
||||
|
||||
/* THIS CODE MUST MATCH THAT IN pwd_mkdb. */
|
||||
t = line;
|
||||
#define EXPAND(e) e = t; while ((*t++ = *p++));
|
||||
#define SCALAR(v) memmove(&(v), p, sizeof v); p += sizeof v
|
||||
EXPAND(_pw_passwd.pw_name);
|
||||
EXPAND(_pw_passwd.pw_passwd);
|
||||
bcopy(p, (char *)&_pw_passwd.pw_uid, sizeof(int));
|
||||
p += sizeof(int);
|
||||
bcopy(p, (char *)&_pw_passwd.pw_gid, sizeof(int));
|
||||
p += sizeof(int);
|
||||
bcopy(p, (char *)&_pw_passwd.pw_change, sizeof(time_t));
|
||||
p += sizeof(time_t);
|
||||
SCALAR(_pw_passwd.pw_uid);
|
||||
SCALAR(_pw_passwd.pw_gid);
|
||||
SCALAR(_pw_passwd.pw_change);
|
||||
EXPAND(_pw_passwd.pw_class);
|
||||
EXPAND(_pw_passwd.pw_gecos);
|
||||
EXPAND(_pw_passwd.pw_dir);
|
||||
EXPAND(_pw_passwd.pw_shell);
|
||||
bcopy(p, (char *)&_pw_passwd.pw_expire, sizeof(time_t));
|
||||
p += sizeof(time_t);
|
||||
SCALAR(_pw_passwd.pw_expire);
|
||||
|
||||
/* See if there's any data left. If so, read in flags. */
|
||||
if (data.size > (p - (char *)data.data)) {
|
||||
bcopy(p, (char *)&_pw_flags, sizeof(int));
|
||||
p += sizeof(int);
|
||||
SCALAR(_pw_flags);
|
||||
} else
|
||||
_pw_flags = _PASSWORD_NOUID|_PASSWORD_NOGID; /* default */
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
.\" $NetBSD: getvfsbyname.3,v 1.2 1998/02/02 02:41:25 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1995
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* $NetBSD: getvfsbyname.c,v 1.2 1998/02/02 02:41:26 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -31,9 +33,14 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)kvm_getvfsbyname.c 8.1 (Berkeley) 4/3/95";
|
||||
#endif /* not lint */
|
||||
#else
|
||||
__RCSID("$NetBSD");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
@ -47,6 +54,7 @@ int getvfsbyname __P((const char *, struct vfsconf *));
|
||||
* Given a filesystem name, determine if it is resident in the kernel,
|
||||
* and if it is resident, return its vfsconf structure.
|
||||
*/
|
||||
int
|
||||
getvfsbyname(fsname, vfcp)
|
||||
const char *fsname;
|
||||
struct vfsconf *vfcp;
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: popen.3,v 1.5 1995/02/25 08:51:29 cgd Exp $
|
||||
.\" $NetBSD: popen.3,v 1.6 1998/02/02 02:41:27 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -31,9 +31,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)popen.3 8.1 (Berkeley) 6/4/93
|
||||
.\" @(#)popen.3 8.2 (Berkeley) 5/3/95
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd May 3, 1995
|
||||
.Dt POPEN 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -52,13 +52,32 @@ The
|
||||
.Fn popen
|
||||
function
|
||||
.Dq opens
|
||||
a process by creating a pipe,
|
||||
a process by creating an IPC connection,
|
||||
forking,
|
||||
and invoking the shell.
|
||||
Since a pipe is by definition unidirectional, the
|
||||
Historically,
|
||||
.Nm popen
|
||||
was implemented with a unidirectional pipe;
|
||||
hence many implementations of
|
||||
.Nm popen
|
||||
only allow the
|
||||
.Fa type
|
||||
argument may specify only reading or writing, not both;
|
||||
the resulting stream is correspondingly read-only or write-only.
|
||||
argument to specify reading or writing, not both.
|
||||
Since
|
||||
.Nm popen
|
||||
is now implemented using sockets, the
|
||||
.Fa type
|
||||
may request a bidirectional data flow.
|
||||
The
|
||||
.Fa type
|
||||
argument is a pointer to a null-terminated string
|
||||
which must be
|
||||
.Ql r
|
||||
for reading,
|
||||
.Ql w
|
||||
for writing, or
|
||||
.Ql r+
|
||||
for reading and writing.
|
||||
.Pp
|
||||
The
|
||||
.Fa command
|
||||
@ -69,15 +88,6 @@ This command is passed to
|
||||
using the
|
||||
.Fl c
|
||||
flag; interpretation, if any, is performed by the shell.
|
||||
The
|
||||
.Fa mode
|
||||
argument is a pointer to a null-terminated string
|
||||
which must be either
|
||||
.Ql r
|
||||
for reading
|
||||
or
|
||||
.Ql w
|
||||
for writing.
|
||||
.Pp
|
||||
The return value from
|
||||
.Fn popen
|
||||
@ -115,9 +125,10 @@ The
|
||||
function returns
|
||||
.Dv NULL
|
||||
if the
|
||||
.Xr fork 2
|
||||
.Xr fork 2 ,
|
||||
.Xr pipe 2 ,
|
||||
or
|
||||
.Xr pipe 2
|
||||
.Xr socketpair 2
|
||||
calls fail,
|
||||
or if it cannot allocate memory.
|
||||
.Pp
|
||||
@ -144,6 +155,7 @@ function does not reliably set
|
||||
.Xr fork 2 ,
|
||||
.Xr sh 1 ,
|
||||
.Xr pipe 2 ,
|
||||
.Xr socketpair 2 ,
|
||||
.Xr wait4 2 ,
|
||||
.Xr fflush 3 ,
|
||||
.Xr fclose 3 ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: popen.c,v 1.15 1997/09/16 00:35:47 thorpej Exp $ */
|
||||
/* $NetBSD: popen.c,v 1.16 1998/02/02 02:41:28 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@ -39,15 +39,16 @@
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: popen.c,v 1.15 1997/09/16 00:35:47 thorpej Exp $");
|
||||
__RCSID("$NetBSD: popen.c,v 1.16 1998/02/02 02:41:28 perry Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
@ -69,30 +70,33 @@ static struct pid {
|
||||
} *pidlist;
|
||||
|
||||
FILE *
|
||||
popen(program, type)
|
||||
const char *program;
|
||||
const char *type;
|
||||
popen(command, type)
|
||||
const char *command, *type;
|
||||
{
|
||||
struct pid *cur, *old;
|
||||
FILE *iop;
|
||||
int pdes[2], pid;
|
||||
int pdes[2], pid, twoway;
|
||||
#ifdef __GNUC__
|
||||
(void) &cur;
|
||||
#endif
|
||||
|
||||
if ((*type != 'r' && *type != 'w') || type[1]) {
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
if (strchr(type, '+')) {
|
||||
twoway = 1;
|
||||
type = "r+";
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pdes) < 0)
|
||||
return (NULL);
|
||||
} else {
|
||||
twoway = 0;
|
||||
if (*type != 'r' && *type != 'w' || type[1] ||
|
||||
(pipe(pdes) < 0)) {
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if ((cur = malloc(sizeof(struct pid))) == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (pipe(pdes) < 0) {
|
||||
free(cur);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
switch (pid = vfork()) {
|
||||
case -1: /* Error. */
|
||||
(void)close(pdes[0]);
|
||||
@ -105,8 +109,11 @@ popen(program, type)
|
||||
if (pdes[1] != STDOUT_FILENO) {
|
||||
(void)dup2(pdes[1], STDOUT_FILENO);
|
||||
(void)close(pdes[1]);
|
||||
pdes[1] = STDOUT_FILENO;
|
||||
}
|
||||
(void) close(pdes[0]);
|
||||
if (twoway && (pdes[1] != STDIN_FILENO))
|
||||
(void)dup2(pdes[1], STDIN_FILENO);
|
||||
} else {
|
||||
if (pdes[0] != STDIN_FILENO) {
|
||||
(void)dup2(pdes[0], STDIN_FILENO);
|
||||
@ -157,8 +164,6 @@ pclose(iop)
|
||||
int pstat;
|
||||
pid_t pid;
|
||||
|
||||
(void)fclose(iop);
|
||||
|
||||
/* Find the appropriate file pointer. */
|
||||
for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
|
||||
if (cur->fp == iop)
|
||||
@ -166,6 +171,8 @@ pclose(iop)
|
||||
if (cur == NULL)
|
||||
return (-1);
|
||||
|
||||
(void)fclose(iop);
|
||||
|
||||
do {
|
||||
pid = waitpid(cur->pid, &pstat, 0);
|
||||
} while (pid == -1 && errno == EINTR);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: psignal.3,v 1.6 1995/07/03 22:48:08 jtc Exp $
|
||||
.\" $NetBSD: psignal.3,v 1.7 1998/02/02 02:41:29 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -31,9 +31,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)psignal.3 8.1 (Berkeley) 6/4/93
|
||||
.\" @(#)psignal.3 8.2 (Berkeley) 2/27/95
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd February 27, 1995
|
||||
.Dt PSIGNAL 3
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: setmode.3,v 1.7 1995/10/12 15:39:28 jtc Exp $
|
||||
.\" $NetBSD: setmode.3,v 1.8 1998/02/02 02:41:30 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -31,9 +31,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)setmode.3 8.1 (Berkeley) 6/9/93
|
||||
.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95
|
||||
.\"
|
||||
.Dd June 9, 1993
|
||||
.Dd April 28, 1995
|
||||
.Dt SETMODE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: sysctl.3,v 1.19 1998/01/05 09:59:03 lukem Exp $
|
||||
.\" $NetBSD: sysctl.3,v 1.20 1998/02/02 02:41:30 perry Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -31,9 +31,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)sysctl.3 8.1 (Berkeley) 6/4/93
|
||||
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd "May 9, 1995"
|
||||
.Dt SYSCTL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -120,7 +120,7 @@ listed here, and described in separate sections below.
|
||||
.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
|
||||
.It Sy Pa Name Next level names Description
|
||||
.It CTL\_DEBUG sys/sysctl.h Debugging
|
||||
.It CTL\_FS sys/sysctl.h File system
|
||||
.It CTL\_VFS sys/mount.h Filesystem
|
||||
.It CTL\_HW sys/sysctl.h Generic CPU, I/O
|
||||
.It CTL\_KERN sys/sysctl.h High kernel limits
|
||||
.It CTL\_MACHDEP sys/sysctl.h Machine dependent
|
||||
@ -179,8 +179,23 @@ as a debugging variable, the following declaration would be used:
|
||||
int dospecialcheck = 1;
|
||||
struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
|
||||
.Ed
|
||||
.Sh CTL_FS
|
||||
There are currently no second level names for the file system.
|
||||
.Sh CTL_VFS
|
||||
A distinguished second level name, VFS_GENERIC,
|
||||
is used to get general information about all filesystems.
|
||||
One of its third level identifiers is VFS_MAXTYPENUM
|
||||
that gives the highest valid filesystem type number.
|
||||
Its other third level identifier is VFS_CONF that
|
||||
returns configuration information about the filesystem
|
||||
type given as a fourth level identifier (see
|
||||
.Xr getvfsbyname 3
|
||||
as an example of its use).
|
||||
The remaining second level identifiers are the
|
||||
filesystem type number returned by a
|
||||
.Xr statfs 2
|
||||
call or from VFS_CONF.
|
||||
The third level identifiers available for each filesystem
|
||||
are given in the header file that defines the mount
|
||||
argument structure for that filesystem.
|
||||
.Sh CTL_HW
|
||||
The string and integer information available for the CTL_HW level
|
||||
is detailed below.
|
||||
@ -207,6 +222,7 @@ The machine class.
|
||||
The machine model
|
||||
.It Li HW_NCPU
|
||||
The number of cpus.
|
||||
.ne 1i
|
||||
.It Li HW_BYTEORDER
|
||||
The byteorder (4,321, or 1,234).
|
||||
.It Li HW_PHYSMEM
|
||||
@ -268,6 +284,7 @@ information.
|
||||
.It KERN\_VERSION string no
|
||||
.It KERN\_VNODE struct vnode no
|
||||
.El
|
||||
.ne 1i
|
||||
.Pp
|
||||
.Bl -tag -width "123456"
|
||||
.It Li KERN_ARGMAX
|
||||
@ -633,6 +650,7 @@ The version of POSIX 1003.2 with which the system attempts to comply.
|
||||
.It Li USER_RE_DUP_MAX
|
||||
The maximum number of repeated occurrences of a regular expression
|
||||
permitted when using interval notation.
|
||||
.ne 1i
|
||||
.It Li USER_STREAM_MAX
|
||||
The minimum maximum number of streams that a process may have open
|
||||
at any one time.
|
||||
@ -694,7 +712,7 @@ for more details.
|
||||
.Sh RETURN VALUES
|
||||
If the call to
|
||||
.Nm sysctl
|
||||
is successful, 0 is returned.
|
||||
is successful, the number of bytes copied out is returned.
|
||||
Otherwise \-1 is returned and
|
||||
.Va errno
|
||||
is set appropriately.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: syslog.c,v 1.12 1997/07/21 14:07:37 jtc Exp $ */
|
||||
/* $NetBSD: syslog.c,v 1.13 1998/02/02 02:41:31 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -36,9 +36,9 @@
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94";
|
||||
static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: syslog.c,v 1.12 1997/07/21 14:07:37 jtc Exp $");
|
||||
__RCSID("$NetBSD: syslog.c,v 1.13 1998/02/02 02:41:31 perry Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user