Subject: devname,daemon,err,uname(3),uname(1) and dev_mkdb(8) (#227 1 of 2)
Index:	libc/gen/{devname,daemon,err,uname}.c,usr.bin/uname,etc/dev_mkdb 2.11BSD

Description:
	Several new C library routines and two new utility programs have
	been ported from 4.4-Lite to 2.11BSD.

Repeat-By:
	Not applicable.

Fix:
	This started out as a port of one thing for a specific program.
	The devname.c module was going to be ported so that the fixed
	string in sysctl(8) could be removed.

	In order for devname() to be useful the 'dev_mkdb' program was 
	needed to create the database (/var/run/dev.{dir,pag}) that would 
	be accessed.

	But 'dev_mkdb' program wanted to report errors using the 4.4 err()
	routines.  So the err(3) routines had to be ported.

	The err(3) routines wanted the global variable '__progname' to
	be initialized with the basename'd argv[0].  This meant that the
	startup routine 'crt0.o' needed to be changed.

	If crt0.o was changed then location 0 was no longer special to
	'printf' and the "(null)" logic in doprnt.s could be removed.

	At that point the list of changed and ported routines was long
	enough that porting a couple more would make little difference:
	daemon(3) and uname(3) were ported.

	Below is a shar file of new files to be added to the system.  Cut
	where indicated, save to a file (/tmp/227) and then:

		sh /tmp/227

	Do not compile anything yet.  Part 2 (#228) contains updates to
	several other C library files as well as the remainder of the
	instructions.

=============================cut here======================
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	/usr/src/lib/libc/gen/devname.c
#	/usr/src/lib/libc/gen/err.c
#	/usr/src/lib/libc/gen/uname.c
#	/usr/src/lib/libc/gen/daemon.c
#	/usr/src/etc/dev_mkdb
#	/usr/src/man/man3/daemon.3
#	/usr/src/man/man3/devname.3
#	/usr/src/man/man3/err.3
#	/usr/src/man/man3/uname.3
#	/usr/src/sys/h/utsname.h
#	/usr/src/usr.bin/uname
# This archive created: Mon Feb  6 19:59:39 1995
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f '/usr/src/lib/libc/gen/devname.c'
then
	echo shar: "will not over-write existing file '/usr/src/lib/libc/gen/devname.c'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/gen/devname.c'
X/*
X * Copyright (c) 1989, 1993
X *	The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)devname.c	8.1.1 (2.11BSD GTE) 2/3/95";
X#endif /* LIBC_SCCS and not lint */
X
X#include <sys/types.h>
X#include <ndbm.h>
X#include <fcntl.h>
X#include <paths.h>
X#include <stdio.h>
X
Xchar *
Xdevname(dev, type)
X	dev_t dev;
X	mode_t type;
X{
X	struct {
X		mode_t type;
X		dev_t dev;
X	} bkey;
X	char	*devdb = _PATH_DEVDB;
X	static DBM *db;
X	static int failure;
X	datum data, key;
X
X	if (!db && !failure &&
X	    !(db = dbm_open(devdb, O_RDONLY, 0))) {
X		warn("warning: %s", devdb);
X		failure = 1;
X	}
X	if (failure)
X		return("??");
X
X	/*
X	 * Keys are a mode_t followed by a dev_t.  The former is the type of
X	 * the file (mode & S_IFMT), the latter is the st_rdev field.  Be
X	 * sure to clear any padding that may be found in bkey.
X	 */
X	memset(&bkey, 0, sizeof(bkey));
X	bkey.dev = dev;
X	bkey.type = type;
X	key.dptr = (char *)&bkey;
X	key.dsize = sizeof(bkey);
X	data = dbm_fetch(db, key);
X	return(data.dptr == NULL ? "??" : (char *)data.dptr);
X}
SHAR_EOF
chmod 444 '/usr/src/lib/libc/gen/devname.c'
fi
if test -f '/usr/src/lib/libc/gen/err.c'
then
	echo shar: "will not over-write existing file '/usr/src/lib/libc/gen/err.c'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/gen/err.c'
X/*-
X * Copyright (c) 1993
X *	The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)err.c	8.1.1 (2.11BSD GTE) 2/3/95";
X#endif /* LIBC_SCCS and not lint */
X
X#include <stdio.h>
X
X#ifdef __STDC__
X#include <stdarg.h>
X#else
X#include <varargs.h>
X#endif
X
Xextern	int	errno;
Xextern	char *__progname;		/* Program name, from crt0. */
Xstatic	void	putprog(), putcolsp();
X
Xvoid
X#ifdef __STDC__
Xerr(int eval, const char *fmt, ...)
X#else
Xerr(eval, fmt, va_alist)
X	int eval;
X	char *fmt;
X	va_dcl
X#endif
X{
X	va_list ap;
X#if __STDC__
X	va_start(ap, fmt);
X#else
X	va_start(ap);
X#endif
X	verr(eval, fmt, ap);
X	va_end(ap);
X}
X
Xvoid
Xverr(eval, fmt, ap)
X	int eval;
X	char *fmt;
X	va_list ap;
X{
X	int sverrno;
X
X	sverrno = errno;
X	putprog();
X	if (fmt != NULL) {
X		(void)vfprintf(stderr, fmt, ap);
X		putcolsp();
X	}
X	(void)fputs(strerror(sverrno), stderr);
X	(void)fputc('\n', stderr);
X	exit(eval);
X}
X
Xvoid
X#if __STDC__
Xerrx(int eval, const char *fmt, ...)
X#else
Xerrx(eval, fmt, va_alist)
X	int eval;
X	char *fmt;
X	va_dcl
X#endif
X{
X	va_list ap;
X#if __STDC__
X	va_start(ap, fmt);
X#else
X	va_start(ap);
X#endif
X	verrx(eval, fmt, ap);
X	va_end(ap);
X}
X
Xvoid
Xverrx(eval, fmt, ap)
X	int eval;
X	char *fmt;
X	va_list ap;
X{
X	putprog();
X	if (fmt != NULL)
X		(void)vfprintf(stderr, fmt, ap);
X	(void)fputc('\n', stderr);
X	exit(eval);
X}
X
Xvoid
X#if __STDC__
Xwarn(const char *fmt, ...)
X#else
Xwarn(fmt, va_alist)
X	char *fmt;
X	va_dcl
X#endif
X{
X	va_list ap;
X#if __STDC__
X	va_start(ap, fmt);
X#else
X	va_start(ap);
X#endif
X	vwarn(fmt, ap);
X	va_end(ap);
X}
X
Xvoid
Xvwarn(fmt, ap)
X	char *fmt;
X	va_list ap;
X{
X	int sverrno;
X
X	sverrno = errno;
X	putprog();
X	if (fmt != NULL) {
X		(void)vfprintf(stderr, fmt, ap);
X		putcolsp();
X	}
X	(void)fputs(strerror(sverrno), stderr);
X	(void)fputc('\n', stderr);
X}
X
Xvoid
X#ifdef __STDC__
Xwarnx(const char *fmt, ...)
X#else
Xwarnx(fmt, va_alist)
X	char *fmt;
X	va_dcl
X#endif
X{
X	va_list ap;
X#ifdef __STDC__
X	va_start(ap, fmt);
X#else
X	va_start(ap);
X#endif
X	vwarnx(fmt, ap);
X	va_end(ap);
X}
X
Xvoid
Xvwarnx(fmt, ap)
X	char *fmt;
X	va_list ap;
X{
X	putprog();
X	if (fmt != NULL)
X		(void)vfprintf(stderr, fmt, ap);
X	(void)fputc('\n', stderr);
X}
X
X/*
X * Helper routines.  Repeated constructs of the form "%s: " used up too
X * much D space.  On a pdp-11 code can be overlaid but Data space is worth
X * conserving.  An extra function call or two handling an error condition is
X * a reasonable trade for 20 or 30 bytes of D space.
X*/
X
Xstatic void
Xputprog()
X	{
X
X	fputs(__progname, stderr);
X	putcolsp();
X	}
X
Xstatic void
Xputcolsp()
X	{
X
X	fputc(':', stderr);
X	fputc(' ', stderr);
X	}
SHAR_EOF
chmod 444 '/usr/src/lib/libc/gen/err.c'
fi
if test -f '/usr/src/lib/libc/gen/uname.c'
then
	echo shar: "will not over-write existing file '/usr/src/lib/libc/gen/uname.c'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/gen/uname.c'
X/*-
X * Copyright (c) 1994
X *	The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)uname.c	8.1.1 (2.11BSD GTE) 2/4/95";
X#endif /* LIBC_SCCS and not lint */
X
X#include <sys/param.h>
X#include <sys/sysctl.h>
X#include <sys/utsname.h>
X
Xint
Xuname(name)
X	register struct utsname *name;
X{
X	int mib[2], rval;
X	size_t len;
X	register char *p;
X
X	rval = 0;
X
X	mib[0] = CTL_KERN;
X	mib[1] = KERN_OSTYPE;
X	len = sizeof(name->sysname);
X	if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) == -1)
X		rval = -1;
X
X	mib[0] = CTL_KERN;
X	mib[1] = KERN_HOSTNAME;
X	len = sizeof(name->nodename);
X	if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) == -1)
X		rval = -1;
X
X	mib[0] = CTL_KERN;
X	mib[1] = KERN_OSRELEASE;
X	len = sizeof(name->release);
X	if (sysctl(mib, 2, &name->release, &len, NULL, 0) == -1)
X		rval = -1;
X
X	/* The version may have newlines in it, turn them into spaces. */
X	mib[0] = CTL_KERN;
X	mib[1] = KERN_VERSION;
X	len = sizeof(name->version);
X	if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1)
X		rval = -1;
X	else
X		for (p = name->version; len--; ++p)
X			if (*p == '\n' || *p == '\t')
X				if (len > 1)
X					*p = ' ';
X				else
X					*p = '\0';
X
X	mib[0] = CTL_HW;
X	mib[1] = HW_MACHINE;
X	len = sizeof(name->machine);
X	if (sysctl(mib, 2, &name->machine, &len, NULL, 0) == -1)
X		rval = -1;
X	return (rval);
X}
SHAR_EOF
chmod 444 '/usr/src/lib/libc/gen/uname.c'
fi
if test -f '/usr/src/lib/libc/gen/daemon.c'
then
	echo shar: "will not over-write existing file '/usr/src/lib/libc/gen/daemon.c'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/gen/daemon.c'
