about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/Makefile67
-rw-r--r--misc/bsd-compat.c50
-rw-r--r--misc/daemon.c71
-rw-r--r--misc/fstab.c205
-rw-r--r--misc/fstab.h79
-rw-r--r--misc/getpass.c92
-rw-r--r--misc/getttyent.c199
-rw-r--r--misc/getusershell.c137
-rw-r--r--misc/init-misc.c42
-rw-r--r--misc/insremque.c55
-rw-r--r--misc/ioctltst.c55
-rw-r--r--misc/nlist.h48
-rw-r--r--misc/paths.h69
-rw-r--r--misc/progname.c50
-rw-r--r--misc/sgtty.h36
-rw-r--r--misc/sys/cdefs.h104
-rw-r--r--misc/sys/dir.h28
-rw-r--r--misc/sys/file.h55
-rw-r--r--misc/sys/ioctl.h130
-rw-r--r--misc/sys/ptrace.h137
-rw-r--r--misc/sys/syslog.h196
-rw-r--r--misc/sys/uio.h58
-rw-r--r--misc/syslog.c235
-rw-r--r--misc/syslog.h1
-rw-r--r--misc/ttyent.h66
-rw-r--r--misc/ttyslot.c68
26 files changed, 2333 insertions, 0 deletions
diff --git a/misc/Makefile b/misc/Makefile
new file mode 100644
index 0000000000..33ddfda39e
--- /dev/null
+++ b/misc/Makefile
@@ -0,0 +1,67 @@
+# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB.  If
+# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+# Cambridge, MA 02139, USA.
+
+#
+#	Sub-makefile for misc portion of the library.
+#
+
+subdir	:= misc
+
+headers	:= sys/uio.h sys/ioctl.h sys/ptrace.h ioctls.h sys/file.h	\
+	   a.out.h nlist.h stab.h stab.def sgtty.h sys/dir.h sys/cdefs.h \
+	   ttyent.h syscall.h syslog.h sys/syslog.h paths.h sys/reboot.h \
+	   sys/mman.h sys/param.h fstab.h
+
+routines := brk sbrk sstk ioctl \
+	    readv writev \
+	    setreuid setregid \
+	    seteuid setegid \
+	    getpagesize \
+	    getdtsz \
+	    gethostname sethostname getdomain setdomain \
+	    select \
+	    acct chroot fsync sync reboot \
+	    gethostid sethostid \
+	    mknod \
+	    swapon vhangup mktemp mkstemp \
+	    ualarm usleep \
+	    gtty stty \
+	    ptrace \
+	    nlist fstab \
+	    utimes \
+	    truncate ftruncate \
+	    chflags fchflags \
+	    insremque getttyent getusershell getpass ttyslot \
+	    syslog syscall daemon \
+	    mmap munmap mprotect msync madvise
+aux := progname init-misc
+distribute := bsd-compat.c
+extra-objs := bsd-compat.o
+install-lib := libbsd-compat.a libg.a
+non-lib.a := libbsd-compat.a
+
+include ../Rules
+
+$(objpfx)libbsd-compat.a: $(objpfx)bsd-compat.o
+	rm -f $@
+	ln $< $@
+
+lib: $(objpfx)libbsd-compat.a
+
+$(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
+lib: $(objpfx)libg.a
diff --git a/misc/bsd-compat.c b/misc/bsd-compat.c
new file mode 100644
index 0000000000..03c43eec57
--- /dev/null
+++ b/misc/bsd-compat.c
@@ -0,0 +1,50 @@
+/* BSD-compatible versions of functions where BSD and POSIX.1 conflict.
+
+Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#define	_BSD_SOURCE
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <gnu-stabs.h>
+#include <limits.h>
+#include <setjmp.h>
+
+#undef	getpgrp
+function_alias(getpgrp, __getpgrp, pid_t, (pid),
+	       DEFUN(getpgrp, (pid), pid_t pid))
+
+/* These entry points allow for things compiled for another C library
+   that want the BSD-compatible definitions.  (Of course, their jmp_buf
+   must be big enough.)  */
+
+#undef	longjmp
+#ifdef __STDC__
+#define void __NORETURN void
+#endif
+function_alias_void(longjmp, siglongjmp, (env, val),
+		    DEFUN(longjmp, (env, val), CONST jmp_buf env AND int val))
+
+#undef	setjmp
+int
+DEFUN(setjmp, (env), jmp_buf env)
+{
+  return sigsetjmp (env, 1);
+}
diff --git a/misc/daemon.c b/misc/daemon.c
new file mode 100644
index 0000000000..6b3409cced
--- /dev/null
+++ b/misc/daemon.c
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)daemon.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <fcntl.h>
+#include <paths.h>
+#include <unistd.h>
+
+int
+daemon(nochdir, noclose)
+	int nochdir, noclose;
+{
+	int fd;
+
+	switch (fork()) {
+	case -1:
+		return (-1);
+	case 0:
+		break;
+	default:
+		_exit(0);
+	}
+
+	if (setsid() == -1)
+		return (-1);
+
+	if (!nochdir)
+		(void)chdir("/");
+
+	if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+		(void)dup2(fd, STDIN_FILENO);
+		(void)dup2(fd, STDOUT_FILENO);
+		(void)dup2(fd, STDERR_FILENO);
+		if (fd > 2)
+			(void)close (fd);
+	}
+	return (0);
+}
diff --git a/misc/fstab.c b/misc/fstab.c
new file mode 100644
index 0000000000..ac59cab861
--- /dev/null
+++ b/misc/fstab.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 1980, 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fstab.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <errno.h>
+#include <fstab.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef EFTYPE
+#define EFTYPE EINVAL
+#endif
+
+static FILE *_fs_fp;
+static struct fstab _fs_fstab;
+
+static void error __P((int));
+
+static int
+fstabscan __P((void))
+{
+	register char *cp;
+#define	MAXLINELENGTH	1024
+	static char line[MAXLINELENGTH];
+	char subline[MAXLINELENGTH];
+	int typexx;
+
+	for (;;) {
+		if (!(cp = fgets(line, sizeof(line), _fs_fp)))
+			return(0);
+/* OLD_STYLE_FSTAB */
+		if (!strpbrk(cp, " \t")) {
+			_fs_fstab.fs_spec = strtok(cp, ":\n");
+			_fs_fstab.fs_file = strtok((char *)NULL, ":\n");
+			_fs_fstab.fs_type = strtok((char *)NULL, ":\n");
+			if (_fs_fstab.fs_type) {
+				if (!strcmp(_fs_fstab.fs_type, FSTAB_XX))
+					continue;
+				_fs_fstab.fs_mntops = _fs_fstab.fs_type;
+				_fs_fstab.fs_vfstype =
+				    strcmp(_fs_fstab.fs_type, FSTAB_SW) ?
+				    "ufs" : "swap";
+				if (cp = strtok((char *)NULL, ":\n")) {
+					_fs_fstab.fs_freq = atoi(cp);
+					if (cp = strtok((char *)NULL, ":\n")) {
+						_fs_fstab.fs_passno = atoi(cp);
+						return(1);
+					}
+				}
+			}
+			goto bad;
+		}
+/* OLD_STYLE_FSTAB */
+		_fs_fstab.fs_spec = strtok(cp, " \t\n");
+		if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#')
+			continue;
+		_fs_fstab.fs_file = strtok((char *)NULL, " \t\n");
+		_fs_fstab.fs_vfstype = strtok((char *)NULL, " \t\n");
+		_fs_fstab.fs_mntops = strtok((char *)NULL, " \t\n");
+		if (_fs_fstab.fs_mntops == NULL)
+			goto bad;
+		_fs_fstab.fs_freq = 0;
+		_fs_fstab.fs_passno = 0;
+		if ((cp = strtok((char *)NULL, " \t\n")) != NULL) {
+			_fs_fstab.fs_freq = atoi(cp);
+			if ((cp = strtok((char *)NULL, " \t\n")) != NULL)
+				_fs_fstab.fs_passno = atoi(cp);
+		}
+		strcpy(subline, _fs_fstab.fs_mntops);
+		for (typexx = 0, cp = strtok(subline, ","); cp;
+		     cp = strtok((char *)NULL, ",")) {
+			if (strlen(cp) != 2)
+				continue;
+			if (!strcmp(cp, FSTAB_RW)) {
+				_fs_fstab.fs_type = FSTAB_RW;
+				break;
+			}
+			if (!strcmp(cp, FSTAB_RQ)) {
+				_fs_fstab.fs_type = FSTAB_RQ;
+				break;
+			}
+			if (!strcmp(cp, FSTAB_RO)) {
+				_fs_fstab.fs_type = FSTAB_RO;
+				break;
+			}
+			if (!strcmp(cp, FSTAB_SW)) {
+				_fs_fstab.fs_type = FSTAB_SW;
+				break;
+			}
+			if (!strcmp(cp, FSTAB_XX)) {
+				_fs_fstab.fs_type = FSTAB_XX;
+				typexx++;
+				break;
+			}
+		}
+		if (typexx)
+			continue;
+		if (cp != NULL)
+			return(1);
+
+bad:		/* no way to distinguish between EOF and syntax error */
+		error(EFTYPE);
+	}
+	/* NOTREACHED */
+}
+
+struct fstab *
+getfsent()
+{
+	if (!_fs_fp && !setfsent() || !fstabscan())
+		return((struct fstab *)NULL);
+	return(&_fs_fstab);
+}
+
+struct fstab *
+getfsspec(name)
+	register const char *name;
+{
+	if (setfsent())
+		while (fstabscan())
+			if (!strcmp(_fs_fstab.fs_spec, name))
+				return(&_fs_fstab);
+	return((struct fstab *)NULL);
+}
+
+struct fstab *
+getfsfile(name)
+	register const char *name;
+{
+	if (setfsent())
+		while (fstabscan())
+			if (!strcmp(_fs_fstab.fs_file, name))
+				return(&_fs_fstab);
+	return((struct fstab *)NULL);
+}
+
+setfsent()
+{
+	if (_fs_fp) {
+		rewind(_fs_fp);
+		return(1);
+	}
+	if (_fs_fp = fopen(_PATH_FSTAB, "r"))
+		return(1);
+	error(errno);
+	return(0);
+}
+
+void
+endfsent()
+{
+	if (_fs_fp) {
+		(void)fclose(_fs_fp);
+		_fs_fp = NULL;
+	}
+}
+
+static void
+error(err)
+	int err;
+{
+	char *p;
+
+	(void)write(STDERR_FILENO, "fstab: ", 7);
+	(void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
+	(void)write(STDERR_FILENO, ": ", 1);
+	p = strerror(err);
+	(void)write(STDERR_FILENO, p, strlen(p));
+	(void)write(STDERR_FILENO, "\n", 1);
+}
diff --git a/misc/fstab.h b/misc/fstab.h
new file mode 100644
index 0000000000..2a176bdb83
--- /dev/null
+++ b/misc/fstab.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 1980, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)fstab.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _FSTAB_H_
+#define _FSTAB_H_
+
+/*
+ * File system table, see fstab(5).
+ *
+ * Used by dump, mount, umount, swapon, fsck, df, ...
+ *
+ * For ufs fs_spec field is the block special name.  Programs that want to
+ * use the character special name must create that name by prepending a 'r'
+ * after the right most slash.  Quota files are always named "quotas", so
+ * if type is "rq", then use concatenation of fs_file and "quotas" to locate
+ * quota file.
+ */
+#define	_PATH_FSTAB	"/etc/fstab"
+#define	FSTAB		"/etc/fstab"	/* deprecated */
+
+#define	FSTAB_RW	"rw"		/* read/write device */
+#define	FSTAB_RQ	"rq"		/* read/write with quotas */
+#define	FSTAB_RO	"ro"		/* read-only device */
+#define	FSTAB_SW	"sw"		/* swap device */
+#define	FSTAB_XX	"xx"		/* ignore totally */
+
+struct fstab {
+	char	*fs_spec;		/* block special device name */
+	char	*fs_file;		/* file system path prefix */
+	char	*fs_vfstype;		/* File system type, ufs, nfs */
+	char	*fs_mntops;		/* Mount options ala -o */
+	char	*fs_type;		/* FSTAB_* from fs_mntops */
+	int	fs_freq;		/* dump frequency, in days */
+	int	fs_passno;		/* pass number on parallel dump */
+};
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+struct fstab *getfsent __P((void));
+struct fstab *getfsspec __P((const char *));
+struct fstab *getfsfile __P((const char *));
+int setfsent __P((void));
+void endfsent __P((void));
+__END_DECLS
+
+#endif /* !_FSTAB_H_ */
diff --git a/misc/getpass.c b/misc/getpass.c
new file mode 100644
index 0000000000..ec535c1cca
--- /dev/null
+++ b/misc/getpass.c
@@ -0,0 +1,92 @@
+/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+/* It is desireable to use this bit on systems that have it.
+   The only bit of terminal state we want to twiddle is echoing, which is
+   done in software; there is no need to change the state of the terminal
+   hardware.  */
+
+#ifndef TCSASOFT
+#define TCSASOFT 0
+#endif
+
+char *
+getpass (prompt)
+     const char *prompt;
+{
+  FILE *in, *out;
+  struct termios t;
+  int echo_off;
+  static char *buf = NULL;
+  static size_t bufsize = 0;
+  ssize_t nread;
+
+  /* Try to write to and read from the terminal if we can.
+     If we can't open the terminal, use stderr and stdin.  */
+
+  in = fopen ("/dev/tty", "w+");
+  if (in == NULL)
+    {
+      in = stdin;
+      out = stderr;
+    }
+  else
+    out = in;
+
+  /* Turn echoing off if it is on now.  */
+
+  if (tcgetattr (fileno (in), &t) == 0)
+    {
+      if (t.c_lflag & ECHO)
+	{
+	  t.c_lflag &= ~ECHO;
+	  echo_off = tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0;
+	  t.c_lflag |= ECHO;
+	}
+      else
+	echo_off = 0;
+    }
+  else
+    echo_off = 0;
+
+  /* Write the prompt.  */
+  fputs (prompt, out);
+  fflush (out);
+
+  /* Read the password.  */
+  nread = __getline (&buf, &bufsize, in);
+  if (nread < 0 && buf != NULL)
+    buf[0] = '\0';
+  else if (buf[nread - 1] == '\n')
+    /* Remove the newline.  */
+    buf[nread - 1] = '\0';
+
+  /* Restore echoing.  */
+  if (echo_off)
+    (void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t);
+
+  if (in != stdin)
+    /* We opened the terminal; now close it.  */
+    fclose (in);
+
+  return buf;
+}
diff --git a/misc/getttyent.c b/misc/getttyent.c
new file mode 100644
index 0000000000..f9b1e0d854
--- /dev/null
+++ b/misc/getttyent.c
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getttyent.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ttyent.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+static char zapchar;
+static FILE *tf;
+
+struct ttyent *
+getttynam(tty)
+	const char *tty;
+{
+	register struct ttyent *t;
+
+	setttyent();
+	while (t = getttyent())
+		if (!strcmp(tty, t->ty_name))
+			break;
+	endttyent();
+	return (t);
+}
+
+struct ttyent *
+getttyent()
+{
+	static struct ttyent tty;
+	register int c;
+	register char *p;
+#define	MAXLINELENGTH	100
+	static char line[MAXLINELENGTH];
+	static char *skip(), *value();
+
+	if (!tf && !setttyent())
+		return (NULL);
+	for (;;) {
+		if (!fgets(p = line, sizeof(line), tf))
+			return (NULL);
+		/* skip lines that are too big */
+		if (!index(p, '\n')) {
+			while ((c = getc(tf)) != '\n' && c != EOF)
+				;
+			continue;
+		}
+		while (isspace(*p))
+			++p;
+		if (*p && *p != '#')
+			break;
+	}
+
+	zapchar = 0;
+	tty.ty_name = p;
+	p = skip(p);
+	if (!*(tty.ty_getty = p))
+		tty.ty_getty = tty.ty_type = NULL;
+	else {
+		p = skip(p);
+		if (!*(tty.ty_type = p))
+			tty.ty_type = NULL;
+		else
+			p = skip(p);
+	}
+	tty.ty_status = 0;
+	tty.ty_window = NULL;
+
+#define	scmp(e)	!strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1])
+#define	vcmp(e)	!strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '='
+	for (; *p; p = skip(p)) {
+		if (scmp(_TTYS_OFF))
+			tty.ty_status &= ~TTY_ON;
+		else if (scmp(_TTYS_ON))
+			tty.ty_status |= TTY_ON;
+		else if (scmp(_TTYS_SECURE))
+			tty.ty_status |= TTY_SECURE;
+		else if (vcmp(_TTYS_WINDOW))
+			tty.ty_window = value(p);
+		else
+			break;
+	}
+
+	if (zapchar == '#' || *p == '#')
+		while ((c = *++p) == ' ' || c == '\t')
+			;
+	tty.ty_comment = p;
+	if (*p == 0)
+		tty.ty_comment = 0;
+	if (p = index(p, '\n'))
+		*p = '\0';
+	return (&tty);
+}
+
+#define	QUOTED	1
+
+/*
+ * Skip over the current field, removing quotes, and return a pointer to
+ * the next field.
+ */
+static char *
+skip(p)
+	register char *p;
+{
+	register char *t;
+	register int c, q;
+
+	for (q = 0, t = p; (c = *p) != '\0'; p++) {
+		if (c == '"') {
+			q ^= QUOTED;	/* obscure, but nice */
+			continue;
+		}
+		if (q == QUOTED && *p == '\\' && *(p+1) == '"')
+			p++;
+		*t++ = *p;
+		if (q == QUOTED)
+			continue;
+		if (c == '#') {
+			zapchar = c;
+			*p = 0;
+			break;
+		}
+		if (c == '\t' || c == ' ' || c == '\n') {
+			zapchar = c;
+			*p++ = 0;
+			while ((c = *p) == '\t' || c == ' ' || c == '\n')
+				p++;
+			break;
+		}
+	}
+	*--t = '\0';
+	return (p);
+}
+
+static char *
+value(p)
+	register char *p;
+{
+
+	return ((p = index(p, '=')) ? ++p : NULL);
+}
+
+int
+setttyent()
+{
+
+	if (tf) {
+		(void)rewind(tf);
+		return (1);
+	} else if (tf = fopen(_PATH_TTYS, "r"))
+		return (1);
+	return (0);
+}
+
+int
+endttyent()
+{
+	int rval;
+
+	if (tf) {
+		rval = !(fclose(tf) == EOF);
+		tf = NULL;
+		return (rval);
+	}
+	return (1);
+}
diff --git a/misc/getusershell.c b/misc/getusershell.c
new file mode 100644
index 0000000000..6782c3efe9
--- /dev/null
+++ b/misc/getusershell.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 1985, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getusershell.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <paths.h>
+
+/*
+ * Local shells should NOT be added here.  They should be added in
+ * /etc/shells.
+ */
+
+static char *okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL };
+static char **curshell, **shells, *strings;
+static char **initshells __P((void));
+
+/*
+ * Get a list of shells from _PATH_SHELLS, if it exists.
+ */
+char *
+getusershell()
+{
+	char *ret;
+
+	if (curshell == NULL)
+		curshell = initshells();
+	ret = *curshell;
+	if (ret != NULL)
+		curshell++;
+	return (ret);
+}
+
+void
+endusershell()
+{
+	
+	if (shells != NULL)
+		free(shells);
+	shells = NULL;
+	if (strings != NULL)
+		free(strings);
+	strings = NULL;
+	curshell = NULL;
+}
+
+void
+setusershell()
+{
+
+	curshell = initshells();
+}
+
+static char **
+initshells()
+{
+	register char **sp, *cp;
+	register FILE *fp;
+	struct stat statb;
+
+	if (shells != NULL)
+		free(shells);
+	shells = NULL;
+	if (strings != NULL)
+		free(strings);
+	strings = NULL;
+	if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
+		return (okshells);
+	if (fstat(fileno(fp), &statb) == -1) {
+		(void)fclose(fp);
+		return (okshells);
+	}
+	if ((strings = malloc((u_int)statb.st_size + 1)) == NULL) {
+		(void)fclose(fp);
+		return (okshells);
+	}
+	shells = calloc((unsigned)statb.st_size / 3, sizeof (char *));
+	if (shells == NULL) {
+		(void)fclose(fp);
+		free(strings);
+		strings = NULL;
+		return (okshells);
+	}
+	sp = shells;
+	cp = strings;
+	while (fgets(cp, statb.st_size - (cp - strings), fp) != NULL) {
+		while (*cp != '#' && *cp != '/' && *cp != '\0')
+			cp++;
+		if (*cp == '#' || *cp == '\0')
+			continue;
+		*sp++ = cp;
+		while (!isspace(*cp) && *cp != '#' && *cp != '\0')
+			cp++;
+		*cp++ = '\0';
+	}
+	*sp = NULL;
+	(void)fclose(fp);
+	return (shells);
+}
diff --git a/misc/init-misc.c b/misc/init-misc.c
new file mode 100644
index 0000000000..9fb876beb0
--- /dev/null
+++ b/misc/init-misc.c
@@ -0,0 +1,42 @@
+/* Define and initialize `__progname'.
+Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <string.h>
+
+char *__progname = (char *) "";
+
+void
+__init_misc (argc, argv, envp)
+     int argc;
+     char **argv;
+     char **envp;
+{
+  if (argv && argv[0])
+    {
+      char *p = strrchr (argv[0], '/');
+      if (p == NULL)
+	__progname = argv[0];
+      else
+	__progname = p + 1;
+    }
+}
+
+#ifdef HAVE_GNU_LD
+text_set_element (__libc_subinit, __init_misc);
+#endif
diff --git a/misc/insremque.c b/misc/insremque.c
new file mode 100644
index 0000000000..d3b9370fdc
--- /dev/null
+++ b/misc/insremque.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <ansidecl.h>
+#include <stddef.h>
+
+struct qelem
+  {
+    struct qelem *q_forw;
+    struct qelem *q_back;
+    char q_data[1];
+  };
+
+/* Insert ELEM into a doubly-linked list, after PREV.  */
+
+void
+DEFUN(insque, (elem, prev) ,
+      struct qelem *elem AND struct qelem *prev)
+{
+  struct qelem *next = prev->q_forw;
+  prev->q_forw = elem;
+  if (next != NULL)
+    next->q_back = elem;
+  elem->q_forw = next;
+  elem->q_back = prev;
+}
+
+/* Unlink ELEM from the doubly-linked list that it is in.  */
+
+void
+DEFUN(remque, (elem),
+      struct qelem *elem)
+{
+  struct qelem *next = elem->q_forw;
+  struct qelem *prev = elem->q_back;
+  if (next != NULL)
+    next->q_back = prev;
+  if (prev != NULL)
+    prev->q_forw = next;
+}
diff --git a/misc/ioctltst.c b/misc/ioctltst.c
new file mode 100644
index 0000000000..3e8ea997eb
--- /dev/null
+++ b/misc/ioctltst.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <netinet/in.h>
+
+/*
+ * open a socket, get the process group information of the socket, and use the
+ * socket to get the network interface configuration list
+ */
+main()
+{
+  int sock;
+  int ioctl_result;
+
+  /* get a socket */
+  sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+  if (sock < 0)
+    {
+      perror("Cannot create socket");
+      exit(1);
+    }
+
+  /* use ioctl() to get the process group information */
+  {
+    int get_process_group;
+    
+    ioctl_result = ioctl(sock, SIOCGPGRP, (char *) &get_process_group);
+
+    if (ioctl_result < 0)
+      {
+        int my_errno = errno;
+
+        fprintf(stderr, "errno %d ", my_errno);
+        perror("ioctl(get process group)");
+      }
+  }
+
+  /* use ioctl() to get the interface configuration list */
+  {
+    static struct ifconf ifc;	/* init to 0 */
+    
+    ioctl_result = ioctl(sock, SIOCGIFCONF, (char *) &ifc);
+
+    if (ioctl_result < 0)
+      {
+        int my_errno = errno;
+
+        fprintf(stderr, "errno %d ", my_errno);
+        perror("ioctl(get interface configuration list)");
+      }
+  }
+}
diff --git a/misc/nlist.h b/misc/nlist.h
new file mode 100644
index 0000000000..67879b52cc
--- /dev/null
+++ b/misc/nlist.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef	_NLIST_H
+
+#define	_NLIST_H	1
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Structure describing a symbol-table entry.  */
+struct nlist
+{
+  char *n_name;
+  unsigned char n_type;
+  char n_other;
+  short int n_desc;
+  unsigned long int n_value;
+};
+
+#define	N_NLIST_DECLARED
+#include <a.out.h>
+
+
+/* Search the executable FILE for symbols matching those in NL,
+   which is terminated by an element with a NULL `n_un.n_name' member,
+   and fill in the elements of NL.  */
+extern int nlist __P ((__const char *__file, struct nlist * __nl));
+
+
+__END_DECLS
+
+#endif /* nlist.h  */
diff --git a/misc/paths.h b/misc/paths.h
new file mode 100644
index 0000000000..5f7a6b4cd5
--- /dev/null
+++ b/misc/paths.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)paths.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _PATHS_H_
+#define	_PATHS_H_
+
+/* Default search path. */
+#define	_PATH_DEFPATH	"/usr/bin:/bin"
+/* All standard utilities path. */
+#define	_PATH_STDPATH \
+	"/usr/bin:/bin:/usr/sbin:/sbin:/usr/contrib/bin:/usr/old/bin"
+
+#define	_PATH_BSHELL	"/bin/sh"
+#define	_PATH_CONSOLE	"/dev/console"
+#define	_PATH_CSHELL	"/bin/csh"
+#define	_PATH_DEVDB	"/var/run/dev.db"
+#define	_PATH_DEVNULL	"/dev/null"
+#define	_PATH_DRUM	"/dev/drum"
+#define	_PATH_KMEM	"/dev/kmem"
+#define	_PATH_MAILDIR	"/var/mail"
+#define	_PATH_MAN	"/usr/share/man"
+#define	_PATH_MEM	"/dev/mem"
+#define	_PATH_NOLOGIN	"/etc/nologin"
+#define	_PATH_SENDMAIL	"/usr/sbin/sendmail"
+#define	_PATH_SHELLS	"/etc/shells"
+#define	_PATH_TTY	"/dev/tty"
+#define	_PATH_UNIX	"/vmunix"
+#define	_PATH_VI	"/usr/bin/vi"
+
+/* Provide trailing slash, since mostly used for building pathnames. */
+#define	_PATH_DEV	"/dev/"
+#define	_PATH_TMP	"/tmp/"
+#define	_PATH_VARDB	"/var/db/"
+#define	_PATH_VARRUN	"/var/run/"
+#define	_PATH_VARTMP	"/var/tmp/"
+
+#endif /* !_PATHS_H_ */
diff --git a/misc/progname.c b/misc/progname.c
new file mode 100644
index 0000000000..265ca5c3a9
--- /dev/null
+++ b/misc/progname.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifdef	HAVE_GNU_LD
+
+#include <ansidecl.h>
+#include <string.h>
+
+char *program_invocation_name;
+char *program_invocation_short_name;
+
+static void
+DEFUN(set_progname, (argc, argv, envp),
+      int argc AND char **argv AND char **envp)
+{
+  char *p;
+
+  if (argv && argv[0])
+    {
+      program_invocation_name = argv[0];
+      p = strrchr (argv[0], '/');
+      if (p == NULL)
+	program_invocation_short_name = argv[0];
+      else
+	program_invocation_short_name = p + 1;
+    }
+  else
+    program_invocation_name = program_invocation_short_name = 0;
+
+  (void) &set_progname;		/* Avoid "defined but not used" warning.  */
+}
+
+text_set_element (__libc_subinit, set_progname);
+
+#endif
diff --git a/misc/sgtty.h b/misc/sgtty.h
new file mode 100644
index 0000000000..f8ed36d0d6
--- /dev/null
+++ b/misc/sgtty.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef	_SGTTY_H
+#define	_SGTYY_H	1
+#include <features.h>
+
+#include <sys/ioctl.h>
+
+__BEGIN_DECLS
+
+/* Fill in *PARAMS with terminal parameters associated with FD.  */
+extern int gtty __P ((int __fd, struct sgttyb * __params));
+
+/* Set the terminal parameters associated with FD to *PARAMS.  */
+extern int stty __P ((int __fd, __const struct sgttyb * __params));
+
+
+__END_DECLS
+
+#endif /* sgtty.h  */
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
new file mode 100644
index 0000000000..8336aa4038
--- /dev/null
+++ b/misc/sys/cdefs.h
@@ -0,0 +1,104 @@
+/* Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef	_SYS_CDEFS_H
+
+#define	_SYS_CDEFS_H	1
+#include <features.h>
+
+/* Some user header file might have defined this before.  */
+#undef	__P
+
+#ifdef __GNUC__
+
+#define	__P(args)	args	/* GCC can always grok prototypes.  */
+#define	__DOTS		, ...
+
+#else	/* Not GCC.  */
+
+#define	__inline		/* No inline functions.  */
+
+#if (defined (__STDC__) && __STDC__) || defined (__cplusplus)
+
+#define	__P(args)	args
+#define	__const		const
+#define	__signed	signed
+#define	__volatile	volatile
+#define	__DOTS		, ...
+
+#else	/* Not ANSI C or C++.  */
+
+#define	__P(args)	()	/* No prototypes.  */
+#define	__const			/* No ANSI C keywords.  */
+#define	__signed
+#define	__volatile
+#define	__DOTS
+
+#endif	/* ANSI C or C++.  */
+
+#endif	/* GCC.  */
+
+/* For these things, GCC behaves the ANSI way normally,
+   and the non-ANSI way under -traditional.  */
+
+#if defined (__STDC__) && __STDC__
+
+#define	__CONCAT(x,y)	x ## y
+#define	__STRING(x)	#x
+
+/* This is not a typedef so `const __ptr_t' does the right thing.  */
+#define __ptr_t void *
+typedef long double __long_double_t;
+
+#else
+
+#define	__CONCAT(x,y)	x/**/y
+#define	__STRING(x)	"x"
+
+#define __ptr_t char *
+typedef double __long_double_t;
+
+#endif
+
+/* The BSD header files use the ANSI keywords unmodified.  (This means that
+   old programs may lose if they use the new keywords as identifiers.)  We
+   define them to their __ versions, which are taken care of above.  */
+
+#ifdef	__USE_BSD
+#define	const		__const
+#define	signed		__signed
+#define	volatile	__volatile
+#endif
+
+/* C++ needs to know that types and declarations are C, not C++.  */
+#ifdef	__cplusplus
+#define	__BEGIN_DECLS	extern "C" {
+#define	__END_DECLS	}
+#else
+#define	__BEGIN_DECLS
+#define	__END_DECLS
+#endif
+
+/* GCC2 has various useful declarations that can be made with the
+   `__attribute__' syntax.  All of the ways we use this do fine if
+   they are omitted for compilers that don't understand it.  */
+#if !defined (__GNUC__) || __GNUC__ < 2
+#define __attribute__(xyz)	/* Ignore.  */
+#endif
+
+#endif	 /* sys/cdefs.h */
diff --git a/misc/sys/dir.h b/misc/sys/dir.h
new file mode 100644
index 0000000000..cd78d5d313
--- /dev/null
+++ b/misc/sys/dir.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef	_SYS_DIR_H
+
+#define	_SYS_DIR_H	1
+#include <features.h>
+
+#include <dirent.h>
+
+#define	direct	dirent
+
+#endif	/* sys/dir.h  */
diff --git a/misc/sys/file.h b/misc/sys/file.h
new file mode 100644
index 0000000000..51d07bc160
--- /dev/null
+++ b/misc/sys/file.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef	_SYS_FILE_H
+
+#define	_SYS_FILE_H	1
+#include <features.h>
+
+#ifndef	_FCNTL_H
+#include <fcntl.h>
+#endif
+
+__BEGIN_DECLS
+
+
+/* Alternate names for values for the WHENCE argument to `lseek'.
+   These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively.  */
+#define	L_SET	0	/* Seek from beginning of file.  */
+#define	L_INCR	1	/* Seek from current position.  */
+#define	L_XTND	2	/* Seek from end of file.  */
+
+
+/* Operations for the `flock' call.  */
+#define	LOCK_SH	1    /* Shared lock.  */
+#define	LOCK_EX	2    /* Exclusive lock.  */
+#define	LOCK_UN	8    /* Unlock.  */
+
+/* Can be OR'd in to one of the above.  */
+#define	LOCK_NB	4    /* Don't block when locking.  */
+
+
+/* Apply or remove an advisory lock, according to OPERATION,
+   on the file FD refers to.  */
+extern int __flock __P ((int __fd, int __operation));
+extern int flock __P ((int __fd, int __operation));
+
+
+__END_DECLS
+
+#endif /* sys/file.h  */
diff --git a/misc/sys/ioctl.h b/misc/sys/ioctl.h
new file mode 100644
index 0000000000..b37a2740cd
--- /dev/null
+++ b/misc/sys/ioctl.h
@@ -0,0 +1,130 @@
+/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef	_SYS_IOCTL_H
+
+#define	_SYS_IOCTL_H	1
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Get the list of `ioctl' requests and related constants.  */
+#include <ioctls.h>
+
+/* On a Unix system, the system <sys/ioctl.h> probably defines some of the
+   symbols we define in <sys/ttydefaults.h> (usually with the same values).
+   The code to generate <ioctls.h> has omitted these symbols to avoid the
+   conflict, but a Unix program expects <sys/ioctl.h> to define them, so we
+   must include <sys/ttydefaults.h> here.  */
+#include <sys/ttydefaults.h>
+
+#if	defined(TIOCGETC) || defined(TIOCSETC)
+/* Type of ARG for TIOCGETC and TIOCSETC requests.  */
+struct tchars
+{
+  char t_intrc;			/* Interrupt character.  */
+  char t_quitc;			/* Quit character.  */
+  char t_startc;		/* Start-output character.  */
+  char t_stopc;			/* Stop-output character.  */
+  char t_eofc;			/* End-of-file character.  */
+  char t_brkc;			/* Input delimiter character.  */
+};
+
+#define	_IOT_tchars	/* Hurd ioctl type field.  */ \
+  _IOT (_IOTS (char), 6, 0, 0, 0, 0)
+#endif
+
+#if	defined(TIOCGLTC) || defined(TIOCSLTC)
+/* Type of ARG for TIOCGLTC and TIOCSLTC requests.  */
+struct ltchars
+{
+  char t_suspc;			/* Suspend character.  */
+  char t_dsuspc;		/* Delayed suspend character.  */
+  char t_rprntc;		/* Reprint-line character.  */
+  char t_flushc;		/* Flush-output character.  */
+  char t_werasc;		/* Word-erase character.  */
+  char t_lnextc;		/* Literal-next character.  */
+};
+
+#define	_IOT_ltchars	/* Hurd ioctl type field.  */ \
+  _IOT (_IOTS (char), 6, 0, 0, 0, 0)
+#endif
+
+/* Type of ARG for TIOCGETP and TIOCSETP requests (and gtty and stty).  */
+struct sgttyb
+{
+  char sg_ispeed;		/* Input speed.  */
+  char sg_ospeed;		/* Output speed.  */
+  char sg_erase;		/* Erase character.  */
+  char sg_kill;			/* Kill character.  */
+  short int sg_flags;		/* Mode flags.  */
+};
+
+#define	_IOT_sgttyb	/* Hurd ioctl type field.  */ \
+  _IOT (_IOTS (char), 6, _IOTS (short int), 1, 0, 0)
+
+#if	defined(TIOCGWINSZ) || defined(TIOCSWINSZ)
+/* Type of ARG for TIOCGWINSZ and TIOCSWINSZ requests.  */
+struct winsize
+{
+  unsigned short int ws_row;	/* Rows, in characters.  */
+  unsigned short int ws_col;	/* Columns, in characters.  */
+
+  /* These are not actually used.  */
+  unsigned short int ws_xpixel;	/* Horizontal pixels.  */
+  unsigned short int ws_ypixel;	/* Vertical pixels.  */
+};
+
+#define	_IOT_winsize	/* Hurd ioctl type field.  */ \
+  _IOT (_IOTS (unsigned short int), 4, 0, 0, 0, 0)
+#endif
+
+#if	defined (TIOCGSIZE) || defined (TIOCSSIZE)
+#  if defined (TIOCGWINSZ) && TIOCGSIZE == TIOCGWINSZ
+/* Many systems that have TIOCGWINSZ define TIOCGSIZE for source
+   compatibility with Sun; they define `struct ttysize' to have identical
+   layout as `struct winsize' and #define TIOCGSIZE to be TIOCGWINSZ
+   (likewise TIOCSSIZE and TIOCSWINSZ).  */
+struct ttysize
+{
+  unsigned short int ts_lines;
+  unsigned short int ts_cols;
+  unsigned short int ts_xxx;
+  unsigned short int ts_yyy;
+};
+#define	_IOT_ttysize	_IOT_winsize
+#  else
+/* Suns use a different layout for `struct ttysize', and TIOCGSIZE and
+   TIOCGWINSZ are separate commands that do the same thing with different
+   structures (likewise TIOCSSIZE and TIOCSWINSZ).  */
+struct ttysize
+{
+  int ts_lines, ts_cols;	/* Lines and columns, in characters.  */
+};
+#  endif
+#endif
+
+/* Perform the I/O control operation specified by REQUEST on FD.
+   One argument may follow; its presence and type depend on REQUEST.
+   Return value depends on REQUEST.  Usually -1 indicates error.  */
+extern int __ioctl __P ((int __fd, unsigned long int __request, ...));
+extern int ioctl __P ((int __fd, unsigned long int __request, ...));
+
+__END_DECLS
+
+#endif /* sys/ioctl.h */
diff --git a/misc/sys/ptrace.h b/misc/sys/ptrace.h
new file mode 100644
index 0000000000..22e44e3ae0
--- /dev/null
+++ b/misc/sys/ptrace.h
@@ -0,0 +1,137 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef	_PTRACE_H
+
+#define	_PTRACE_H	1
+#include <features.h>
+
+__BEGIN_DECLS
+
+
+/* Type of the REQUEST argument to `ptrace.'  */
+enum __ptrace_request
+{
+  /* Indicate that the process making this request should be traced.
+     All signals received by this process can be intercepted by its
+     parent, and its parent can use the other `ptrace' requests.  */
+  PTRACE_TRACEME = 0,
+#define PT_TRACE_ME PTRACE_TRACEME
+
+  /* Return the word in the process's text space at address ADDR.  */
+  PTRACE_PEEKTEXT,
+#define PT_READ_I PTRACE_PEEKTEXT
+
+  /* Return the word in the process's data space at address ADDR.  */
+  PTRACE_PEEKDATA,
+#define PT_READ_D PTRACE_PEEKDATA
+
+  /* Return the word in the process's user area at offset ADDR.  */
+  PTRACE_PEEKUSER,
+#define PT_READ_U PTRACE_PEEKUSER
+
+  /* Write the word DATA into the process's text space at address ADDR.  */
+  PTRACE_POKETEXT,
+#define PT_WRITE_I PTRACE_POKETEXT
+
+  /* Write the word DATA into the process's data space at address ADDR.  */
+  PTRACE_POKEDATA,
+#define PT_WRITE_D PTRACE_POKEDATA
+
+  /* Write the word DATA into the process's user space at offset ADDR.  */
+  PTRACE_POKEUSER,
+#define PT_WRITE_U PTRACE_POKEUSER
+
+  /* Continue the process.  */
+  PTRACE_CONT,
+#define PT_CONTINUE PTRACE_CONT
+
+  /* Kill the process.  */
+  PTRACE_KILL,
+#define PT_KILL PTRACE_KILL
+
+  /* Single step the process.
+     This is not supported on all machines.  */
+  PTRACE_SINGLESTEP,
+#define PT_STEP PTRACE_SINGLESTEP
+
+  /* Attach to a process that is already running. */
+  PTRACE_ATTACH,
+#define PT_ATTACH PTRACE_ATTACH
+
+  /* Detach from a process attached to with PTRACE_ATTACH.  */
+  PTRACE_DETACH,
+#define PT_DETACH PTRACE_DETACH
+
+  /* Get the process's registers (not including floating-point registers)
+     and put them in the `struct regs' (see <machine/regs.h>) at ADDR.  */
+  PTRACE_GETREGS = 12,
+
+  /* Set the process's registers (not including floating-point registers)
+     to the contents of the `struct regs' (see <machine/regs.h>) at ADDR.  */
+  PTRACE_SETREGS,
+
+  /* Get the process's floating point registers and put them
+     in the `struct fp_status' (see <machine/regs.h>) at ADDR.  */
+  PTRACE_GETFPREGS = 14,
+
+  /* Set the process's floating point registers to the contents
+     of the `struct fp_status' (see <machine/regs.h>) at ADDR.  */
+  PTRACE_SETFPREGS,
+
+  /* Read DATA bytes from the process's data space at address ADDR.
+     Put the result starting at address ADDR2 in the caller's
+     address space.  */
+  PTRACE_READDATA = 16,
+
+  /* Write DATA bytes from ADDR2 in the caller's address space into
+     the process's data space at address ADDR.  */
+  PTRACE_WRITEDATA,
+
+  /* Read DATA bytes from the process's text space at address ADDR.
+     Put the result starting at address ADDR2 in the caller's
+     address space.  */
+  PTRACE_READTEXT = 18,
+
+  /* Write DATA bytes from ADDR2 in the caller's address space into
+     the process's text space at address ADDR.  */
+  PTRACE_WRITETEXT,
+
+  /* Read the floating-point accelerator unit registers and
+     put them into the `struct fpa_regs' (see <machine/regs.h>) at ADDR.  */
+  PTRACE_GETFPAREGS = 20,
+
+  /* Write the floating-point accelerator unit registers from
+     the contents of the `struct fpa_regs' at ADDR.  */
+  PTRACE_SETFPAREGS,
+};
+
+/* Perform process tracing functions.  REQUEST is one of the values
+   above, and determines the action to be taken.
+   For all requests except PTRACE_TRACEME, PID specifies the process to be
+   traced.
+
+   PID and the other arguments described above for the various requests should
+   appear (those that are used for the particular request) as:
+     pid_t PID, void *ADDR, int DATA, void *ADDR2
+   after REQUEST.  */
+extern int ptrace __P ((enum __ptrace_request __request __DOTS));
+
+__END_DECLS
+
+#endif /* ptrace.h */
diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
new file mode 100644
index 0000000000..87bfd2ec6f
--- /dev/null
+++ b/misc/sys/syslog.h
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)syslog.h	8.1 (Berkeley) 6/2/93
+ */
+
+#define	_PATH_LOG	"/dev/log"
+
+/*
+ * priorities/facilities are encoded into a single 32-bit quantity, where the
+ * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
+ * (0-big number).  Both the priorities and the facilities map roughly
+ * one-to-one to strings in the syslogd(8) source code.  This mapping is
+ * included in this file.
+ *
+ * priorities (these are ordered)
+ */
+#define	LOG_EMERG	0	/* system is unusable */
+#define	LOG_ALERT	1	/* action must be taken immediately */
+#define	LOG_CRIT	2	/* critical conditions */
+#define	LOG_ERR		3	/* error conditions */
+#define	LOG_WARNING	4	/* warning conditions */
+#define	LOG_NOTICE	5	/* normal but significant condition */
+#define	LOG_INFO	6	/* informational */
+#define	LOG_DEBUG	7	/* debug-level messages */
+
+#define	LOG_PRIMASK	0x07	/* mask to extract priority part (internal) */
+				/* extract priority */
+#define	LOG_PRI(p)	((p) & LOG_PRIMASK)
+#define	LOG_MAKEPRI(fac, pri)	(((fac) << 3) | (pri))
+
+#ifdef SYSLOG_NAMES
+#define	INTERNAL_NOPRI	0x10	/* the "no priority" priority */
+				/* mark "facility" */
+#define	INTERNAL_MARK	LOG_MAKEPRI(LOG_NFACILITIES, 0)
+typedef struct _code {
+	char	*c_name;
+	int	c_val;
+} CODE;
+
+CODE prioritynames[] = {
+	"alert",	LOG_ALERT,
+	"crit",		LOG_CRIT,
+	"debug",	LOG_DEBUG,
+	"emerg",	LOG_EMERG,
+	"err",		LOG_ERR,
+	"error",	LOG_ERR,		/* DEPRECATED */
+	"info",		LOG_INFO,
+	"none",		INTERNAL_NOPRI,		/* INTERNAL */
+	"notice",	LOG_NOTICE,
+	"panic", 	LOG_EMERG,		/* DEPRECATED */
+	"warn",		LOG_WARNING,		/* DEPRECATED */
+	"warning",	LOG_WARNING,
+	NULL,		-1,
+};
+#endif
+
+/* facility codes */
+#define	LOG_KERN	(0<<3)	/* kernel messages */
+#define	LOG_USER	(1<<3)	/* random user-level messages */
+#define	LOG_MAIL	(2<<3)	/* mail system */
+#define	LOG_DAEMON	(3<<3)	/* system daemons */
+#define	LOG_AUTH	(4<<3)	/* security/authorization messages */
+#define	LOG_SYSLOG	(5<<3)	/* messages generated internally by syslogd */
+#define	LOG_LPR		(6<<3)	/* line printer subsystem */
+#define	LOG_NEWS	(7<<3)	/* network news subsystem */
+#define	LOG_UUCP	(8<<3)	/* UUCP subsystem */
+#define	LOG_CRON	(9<<3)	/* clock daemon */
+#define	LOG_AUTHPRIV	(10<<3)	/* security/authorization messages (private) */
+#define	LOG_FTP		(11<<3)	/* ftp daemon */
+
+	/* other codes through 15 reserved for system use */
+#define	LOG_LOCAL0	(16<<3)	/* reserved for local use */
+#define	LOG_LOCAL1	(17<<3)	/* reserved for local use */
+#define	LOG_LOCAL2	(18<<3)	/* reserved for local use */
+#define	LOG_LOCAL3	(19<<3)	/* reserved for local use */
+#define	LOG_LOCAL4	(20<<3)	/* reserved for local use */
+#define	LOG_LOCAL5	(21<<3)	/* reserved for local use */
+#define	LOG_LOCAL6	(22<<3)	/* reserved for local use */
+#define	LOG_LOCAL7	(23<<3)	/* reserved for local use */
+
+#define	LOG_NFACILITIES	24	/* current number of facilities */
+#define	LOG_FACMASK	0x03f8	/* mask to extract facility part */
+				/* facility of pri */
+#define	LOG_FAC(p)	(((p) & LOG_FACMASK) >> 3)
+
+#ifdef SYSLOG_NAMES
+CODE facilitynames[] = {
+	"auth",		LOG_AUTH,
+	"authpriv",	LOG_AUTHPRIV,
+	"cron", 	LOG_CRON,
+	"daemon",	LOG_DAEMON,
+	"ftp",		LOG_FTP,
+	"kern",		LOG_KERN,
+	"lpr",		LOG_LPR,
+	"mail",		LOG_MAIL,
+	"mark", 	INTERNAL_MARK,		/* INTERNAL */
+	"news",		LOG_NEWS,
+	"security",	LOG_AUTH,		/* DEPRECATED */
+	"syslog",	LOG_SYSLOG,
+	"user",		LOG_USER,
+	"uucp",		LOG_UUCP,
+	"local0",	LOG_LOCAL0,
+	"local1",	LOG_LOCAL1,
+	"local2",	LOG_LOCAL2,
+	"local3",	LOG_LOCAL3,
+	"local4",	LOG_LOCAL4,
+	"local5",	LOG_LOCAL5,
+	"local6",	LOG_LOCAL6,
+	"local7",	LOG_LOCAL7,
+	NULL,		-1,
+};
+#endif
+
+#ifdef KERNEL
+#define	LOG_PRINTF	-1	/* pseudo-priority to indicate use of printf */
+#endif
+
+/*
+ * arguments to setlogmask.
+ */
+#define	LOG_MASK(pri)	(1 << (pri))		/* mask for one priority */
+#define	LOG_UPTO(pri)	((1 << ((pri)+1)) - 1)	/* all priorities through pri */
+
+/*
+ * Option flags for openlog.
+ *
+ * LOG_ODELAY no longer does anything.
+ * LOG_NDELAY is the inverse of what it used to be.
+ */
+#define	LOG_PID		0x01	/* log the pid with each message */
+#define	LOG_CONS	0x02	/* log on the console if errors in sending */
+#define	LOG_ODELAY	0x04	/* delay open until first syslog() (default) */
+#define	LOG_NDELAY	0x08	/* don't delay open */
+#define	LOG_NOWAIT	0x10	/* don't wait for console forks: DEPRECATED */
+#define	LOG_PERROR	0x20	/* log to stderr as well */
+
+#ifndef KERNEL
+
+#if 0
+/*
+ * Don't use va_list in the vsyslog() prototype.   Va_list is typedef'd in two
+ * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
+ * of them here we may collide with the utility's includes.  It's unreasonable
+ * for utilities to have to include one of them to include syslog.h, so we get
+ * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
+ */
+#include <machine/ansi.h>
+#elif !defined (_BSD_VA_LIST_)
+/* In GNU we don't have a <machine/ansi.h> and it would be too painful to
+   emulate one.  */
+#define __need_va_list
+#include <stdarg.h>
+#define _BSD_VA_LIST_ __gnuc_va_list
+#endif
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	closelog __P((void));
+void	openlog __P((const char *, int, int));
+int	setlogmask __P((int));
+void	syslog __P((int, const char *, ...));
+void	vsyslog __P((int, const char *, _BSD_VA_LIST_));
+__END_DECLS
+
+#endif /* !KERNEL */
diff --git a/misc/sys/uio.h b/misc/sys/uio.h
new file mode 100644
index 0000000000..301712546f
--- /dev/null
+++ b/misc/sys/uio.h
@@ -0,0 +1,58 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef _SYS_UIO_H
+
+#define _SYS_UIO_H	1
+#include <features.h>
+
+__BEGIN_DECLS
+
+#define	__need_size_t
+#include <stddef.h>
+
+
+/* Structure describing a section of memory.  */
+
+struct iovec
+{
+  /* Starting address.  */
+  __ptr_t iov_base;
+  /* Length in bytes.  */
+  size_t iov_len;
+};
+
+
+/* Read data from file descriptor FD, and put the result in the
+   buffers described by VECTOR, which is a vector of COUNT `struct iovec's.
+   The buffers are filled in the order specified.
+   Operates just like `read' (see <unistd.h>) except that data are
+   put in VECTOR instead of a contiguous buffer.  */
+int readv __P ((int __fd, __const struct iovec * __vector, size_t __count));
+
+/* Write data pointed by the buffers described by VECTOR, which
+   is a vector of COUNT `struct iovec's, to file descriptor FD.
+   The data is written in the order specified.
+   Operates just like `write' (see <unistd.h>) except that the data
+   are taken from VECTOR instead of a contiguous buffer.  */
+int writev __P ((int __fd, __const struct iovec * __vector, size_t __count));
+
+
+__END_DECLS
+
+#endif /* sys/uio.h */
diff --git a/misc/syslog.c b/misc/syslog.c
new file mode 100644
index 0000000000..ba82e23019
--- /dev/null
+++ b/misc/syslog.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 1983, 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)syslog.c	8.4 (Berkeley) 3/18/94";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/syslog.h>
+#include <sys/uio.h>
+#include <netdb.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+static int	LogFile = -1;		/* fd for log */
+static int	connected;		/* have done connect */
+static int	LogStat = 0;		/* status bits, set by openlog() */
+static const char *LogTag = NULL;	/* string to tag the entry with */
+static int	LogFacility = LOG_USER;	/* default facility code */
+static int	LogMask = 0xff;		/* mask of priorities to be logged */
+extern char	*__progname;		/* Program name, from crt0. */
+
+/*
+ * syslog, vsyslog --
+ *	print message on log file; output is intended for syslogd(8).
+ */
+void
+#if __STDC__
+syslog(int pri, const char *fmt, ...)
+#else
+syslog(pri, fmt, va_alist)
+	int pri;
+	char *fmt;
+	va_dcl
+#endif
+{
+	va_list ap;
+
+#if __STDC__
+	va_start(ap, fmt);
+#else
+	va_start(ap);
+#endif
+	vsyslog(pri, fmt, ap);
+	va_end(ap);
+}
+
+void
+vsyslog(pri, fmt, ap)
+	int pri;
+	register const char *fmt;
+	va_list ap;
+{
+	register int cnt;
+	register char ch, *p, *t;
+	time_t now;
+	int fd, saved_errno;
+	char *stdp, tbuf[2048], fmt_cpy[1024];
+
+#define	INTERNALLOG	LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID
+	/* Check for invalid bits. */
+	if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) {
+		syslog(INTERNALLOG,
+		    "syslog: unknown facility/priority: %x", pri);
+		pri &= LOG_PRIMASK|LOG_FACMASK;
+	}
+
+	/* Check priority against setlogmask values. */
+	if (!LOG_MASK(LOG_PRI(pri)) & LogMask)
+		return;
+
+	saved_errno = errno;
+
+	/* Set default facility if none specified. */
+	if ((pri & LOG_FACMASK) == 0)
+		pri |= LogFacility;
+
+	/* Build the message. */
+	(void)time(&now);
+	p = tbuf + sprintf(tbuf, "<%d>", pri);
+	p += strftime(p, sizeof (tbuf) - (p - tbuf), "%h %e %T ",
+	    localtime(&now));
+	if (LogStat & LOG_PERROR)
+		stdp = p;
+	if (LogTag == NULL)
+		LogTag = __progname;
+	if (LogTag != NULL)
+		p += sprintf(p, "%s", LogTag);
+	if (LogStat & LOG_PID)
+		p += sprintf(p, "[%d]", getpid());
+	if (LogTag != NULL) {
+		*p++ = ':';
+		*p++ = ' ';
+	}
+
+	/* Substitute error message for %m. */
+	for (t = fmt_cpy; ch = *fmt; ++fmt)
+		if (ch == '%' && fmt[1] == 'm') {
+			++fmt;
+			t += sprintf(t, "%s", strerror(saved_errno));
+		} else
+			*t++ = ch;
+	*t = '\0';
+
+	p += vsprintf(p, fmt_cpy, ap);
+	cnt = p - tbuf;
+
+	/* Output to stderr if requested. */
+	if (LogStat & LOG_PERROR) {
+		struct iovec iov[2];
+		register struct iovec *v = iov;
+
+		v->iov_base = stdp;
+		v->iov_len = cnt - (stdp - tbuf);
+		++v;
+		v->iov_base = "\n";
+		v->iov_len = 1;
+		(void)writev(STDERR_FILENO, iov, 2);
+	}
+
+	/* Get connected, output the message to the local logger. */
+	if (!connected)
+		openlog(LogTag, LogStat | LOG_NDELAY, 0);
+	if (send(LogFile, tbuf, cnt, 0) >= 0)
+		return;
+
+	/*
+	 * Output the message to the console; don't worry about blocking,
+	 * if console blocks everything will.  Make sure the error reported
+	 * is the one from the syslogd failure.
+	 */
+	if (LogStat & LOG_CONS &&
+	    (fd = open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
+		(void)strcat(tbuf, "\r\n");
+		cnt += 2;
+		p = index(tbuf, '>') + 1;
+		(void)write(fd, p, cnt - (p - tbuf));
+		(void)close(fd);
+	}
+}
+
+static struct sockaddr SyslogAddr;	/* AF_UNIX address of local logger */
+
+void
+openlog(ident, logstat, logfac)
+	const char *ident;
+	int logstat, logfac;
+{
+	if (ident != NULL)
+		LogTag = ident;
+	LogStat = logstat;
+	if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
+		LogFacility = logfac;
+
+	if (LogFile == -1) {
+		SyslogAddr.sa_family = AF_UNIX;
+		(void)strncpy(SyslogAddr.sa_data, _PATH_LOG,
+		    sizeof(SyslogAddr.sa_data));
+		if (LogStat & LOG_NDELAY) {
+			if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
+				return;
+			(void)fcntl(LogFile, F_SETFD, 1);
+		}
+	}
+	if (LogFile != -1 && !connected)
+		if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) == -1) {
+			(void)close(LogFile);
+			LogFile = -1;
+		} else
+			connected = 1;
+}
+
+void
+closelog()
+{
+	(void)close(LogFile);
+	LogFile = -1;
+	connected = 0;
+}
+
+/* setlogmask -- set the log mask level */
+int
+setlogmask(pmask)
+	int pmask;
+{
+	int omask;
+
+	omask = LogMask;
+	if (pmask != 0)
+		LogMask = pmask;
+	return (omask);
+}
diff --git a/misc/syslog.h b/misc/syslog.h
new file mode 100644
index 0000000000..830b4928ad
--- /dev/null
+++ b/misc/syslog.h
@@ -0,0 +1 @@
+#include <sys/syslog.h>
diff --git a/misc/ttyent.h b/misc/ttyent.h
new file mode 100644
index 0000000000..e95db259ca
--- /dev/null
+++ b/misc/ttyent.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)ttyent.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef	_TTYENT_H_
+#define	_TTYENT_H_
+
+#define	_PATH_TTYS	"/etc/ttys"
+
+#define	_TTYS_OFF	"off"
+#define	_TTYS_ON	"on"
+#define	_TTYS_SECURE	"secure"
+#define	_TTYS_WINDOW	"window"
+
+struct ttyent {
+	char	*ty_name;	/* terminal device name */
+	char	*ty_getty;	/* command to execute, usually getty */
+	char	*ty_type;	/* terminal type for termcap */
+#define	TTY_ON		0x01	/* enable logins (start ty_getty program) */
+#define	TTY_SECURE	0x02	/* allow uid of 0 to login */
+	int	ty_status;	/* status flags */
+	char 	*ty_window;	/* command to start up window manager */
+	char	*ty_comment;	/* comment field */
+};
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+struct ttyent *getttyent __P((void));
+struct ttyent *getttynam __P((const char *));
+int setttyent __P((void));
+int endttyent __P((void));
+__END_DECLS
+
+#endif /* !_TTYENT_H_ */
diff --git a/misc/ttyslot.c b/misc/ttyslot.c
new file mode 100644
index 0000000000..3d9fee62fc
--- /dev/null
+++ b/misc/ttyslot.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ttyslot.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ttyent.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+ttyslot()
+{
+	register struct ttyent *ttyp;
+	register int slot;
+	register char *p;
+	int cnt;
+	char *name;
+
+	setttyent();
+	for (cnt = 0; cnt < 3; ++cnt) 
+		if (name = ttyname(cnt)) {
+			if (p = rindex(name, '/')) 
+				++p;
+			else
+				p = name;
+			for (slot = 1; ttyp = getttyent(); ++slot)
+				if (!strcmp(ttyp->ty_name, p)) {
+					endttyent();
+					return(slot);
+				}
+			break;
+		}
+	endttyent();
+	return(0);
+}