X/*-
X * Copyright (c) 1990, 1993
X *	The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)daemon.c	8.1.1 (2.11BSD GTE) 2/3/95";
X#endif /* LIBC_SCCS and not lint */
X
X#include <fcntl.h>
X#include <sys/ioctl.h>
X#include <paths.h>
X
Xint
Xdaemon(nochdir, noclose)
X	int nochdir, noclose;
X{
X	register int fd;
X
X	switch (fork()) {
X	case -1:
X		return (-1);
X	case 0:
X		break;
X	default:
X		_exit(0);
X	}
X
X	if ((fd = open(_PATH_TTY, O_RDWR)) >= 0) {
X		ioctl(fd, TIOCNOTTY, 0);
X		close(fd);
X	}
X
X	if (!nochdir)
X		(void)chdir("/");
X
X	if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
X		(void)dup2(fd, 0);
X		(void)dup2(fd, 1);
X		(void)dup2(fd, 2);
X		if (fd > 2)
X			(void)close(fd);
X	}
X	return(0);
X}
SHAR_EOF
chmod 444 '/usr/src/lib/libc/gen/daemon.c'
fi
if test ! -d '/usr/src/etc/dev_mkdb'
then
	mkdir '/usr/src/etc/dev_mkdb'
fi
cd '/usr/src/etc/dev_mkdb'
if test -f 'dev_mkdb.8'
then
	echo shar: "will not over-write existing file 'dev_mkdb.8'"
else
sed 's/^X//' << \SHAR_EOF > 'dev_mkdb.8'
X.\" Copyright (c) 1990, 1993
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"	@(#)dev_mkdb.8	8.1.1 (2.11BSD GTE) 2/3/95
X.\"
X.TH DEV_MKDB 8 "February 3, 1995"
X.UC 4
X.SH NAME
Xdev_mkdb \- create \fI/dev\fP database
X.SH SYNOPSIS
Xdev_mkdb
X.SH DESCRIPTION
XThe
X.B dev_mkdb
Xcommand creates a
X.IR dbm (3)
Xhash access method database in
X.I /var/run/dev.db
Xwhich contains the names of all of the character and block special
Xfiles in the
X.I /dev
Xdirectory, using the file type and the 
X.I st_rdev
Xfield as the key.
X.PP
XKeys are a structure containing a mode_t followed by a dev_t,
Xwith any padding zero'd out.
XThe former is the type of the file (st_mode & S_IFMT),
Xthe latter is the st_rdev field.
X.SH FILES
X.TP 20
X/dev
XDevice directory.
X.TP 20
X/var/run/dev.db
XDatabase file.
X.SH SEE ALSO
Xps(1),
Xstat(2),
Xdbm(3),
Xdevname(3),
Xttyname(3)
X.SH HISTORY
XThe
X.B dev_mkdb
Xcommand appeared in 4.4BSD.
SHAR_EOF
chmod 444 'dev_mkdb.8'
fi
if test -f 'dev_mkdb.c'
then
	echo shar: "will not over-write existing file 'dev_mkdb.c'"
else
sed 's/^X//' << \SHAR_EOF > 'dev_mkdb.c'
X/*-
X * Copyright (c) 1990, 1993
X *	The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if	!defined(lint) && defined(DOSCCS)
Xstatic char copyright[] =
X"@(#) Copyright (c) 1990, 1993\n\
X	The Regents of the University of California.  All rights reserved.\n";
X
Xstatic char sccsid[] = "@(#)dev_mkdb.c	8.1.1 (2.11BSD GTE) 2/3/95";
X#endif
X
X#include <sys/param.h>
X#include <sys/stat.h>
X#include <fcntl.h>
X#include <sys/dir.h>
X#include <ndbm.h>
X#include <stdio.h>
X#include <paths.h>
X
Xextern	int	optind;
Xextern	void	err();
X	void	usage();
X
Xint
Xmain(argc, argv)
X	int argc;
X	char *argv[];
X{
X	register DIR *dirp;
X	register struct direct *dp;
X	struct stat sb;
X	struct {
X		mode_t type;
X		dev_t dev;
X	} bkey;
X	DBM *db;
X	datum data, key;
X	int ch;
X	u_char buf[MAXNAMLEN + 1];
X	char dbtmp[MAXPATHLEN + 1], dbname[MAXPATHLEN + 1];
X	char *varrun = _PATH_VARRUN;
X
X	umask(022);
X
X	while ((ch = getopt(argc, argv, "")) != EOF)
X		switch((char)ch) {
X		case '?':
X		default:
X			usage();
X		}
X	argc -= optind;
X	argv += optind;
X
X	if (argc > 0)
X		usage();
X
X	if (chdir(_PATH_DEV))
X		err(1, "%s", _PATH_DEV);
X
X	dirp = opendir(".");
X
X	(void)sprintf(dbtmp, "%sdev.tmp", varrun);
X	db = dbm_open(dbtmp, O_CREAT|O_EXLOCK|O_RDWR|O_TRUNC, 0644);
X	if (db == NULL)
X		err(1, "%s", dbtmp);
X
X	/*
X	 * Keys are a mode_t followed by a dev_t.  The former is the type of
X	 * the file (mode & S_IFMT), the latter is the st_rdev field.  Note
X	 * that the structure may contain padding, so we have to clear it
X	 * out here.
X	 */
X	bzero(&bkey, sizeof(bkey));
X	key.dptr = (char *)&bkey;
X	key.dsize = sizeof(bkey);
X	data.dptr = (char *)buf;
X	while (dp = readdir(dirp)) {
X		if (lstat(dp->d_name, &sb)) {
X			warn("%s", dp->d_name);
X			continue;
X		}
X
X		/* Create the key. */
X		if ((sb.st_mode & S_IFMT) == S_IFCHR)
X			bkey.type = S_IFCHR;
X		else if ((sb.st_mode & S_IFMT) == S_IFBLK)
X			bkey.type = S_IFBLK;
X		else
X			continue;
X		bkey.dev = sb.st_rdev;
X
X		/*
X		 * Create the data; nul terminate the name so caller doesn't
X		 * have to.
X		 */
X		bcopy(dp->d_name, buf, dp->d_namlen);
X		buf[dp->d_namlen] = '\0';
X		data.dsize = dp->d_namlen + 1;
X		if (dbm_store(db, key, data, DBM_REPLACE) < 0)
X			err(1, "dbm_store %s", dbtmp);
X	}
X	(void)dbm_close(db);
X
X	sigsetmask(~0L);
X	sprintf(dbname, "%sdev.pag", varrun);
X	sprintf(dbtmp,  "%sdev.tmp.pag", varrun);
X	if (rename(dbtmp, dbname))
X		err(1, "rename %s to %s", dbtmp, dbname);
X	sprintf(dbname, "%sdev.dir", varrun);
X	sprintf(dbtmp,  "%sdev.tmp.dir", varrun);
X	if (rename(dbtmp, dbname))
X		err(1, "rename %s to %s", dbtmp, dbname);
X	exit(0);
X}
X
Xvoid
Xusage()
X{
X	err(1, "usage: dev_mkdb");
X}
SHAR_EOF
chmod 444 'dev_mkdb.c'
fi
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X#
X# Public Domain.  2/3/1995 - Steven Schultz
X#
X#	@(#)Makefile	1.0 (2.11BSD GTE) 2/3/95
X#
XCFLAGS=	 -O
XSEPFLAG= -i
XSRCS=	dev_mkdb.c
XOBJS=	dev_mkdb.o
XMAN=	dev_mkdb.0
XMANSRC=	dev_mkdb.8
X
Xall: dev_mkdb dev_mkdb.0
X
Xdev_mkdb: ${OBJS}
X	${CC} ${CFLAGS} ${SEPFLAG} -o $@ ${OBJS}
X
Xdev_mkdb.0: ${MANSRC}
X	/usr/man/manroff ${MANSRC} > ${MAN}
X
Xclean:
X	rm -f ${OBJS} ${MAN} dev_mkdb tags 
X
Xdepend: ${SRCS}
X	mkdep ${CFLAGS} ${SRCS}
X
Xinstall: all
X	install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat8
X	install -s -o root -g bin -m 755 dev_mkdb ${DESTDIR}/etc/dev_mkdb
X
Xlint: ${SRCS}
X	lint -hax ${SRCS}
X
Xtags: ${SRCS}
X	ctags ${SRCS}
X# DO NOT DELETE THIS LINE -- mkdep uses it.
X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
SHAR_EOF
chmod 644 'Makefile'
fi
chmod 755 .
cd ..
if test -f '/usr/src/man/man3/daemon.3'
then
	echo shar: "will not over-write existing file '/usr/src/man/man3/daemon.3'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/man/man3/daemon.3'
X.\" Copyright (c) 1993
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"	@(#)daemon.3	8.1.1 (2.11BSD GTE) 2/5/95
X.TH DAEMON 3 "February 3, 1995"
X.UC 4
X.SH NAME
Xdaemon \- run in the background
X.SH SYNOPSIS
X.nf
X.ft B
Xint
Xdaemon(nochdir, noclose)
X    int nochdir, noclose;
X.ft R
X.fi
X.SH DESCRIPTION
X.PP
XThe
X.B daemon
Xfunction is for programs wishing to detach themselves from the
Xcontrolling terminal and run in the background as system daemons.
X.PP
XUnless the argument
X.I nochdir
Xis non-zero,
X.B daemon
Xchanges the current working directory to the root (``/'').
X.PP
XUnless the argument
X.I noclose
Xis non-zero,
X.B daemon
Xwill redirect standard input, standard output and standard error
Xto ``/dev/null''.
X.SH ERRORS
XThe function
X.B daemon
Xmay fail and set
X.I errno
Xfor any of the errors specified for the library functions
X.IR fork (2) .
X.SH SEE ALSO
Xfork(2), ioctl(2).
X.SH HISTORY
XThe
X.B daemon
Xfunction first appeared in 4.4BSD.
SHAR_EOF
chmod 444 '/usr/src/man/man3/daemon.3'
fi
if test -f '/usr/src/man/man3/devname.3'
then
	echo shar: "will not over-write existing file '/usr/src/man/man3/devname.3'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/man/man3/devname.3'
X.\" Copyright (c) 1993
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"     @(#)devname.3	8.1.1 (2.11BSD GTE) 2/3/95
X.\"
X.TH DEVNAME 3 "February 3, 1995"
X.UC 4
X.SH NAME
Xdevname \- get device name
X.SH SYNOPSIS
X.nf
X.ft B
X#include <sys/types.h>
X
Xchar *
Xdevname(dev, type)
X    dev_t dev;
X    mode_t type;
X.ft R
X.fi
X.SH DESCRIPTION
XThe
X.B devname
Xfunction returns a pointer to the name of the block or character
Xdevice in
X.IR /dev
Xwith a device number of
X.I dev ,
Xand a file type matching the one encoded in
X.I type
Xwhich must be one of S_IFBLK or S_IFCHR.
XIf no device matches the specified values, or no information is
Xavailable, the string
X.I ??
Xis returned.
X.SH SEE ALSO
Xstat(2),
Xdev_mkdb(8)
X.SH HISTORY
XThe
X.B devname
Xfunction call appeared in 4.4BSD.
SHAR_EOF
chmod 444 '/usr/src/man/man3/devname.3'
fi
if test -f '/usr/src/man/man3/err.3'
then
	echo shar: "will not over-write existing file '/usr/src/man/man3/err.3'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/man/man3/err.3'
X.\" Copyright (c) 1993
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"	@(#)err.3	8.1.1 (2.11BSD GTE) 2/3/95
X.\"
X.TH ERR 3 "February 3, 1995"
X.UC 4
X.SH NAME
Xerr,
Xverr ,
Xerrx ,
Xverrx ,
Xwarn ,
Xvwarn ,
Xwarnx ,
Xvwarnx \- formatted error messages
X.SH SYNOPSIS
X.nf
X.ft B
Xvoid
Xerr(eval, fmt, ...)
X    int eval;
X    char *fmt;
X.PP
Xvoid
Xverr(eval, fmt, args)
X    int eval;
X    char *fmt;
X    va_list args;
X.PP
Xvoid
Xerrx(eval, fmt, ...)
X    int eval;
X    char *fmt;
X.PP
Xvoid
Xverrx(eval, fmt, args)
X    int eval
X    char *fmt;
X    va_list args;
X.PP
Xvoid
Xwarn(fmt, ...)
X    char *fmt;
X.PP
Xvoid
Xvwarn(fmt, args)
X    char *fmt;
X    va_list args;
X.PP
Xvoid
Xwarnx(fmt, ...)
X    char *fmt;
X.PP
Xvoid
Xvwarnx(fmt, args)
X    char *fmt;
X    va_list args;
X.ft R
X.fi
X.SH DESCRIPTION
XThe
X.B err
Xand
X.B warn
Xfamily of functions display a formatted error message on the standard
Xerror output.
XIn all cases, the last component of the program name, a colon character,
Xand a space are output.
XIf the
X.I fmt
Xargument is not NULL, the formatted error message, a colon character,
Xand a space are output.
XIn the case of the
X.BR err ,
X.BR verr ,
X.BR warn ,
Xand
X.BR vwarn
Xfunctions, the error message string affiliated with the current value of
Xthe global variable
X.I errno 
Xis output.
XIn all cases, the output is followed by a newline character.
X.PP
XThe
X.BR err ,
X.BR verr ,
X.BR errx ,
Xand
X.BR verrx
Xfunctions do not return, but exit with the value of the argument
X.IR eval .
X.SH EXAMPLES
XDisplay the current errno information string and exit:
X.sp
X.in +1.0i
X.nf
Xif ((p = malloc(size)) == NULL)
X	err(1, NULL);
Xif ((fd = open(file_name, O_RDONLY, 0)) == -1)
X	err(1, "%s", file_name);
X.in -1.0i
X.fi
X.PP
XDisplay an error message and exit:
X.sp
X.in +1.0i
X.nf
Xif (tm.tm_hour < START_TIME)
X	errx(1, "too early, wait until %s", start_time_string);
X.in -1.0i
X.fi
X.PP
XWarn of an error:
X.sp
X.in +1.0i
X.nf
Xif ((fd = open(raw_device, O_RDONLY, 0)) == -1)
X	warnx("%s: %s: trying the block device",
X	    raw_device, strerror(errno));
Xif ((fd = open(block_device, O_RDONLY, 0)) == -1)
X	err(1, "%s", block_device);
X.in -1.0i
X.fi
X.SH SEE ALSO
Xstrerror(3)
X.SH HISTORY
XThe
X.B err
Xand
X.B warn
Xfunctions first appeared in 4.4BSD.
SHAR_EOF
chmod 444 '/usr/src/man/man3/err.3'
fi
if test -f '/usr/src/man/man3/uname.3'
then
	echo shar: "will not over-write existing file '/usr/src/man/man3/uname.3'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/man/man3/uname.3'
X.\" Copyright (c) 1994
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"	@(#)uname.3	8.1.1 (2.11BSD GTE) 2/4/95
X.\"
X.TH UNAME 3 "February 4, 1995"
X.UC 4
X.SH NAME
Xuname \- get system identification
X.SH SYNOPSIS
X.nf
X.ft B
X#include <sys/utsname.h>
X
Xint
Xuname(name)
Xstruct utsname *name
X.ft R
X.fi
X.SH DESCRIPTION
XThe
X.B uname
Xfunction stores nul-terminated strings of information identifying
Xthe current system into the structure referenced by
X.IR name .
X.PP
XThe
X.I utsname
Xstructure is defined in the
X.I <sys/utsname.h>
Xheader file, and contains the following members:
X.TP 15
Xsysname
XName of the operating system implementation.
X.TP 15
Xnodename
XNetwork name of this machine.
X.TP 15
Xrelease
XRelease level of the operating system.
X.TP 15
Xversion
XVersion level of the operating system.
X.TP 15
Xmachine
XMachine hardware platform.
X.SH RETURN VALUES
XIf
X.B uname
Xis successful, 0 is returned, otherwise, -1 is returned and
X.I errno
Xis set appropriately.
X.SH ERRORS
XThe
X.B uname
Xfunction may fail and set
X.I errno
Xfor any of the errors specified for the library functions
Xsysctl(3).
X.SH SEE ALSO
Xuname(1), sysctl(3)
X.SH STANDARDS
XThe
X.B uname
Xfunction conforms to
XIEEE Std1003.1-88 (``POSIX'').
X.SH HISTORY
XThe
X.B uname
Xfunction first appeared in 4.4BSD.
SHAR_EOF
chmod 444 '/usr/src/man/man3/uname.3'
fi
if test -f '/usr/src/sys/h/utsname.h'
then
	echo shar: "will not over-write existing file '/usr/src/sys/h/utsname.h'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/sys/h/utsname.h'
X/*-
X * Copyright (c) 1994
X *	The Regents of the University of California.  All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Chuck Karish of Mindcraft, Inc.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X *	@(#)utsname.h	8.1.1 (2.11BSD GTE) 2/4/95
X */
X
X#ifndef	_SYS_UTSNAME_H
X#define	_SYS_UTSNAME_H
X
Xstruct utsname {
X	char	sysname[128];	/* Name of this OS. */
X	char	nodename[128];	/* Name of this network node. */
X	char	release[128];	/* Release level. */
X	char	version[128];	/* Version level. */
X	char	machine[128];	/* Hardware type. */
X};
X
X#endif	/* !_SYS_UTSNAME_H */
SHAR_EOF
chmod 444 '/usr/src/sys/h/utsname.h'
fi
if test ! -d '/usr/src/usr.bin/uname'
then
	mkdir '/usr/src/usr.bin/uname'
fi
cd '/usr/src/usr.bin/uname'
if test -f 'uname.1'
then
	echo shar: "will not over-write existing file 'uname.1'"
else
sed 's/^X//' << \SHAR_EOF > 'uname.1'
X.\" Copyright (c) 1993
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"	@(#)uname.1	8.3.1 (2.11BSD GTE) 2/4/95
X.\"
X.TH UNAME 1 "February 4, 1995"
X.UC 4
X.SH NAME
Xuname \- display information about the system
X.SH SYNOPSIS
X.B uname [\-amnrsv]
X.SH DESCRIPTION
XThe
X.B uname
Xcommand writes the name of the operating system implementation to
Xstandard output.
XWhen options are specified, strings representing one or more system
Xcharacteristics are written to standard output.
X.PP
XThe options are as follows:
X.TP 10
X\-a
XBehave as though the options
X\-m, \-n, \-r , \-s, and \-v were specified.
X.TP 10
X\-m
XWrite the type of the current hardware platform to standard output.
X.TP 10
X\-n
XWrite the name of the system to standard output.
X.TP 10
X\-r
XWrite the current release level of the operating system
Xto standard output.
X.TP 10
X\-s
XWrite the name of the operating system implementation to standard output.
X.TP 10
X\-v
XWrite the version level of this release of the operating system
Xto standard output.
X.PP
XIf the
X\-a
Xflag is specified, or multiple flags are specified, all
Xoutput is written on a single line, separated by spaces.
X.PP
XThe
X.B uname
Xutility exits 0 on success, and >0 if an error occurs.
X.SH SEE ALSO
Xsysctl(8), sysctl(3), uname(3)
X.SH HISTORY
XThe
X.B uname
Xcommand appeared in 4.4BSD.
X.SH STANDARDS
XThe
X.Nm uname
Xcommand is expected to conform to the
XIEEE Std1003.2 (``POSIX'')
Xspecification.
SHAR_EOF
chmod 444 'uname.1'
fi
if test -f 'uname.c'
then
	echo shar: "will not over-write existing file 'uname.c'"
else
sed 's/^X//' << \SHAR_EOF > 'uname.c'
X/*-
X * Copyright (c) 1993
X *	The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if	!defined(lint) && defined(DOSCCS)
Xstatic char copyright[] =
X"@(#) Copyright (c) 1993\n\
X	The Regents of the University of California.  All rights reserved.\n";
X
Xstatic char sccsid[] = "@(#)uname.c	8.1.1 (2.11BSD GTE) 2/4/95";
X#endif /* not lint */
X
X#include <sys/param.h>
X#include <sys/sysctl.h>
X
X#include <stdio.h>
X
Xextern	int	optind;
X
Xvoid usage();
X
Xint
Xmain(argc, argv)
X	int argc;
X	char *argv[];
X{
X#define	MFLAG	0x01
X#define	NFLAG	0x02
X#define	RFLAG	0x04
X#define	SFLAG	0x08
X#define	VFLAG	0x10
X	register u_int flags;
X	int ch, mib[2];
X	size_t len, tlen;
X	register char *p, *prefix;
X	char buf[1024];
X
X	flags = 0;
X	while ((ch = getopt(argc, argv, "amnrsv")) != EOF)
X		switch(ch) {
X		case 'a':
X			flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
X			break;
X		case 'm':
X			flags |= MFLAG;
X			break;
X		case 'n':
X			flags |= NFLAG;
X			break;
X		case 'r':
X			flags |= RFLAG;
X			break;
X		case 's':
X			flags |= SFLAG;
X			break;
X		case 'v':
X			flags |= VFLAG;
X			break;
X		case '?':
X		default:
X			usage();
X		}
X
X	argc -= optind;
X	argv += optind;
X
X	if (argc)
X		usage();
X
X	if (!flags)
X		flags |= SFLAG;
X
X	prefix = "";
X
X	if (flags & SFLAG) {
X		mib[0] = CTL_KERN;
X		mib[1] = KERN_OSTYPE;
X		len = sizeof(buf);
X		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
X			err(1, "sysctl");
X		(void)printf("%s%.*s", prefix, len, buf);
X		prefix = " ";
X	}
X	if (flags & NFLAG) {
X		mib[0] = CTL_KERN;
X		mib[1] = KERN_HOSTNAME;
X		len = sizeof(buf);
X		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
X			err(1, "sysctl");
X		(void)printf("%s%.*s", prefix, len, buf);
X		prefix = " ";
X	}
X	if (flags & RFLAG) {
X		mib[0] = CTL_KERN;
X		mib[1] = KERN_OSRELEASE;
X		len = sizeof(buf);
X		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
X			err(1, "sysctl");
X		(void)printf("%s%.*s", prefix, len, buf);
X		prefix = " ";
X	}
X	if (flags & VFLAG) {
X		mib[0] = CTL_KERN;
X		mib[1] = KERN_VERSION;
X		len = sizeof(buf);
X		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
X			err(1, "sysctl");
X		for (p = buf, tlen = len; tlen--; ++p)
X			if (*p == '\n' || *p == '\t')
X				*p = ' ';
X		(void)printf("%s%.*s", prefix, len, buf);
X		prefix = " ";
X	}
X	if (flags & MFLAG) {
X		mib[0] = CTL_HW;
X		mib[1] = HW_MACHINE;
X		len = sizeof(buf);
X		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
X			err(1, "sysctl");
X		(void)printf("%s%.*s", prefix, len, buf);
X		prefix = " ";
X	}
X	(void)printf("\n");
X	exit (0);
X}
X
Xvoid
Xusage()
X{
X	(void)fprintf(stderr, "usage: uname [-amnrsv]\n");
X	exit(1);
X}
SHAR_EOF
chmod 444 'uname.c'
fi
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X#
X# Public Domain.  2/4/1995 - Steven Schultz
X#
X#	@(#)Makefile	1.1 (2.11BSD GTE) 2/3/95
X#
XCFLAGS=	 -O
XSEPFLAG= -i
XSRCS=	uname.c
XOBJS=	uname.o
XMAN=	uname.0
XMANSRC=	uname.1
X
Xall: uname uname.0
X
Xuname: ${OBJS}
X	${CC} ${CFLAGS} ${SEPFLAG} -o $@ ${OBJS}
X
Xuname.0: ${MANSRC}
X	/usr/man/manroff ${MANSRC} > ${MAN}
X
Xclean:
X	rm -f ${OBJS} ${MAN} uname tags 
X
Xdepend: ${SRCS}
X	mkdep ${CFLAGS} ${SRCS}
X
Xinstall: all
X	install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat1
X	install -s -o root -g bin -m 755 uname ${DESTDIR}/usr/bin/uname
X
Xlint: ${SRCS}
X	lint -hax ${SRCS}
X
Xtags: ${SRCS}
X	ctags ${SRCS}
X# DO NOT DELETE THIS LINE -- mkdep uses it.
X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
SHAR_EOF
chmod 644 'Makefile'
fi
chmod 755 .
cd ..
exit 0
#	End of shell archive
