Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/unix')
-rw-r--r--newlib/libc/unix/Makefile.am72
-rw-r--r--newlib/libc/unix/Makefile.in402
-rw-r--r--newlib/libc/unix/getcwd.c265
-rw-r--r--newlib/libc/unix/getlogin.c42
-rw-r--r--newlib/libc/unix/getpass.c103
-rw-r--r--newlib/libc/unix/getpwent.c127
-rw-r--r--newlib/libc/unix/getut.c86
-rw-r--r--newlib/libc/unix/pread.c91
-rw-r--r--newlib/libc/unix/pwrite.c92
-rw-r--r--newlib/libc/unix/sigset.c61
-rw-r--r--newlib/libc/unix/ttyname.c86
11 files changed, 0 insertions, 1427 deletions
diff --git a/newlib/libc/unix/Makefile.am b/newlib/libc/unix/Makefile.am
deleted file mode 100644
index 24d1bfb5c..000000000
--- a/newlib/libc/unix/Makefile.am
+++ /dev/null
@@ -1,72 +0,0 @@
-## Process this file with automake to generate Makefile.in
-
-AUTOMAKE_OPTIONS = cygnus
-
-INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
-
-GENERAL_SOURCES = \
- getcwd.c \
- pread.c \
- pwrite.c \
- sigset.c
-
-## Distinguish different EL/IX level interfaces
-ELIX_2_OBJS = \
- ttyname.$(oext)
-
-ELIX_4_OBJS = \
- getlogin.$(oext) \
- getpass.$(oext) \
- getpwent.$(oext) \
- getut.$(oext)
-
-if ELIX_LEVEL_1
-LIB_OBJS =
-else
-if ELIX_LEVEL_2
-LIB_OBJS = $(ELIX_2_OBJS)
-else
-if ELIX_LEVEL_3
-LIB_OBJS = $(ELIX_2_OBJS)
-else
-if ELIX_LEVEL_4
-LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_4_OBJS)
-endif
-endif
-endif
-endif
-
-libunix_la_LDFLAGS = -Xcompiler -nostdlib
-
-if USE_LIBTOOL
-noinst_LTLIBRARIES = libunix.la
-libunix_la_SOURCES = $(GENERAL_SOURCES)
-libunix_la_LIBADD = $(LIB_OBJS)
-libunix_la_DEPENDENCIES = $(LIB_OBJS)
-noinst_DATA = objectlist.awk.in
-else
-noinst_LIBRARIES = lib.a
-lib_a_SOURCES = $(GENERAL_SOURCES)
-lib_a_LIBADD = $(LIB_OBJS)
-lib_a_DEPENDENCIES = $(LIB_OBJS)
-noinst_DATA =
-endif # USE_LIBTOOL
-
-include $(srcdir)/../../Makefile.shared
-
-CHEWOUT_FILES =
-
-SUFFIXES = .def
-
-CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
-
-.c.def:
- $(CHEW) < $< > $*.def 2> $*.ref
- touch stmp-def
-
-TARGETDOC = ../tmp.texi
-
-# No doc for unix.
-doc:
-
-CLEANFILES = $(CHEWOUT_FILES) *.ref
diff --git a/newlib/libc/unix/Makefile.in b/newlib/libc/unix/Makefile.in
deleted file mode 100644
index cdc056b90..000000000
--- a/newlib/libc/unix/Makefile.in
+++ /dev/null
@@ -1,402 +0,0 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_alias = @build_alias@
-build_triplet = @build@
-host_alias = @host_alias@
-host_triplet = @host@
-target_alias = @target_alias@
-target_triplet = @target@
-AR = @AR@
-AS = @AS@
-CC = @CC@
-CPP = @CPP@
-CRT0 = @CRT0@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-DLLTOOL = @DLLTOOL@
-EXEEXT = @EXEEXT@
-GCJ = @GCJ@
-GCJFLAGS = @GCJFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@
-LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@
-LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
-LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
-LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
-LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
-LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
-LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
-LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
-LIBC_SYS_LIB = @LIBC_SYS_LIB@
-LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-STRIP = @STRIP@
-VERSION = @VERSION@
-aext = @aext@
-extra_dir = @extra_dir@
-libm_machine_dir = @libm_machine_dir@
-machine_dir = @machine_dir@
-newlib_basedir = @newlib_basedir@
-oext = @oext@
-sys_dir = @sys_dir@
-
-AUTOMAKE_OPTIONS = cygnus
-
-INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
-
-GENERAL_SOURCES = getcwd.c pread.c pwrite.c sigset.c
-
-
-ELIX_2_OBJS = ttyname.$(oext)
-
-
-ELIX_4_OBJS = getlogin.$(oext) getpass.$(oext) getpwent.$(oext) getut.$(oext)
-
-@ELIX_LEVEL_1_TRUE@LIB_OBJS =
-@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@LIB_OBJS = $(ELIX_2_OBJS)
-@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@LIB_OBJS = $(ELIX_2_OBJS)
-@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_TRUE@LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_4_OBJS)
-
-libunix_la_LDFLAGS = -Xcompiler -nostdlib
-
-@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libunix.la
-@USE_LIBTOOL_TRUE@libunix_la_SOURCES = $(GENERAL_SOURCES)
-@USE_LIBTOOL_TRUE@libunix_la_LIBADD = $(LIB_OBJS)
-@USE_LIBTOOL_TRUE@libunix_la_DEPENDENCIES = $(LIB_OBJS)
-@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in
-@USE_LIBTOOL_FALSE@noinst_DATA =
-@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a
-@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(GENERAL_SOURCES)
-@USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIB_OBJS)
-@USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIB_OBJS)
-
-CHEWOUT_FILES =
-
-SUFFIXES = .def
-
-CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
-
-TARGETDOC = ../tmp.texi
-
-CLEANFILES = $(CHEWOUT_FILES) *.ref
-mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
-CONFIG_CLEAN_FILES =
-LIBRARIES = $(noinst_LIBRARIES)
-
-
-DEFS = @DEFS@ -I. -I$(srcdir)
-CPPFLAGS = @CPPFLAGS@
-LIBS = @LIBS@
-@USE_LIBTOOL_FALSE@lib_a_OBJECTS = getcwd.$(OBJEXT) pread.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@pwrite.$(OBJEXT) sigset.$(OBJEXT)
-LTLIBRARIES = $(noinst_LTLIBRARIES)
-
-@USE_LIBTOOL_TRUE@libunix_la_OBJECTS = getcwd.lo pread.lo pwrite.lo \
-@USE_LIBTOOL_TRUE@sigset.lo
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DATA = $(noinst_DATA)
-
-DIST_COMMON = Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = gtar
-GZIP_ENV = --best
-SOURCES = $(lib_a_SOURCES) $(libunix_la_SOURCES)
-OBJECTS = $(lib_a_OBJECTS) $(libunix_la_OBJECTS)
-
-all: all-redirect
-.SUFFIXES:
-.SUFFIXES: .S .c .def .lo .o .obj .s
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../Makefile.shared
- cd $(top_srcdir) && $(AUTOMAKE) --cygnus unix/Makefile
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-noinstLIBRARIES:
-
-clean-noinstLIBRARIES:
- -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
-
-distclean-noinstLIBRARIES:
-
-maintainer-clean-noinstLIBRARIES:
-
-.c.o:
- $(COMPILE) -c $<
-
-# FIXME: We should only use cygpath when building on Windows,
-# and only if it is available.
-.c.obj:
- $(COMPILE) -c `cygpath -w $<`
-
-.s.o:
- $(COMPILE) -c $<
-
-.S.o:
- $(COMPILE) -c $<
-
-mostlyclean-compile:
- -rm -f *.o core *.core
- -rm -f *.$(OBJEXT)
-
-clean-compile:
-
-distclean-compile:
- -rm -f *.tab.c
-
-maintainer-clean-compile:
-
-.c.lo:
- $(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-.s.lo:
- $(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-.S.lo:
- $(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-distclean-libtool:
-
-maintainer-clean-libtool:
-
-lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES)
- -rm -f lib.a
- $(AR) cru lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
- $(RANLIB) lib.a
-
-mostlyclean-noinstLTLIBRARIES:
-
-clean-noinstLTLIBRARIES:
- -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
-
-distclean-noinstLTLIBRARIES:
-
-maintainer-clean-noinstLTLIBRARIES:
-
-libunix.la: $(libunix_la_OBJECTS) $(libunix_la_DEPENDENCIES)
- $(LINK) $(libunix_la_LDFLAGS) $(libunix_la_OBJECTS) $(libunix_la_LIBADD) $(LIBS)
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP)
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- here=`pwd` && cd $(srcdir) \
- && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
- || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
-
-mostlyclean-tags:
-
-clean-tags:
-
-distclean-tags:
- -rm -f TAGS ID
-
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = unix
-
-distdir: $(DISTFILES)
- @for file in $(DISTFILES); do \
- if test -f $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- cp -pr $$d/$$file $(distdir)/$$file; \
- else \
- test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
- fi; \
- done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am:
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-info-am:
-install-info: install-info-am
-install-exec-am:
-install-exec: install-exec-am
-
-install-data-am:
-install-data: install-data-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA)
-all-redirect: all-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
-mostlyclean-generic:
-
-clean-generic:
- -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
-
-distclean-generic:
- -rm -f Makefile $(CONFIG_CLEAN_FILES)
- -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
- mostlyclean-libtool mostlyclean-noinstLTLIBRARIES \
- mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am: clean-noinstLIBRARIES clean-compile clean-libtool \
- clean-noinstLTLIBRARIES clean-tags clean-generic \
- mostlyclean-am
-
-clean: clean-am
-
-distclean-am: distclean-noinstLIBRARIES distclean-compile \
- distclean-libtool distclean-noinstLTLIBRARIES \
- distclean-tags distclean-generic clean-am
- -rm -f libtool
-
-distclean: distclean-am
-
-maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
- maintainer-clean-compile maintainer-clean-libtool \
- maintainer-clean-noinstLTLIBRARIES \
- maintainer-clean-tags maintainer-clean-generic \
- distclean-am
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
-clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile mostlyclean-libtool distclean-libtool \
-clean-libtool maintainer-clean-libtool mostlyclean-noinstLTLIBRARIES \
-distclean-noinstLTLIBRARIES clean-noinstLTLIBRARIES \
-maintainer-clean-noinstLTLIBRARIES tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-info-am install-info \
-install-exec-am install-exec install-data-am install-data install-am \
-install uninstall-am uninstall all-redirect all-am all installdirs \
-mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
-
-
-objectlist.awk.in: $(noinst_LTLIBRARIES)
- -rm -f objectlist.awk.in
- for i in `ls *.lo` ; \
- do \
- echo $$i `pwd`/$$i >> objectlist.awk.in ; \
- done
-
-.c.def:
- $(CHEW) < $< > $*.def 2> $*.ref
- touch stmp-def
-
-# No doc for unix.
-doc:
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/newlib/libc/unix/getcwd.c b/newlib/libc/unix/getcwd.c
deleted file mode 100644
index 826fc789d..000000000
--- a/newlib/libc/unix/getcwd.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 1989, 1991 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[] = "@(#)getcwd.c 5.11 (Berkeley) 2/24/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/stat.h>
-#include <errno.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <reent.h>
-#include <_syslist.h>
-
-#define bcopy(a,b,c) memmove (b,a,c)
-
-#define ISDOT(dp) \
- (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
- (dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
-
-#ifndef _REENT_ONLY
-
-char *
-getcwd (pt, size)
- char *pt;
- size_t size;
-{
- register struct dirent *dp;
- register DIR *dir;
- register dev_t dev;
- register ino_t ino;
- register int first;
- register char *bpt, *bup;
- struct stat s;
- dev_t root_dev;
- ino_t root_ino;
- size_t ptsize, upsize;
- int save_errno;
- char *ept, *eup, *up;
-
- /*
- * If no buffer specified by the user, allocate one as necessary.
- * If a buffer is specified, the size has to be non-zero. The path
- * is built from the end of the buffer backwards.
- */
-
- if (pt)
- {
- ptsize = 0;
- if (!size)
- {
- errno = EINVAL;
- return (char *) NULL;
- }
- ept = pt + size;
- }
- else
- {
- if (!(pt = (char *) malloc (ptsize = 1024 - 4)))
- {
- return (char *) NULL;
- }
- ept = pt + ptsize;
- }
- bpt = ept - 1;
- *bpt = '\0';
-
- /*
- * Allocate bytes (1024 - malloc space) for the string of "../"'s.
- * Should always be enough (it's 340 levels). If it's not, allocate
- * as necessary. Special * case the first stat, it's ".", not "..".
- */
-
- if (!(up = (char *) malloc (upsize = 1024 - 4)))
- {
- goto err;
- }
- eup = up + MAXPATHLEN;
- bup = up;
- up[0] = '.';
- up[1] = '\0';
-
- /* Save root values, so know when to stop. */
- if (stat ("/", &s))
- goto err;
- root_dev = s.st_dev;
- root_ino = s.st_ino;
-
- errno = 0; /* XXX readdir has no error return. */
-
- for (first = 1;; first = 0)
- {
- /* Stat the current level. */
- if (_stat (up, &s))
- goto err;
-
- /* Save current node values. */
- ino = s.st_ino;
- dev = s.st_dev;
-
- /* Check for reaching root. */
- if (root_dev == dev && root_ino == ino)
- {
- *--bpt = '/';
- /*
- * It's unclear that it's a requirement to copy the
- * path to the beginning of the buffer, but it's always
- * been that way and stuff would probably break.
- */
- (void) bcopy (bpt, pt, ept - bpt);
- free (up);
- return pt;
- }
-
- /*
- * Build pointer to the parent directory, allocating memory
- * as necessary. Max length is 3 for "../", the largest
- * possible component name, plus a trailing NULL.
- */
-
- if (bup + 3 + MAXNAMLEN + 1 >= eup)
- {
- if (!(up = (char *) realloc (up, upsize *= 2)))
- {
- goto err;
- }
- bup = up;
- eup = up + upsize;
- }
- *bup++ = '.';
- *bup++ = '.';
- *bup = '\0';
-
- /* Open and stat parent directory. */
- if (!(dir = _opendir (up)) || _fstat (__dirfd (dir), &s))
- goto err;
-
- /* Add trailing slash for next directory. */
- *bup++ = '/';
-
- /*
- * If it's a mount point, have to stat each element because
- * the inode number in the directory is for the entry in the
- * parent directory, not the inode number of the mounted file.
- */
-
- save_errno = 0;
- if (s.st_dev == dev)
- {
- for (;;)
- {
- if (!(dp = _readdir (dir)))
- goto notfound;
- if (dp->d_ino == ino)
- break;
- }
- }
- else
- for (;;)
- {
- if (!(dp = _readdir (dir)))
- goto notfound;
- if (ISDOT (dp))
- continue;
- bcopy (dp->d_name, bup, strlen (dp->d_name) + 1);
-
- /* Save the first error for later. */
- if (stat (up, &s))
- {
- if (!save_errno)
- save_errno = errno;
- errno = 0;
- continue;
- }
- if (s.st_dev == dev && s.st_ino == ino)
- break;
- }
-
- /*
- * Check for length of the current name, preceding slash,
- * leading slash.
- */
-
- if (bpt - pt <= strlen (dp->d_name) + (first ? 1 : 2))
- {
- size_t len, off;
-
- if (!ptsize)
- {
- errno = ERANGE;
- goto err;
- }
- off = bpt - pt;
- len = ept - bpt;
- if (!(pt = (char *) realloc (pt, ptsize *= 2)))
- {
- goto err;
- }
- bpt = pt + off;
- ept = pt + ptsize;
- (void) bcopy (bpt, ept - len, len);
- bpt = ept - len;
- }
- if (!first)
- *--bpt = '/';
- bpt -= strlen (dp->d_name);
- bcopy (dp->d_name, bpt, strlen (dp->d_name));
- (void) _closedir (dir);
-
- /* Truncate any file name. */
- *bup = '\0';
- }
-
-notfound:
- /*
- * If readdir set errno, use it, not any saved error; otherwise,
- * didn't find the current directory in its parent directory, set
- * errno to ENOENT.
- */
-
- if (!errno)
- errno = save_errno ? save_errno : ENOENT;
- /* FALLTHROUGH */
-
-err:
- if (ptsize)
- free (pt);
- free (up);
- return (char *) NULL;
-}
-
-#endif /* _REENT_ONLY */
diff --git a/newlib/libc/unix/getlogin.c b/newlib/libc/unix/getlogin.c
deleted file mode 100644
index e043b029f..000000000
--- a/newlib/libc/unix/getlogin.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <utmp.h>
-#include <fcntl.h>
-#include <_syslist.h>
-
-char *
-getlogin ()
-{
- int utmp_fd;
- struct utmp utmp_buf;
- static char buf[10];
- extern char *ttyname ();
- char *tty;
-
- if (((tty = ttyname (0)) == 0)
- || ((tty = ttyname (1)) == 0)
- || ((tty = ttyname (2)) == 0))
- return 0;
-
- if ((utmp_fd = _open (UTMP_FILE, O_RDONLY)) == -1)
- return 0;
-
- if (!strncmp (tty, "/dev/", 5))
- tty += 5;
-
- while (_read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf))
- {
- if (!strncmp (tty, utmp_buf.ut_line, sizeof (utmp_buf.ut_line))
- && utmp_buf.ut_type == USER_PROCESS)
- {
- _close (utmp_fd);
- memset (buf, 0, sizeof (buf));
- strncpy (buf, utmp_buf.ut_user, sizeof (utmp_buf.ut_user));
- return buf;
- }
- }
-
- _close (utmp_fd);
- return 0;
-}
diff --git a/newlib/libc/unix/getpass.c b/newlib/libc/unix/getpass.c
deleted file mode 100644
index db0e52d61..000000000
--- a/newlib/libc/unix/getpass.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 1988 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[] = "@(#)getpass.c 5.9 (Berkeley) 5/6/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <sys/termios.h>
-#include <sys/signal.h>
-#include <_syslist.h>
-
-#ifndef _PATH_PASSWD
-#define _PATH_PASSWD "/etc/passwd"
-#endif
-
-#ifndef _PASSWORD_LEN
-#define _PASSWORD_LEN 128 /* max length, not counting NULL */
-#endif
-
-char *
-getpass (prompt)
- const char *prompt;
-{
- struct termios term;
- register int ch;
- register char *p;
- FILE *fp, *outfp;
- long omask;
- int echo;
- static char buf[_PASSWORD_LEN + 1];
-
- /*
- * read and write to /dev/tty if possible; else read from
- * stdin and write to stderr.
- */
-
- if ((outfp = fp = fopen ("/dev/tty", "w+")) == NULL)
- {
- outfp = stderr;
- fp = stdin;
- }
- /*
- * note - blocking signals isn't necessarily the
- * right thing, but we leave it for now.
- */
- omask = sigblock (sigmask (SIGINT) | sigmask (SIGTSTP));
- (void) tcgetattr (fileno (fp), &term);
- echo = (term.c_lflag & ECHO);
- if (echo)
- {
- term.c_lflag &= ~ECHO;
- (void) tcsetattr (fileno (fp), TCSAFLUSH, &term);
- }
- (void) fputs (prompt, outfp);
- rewind (outfp); /* implied flush */
- for (p = buf; (ch = getc (fp)) != EOF && ch != '\n';)
- if (p < buf + _PASSWORD_LEN)
- *p++ = ch;
- *p = '\0';
- (void) _write (fileno (outfp), "\n", 1);
- if (echo)
- {
- term.c_lflag |= ECHO;
- tcsetattr (fileno (fp), TCSAFLUSH, &term);
- }
- (void) sigsetmask (omask);
- if (fp != stdin)
- (void) fclose (fp);
- return buf;
-}
diff --git a/newlib/libc/unix/getpwent.c b/newlib/libc/unix/getpwent.c
deleted file mode 100644
index 5390c682f..000000000
--- a/newlib/libc/unix/getpwent.c
+++ /dev/null
@@ -1,127 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-static struct passwd pw_passwd; /* password structure */
-static FILE *passwd_fp;
-
-static char logname[8];
-static char password[1024];
-static char gecos[1024];
-static char dir[1024];
-static char shell[1024];
-
-struct passwd *
-getpwnam (name)
- const char *name;
-{
- FILE *fp;
- char buf[1024];
-
- if ((fp = fopen ("/etc/passwd", "r")) == NULL)
- {
- return NULL;
- }
-
- while (fgets (buf, sizeof (buf), fp))
- {
- sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
- logname, password, &pw_passwd.pw_uid,
- &pw_passwd.pw_gid, gecos,
- dir, shell);
- pw_passwd.pw_name = logname;
- pw_passwd.pw_passwd = password;
- pw_passwd.pw_comment = "";
- pw_passwd.pw_gecos = gecos;
- pw_passwd.pw_dir = dir;
- pw_passwd.pw_shell = shell;
-
- if (!strcmp (logname, name))
- {
- fclose (fp);
- return &pw_passwd;
- }
- }
- fclose (fp);
- return NULL;
-}
-
-struct passwd *
-getpwuid (uid_t uid)
-{
- FILE *fp;
- char buf[1024];
-
- if ((fp = fopen ("/etc/passwd", "r")) == NULL)
- {
- return NULL;
- }
-
- while (fgets (buf, sizeof (buf), fp))
- {
- sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
- logname, password, &pw_passwd.pw_uid,
- &pw_passwd.pw_gid, gecos,
- dir, shell);
- pw_passwd.pw_name = logname;
- pw_passwd.pw_passwd = password;
- pw_passwd.pw_comment = "";
- pw_passwd.pw_gecos = gecos;
- pw_passwd.pw_dir = dir;
- pw_passwd.pw_shell = shell;
-
- if (uid == pw_passwd.pw_uid)
- {
- fclose (fp);
- return &pw_passwd;
- }
- }
- fclose (fp);
- return NULL;
-}
-
-struct passwd *
-getpwent ()
-{
- char buf[1024];
-
- if (passwd_fp == NULL)
- return NULL;
-
- if (fgets (buf, sizeof (buf), passwd_fp) == NULL)
- return NULL;
-
- sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
- logname, password, &pw_passwd.pw_uid,
- &pw_passwd.pw_gid, gecos,
- dir, shell);
- pw_passwd.pw_name = logname;
- pw_passwd.pw_passwd = password;
- pw_passwd.pw_comment = "";
- pw_passwd.pw_gecos = gecos;
- pw_passwd.pw_dir = dir;
- pw_passwd.pw_shell = shell;
-
- return &pw_passwd;
-}
-
-void
-setpwent ()
-{
- if (passwd_fp != NULL)
- fclose (passwd_fp);
-
- passwd_fp = fopen ("/etc/passwd", "r");
-}
-
-void
-endpwent ()
-{
- if (passwd_fp != NULL)
- fclose (passwd_fp);
-}
diff --git a/newlib/libc/unix/getut.c b/newlib/libc/unix/getut.c
deleted file mode 100644
index 1e2b75596..000000000
--- a/newlib/libc/unix/getut.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <utmp.h>
-#include <_syslist.h>
-#include <_ansi.h>
-
-static int utmp_fd = -2;
-static char *utmp_file = UTMP_FILE;
-
-static struct utmp utmp_data;
-
-void
-setutent ()
-{
- if (utmp_fd == -2)
- {
- utmp_fd = _open (utmp_file, O_RDONLY);
- }
- _lseek (utmp_fd, 0, SEEK_SET);
-}
-
-void
-endutent ()
-{
- _close (utmp_fd);
- utmp_fd = -2;
-}
-
-void
-utmpname (_CONST char *file)
-{
- utmp_file = strdup (file);
-}
-
-struct utmp *
-getutent ()
-{
- if (utmp_fd == -2)
- setutent ();
- if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data))
- return 0;
- return &utmp_data;
-}
-
-struct utmp *
-getutid (struct utmp *id)
-{
- while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
- {
- switch (id->ut_type)
- {
- case RUN_LVL:
- case BOOT_TIME:
- case OLD_TIME:
- case NEW_TIME:
- if (id->ut_type == utmp_data.ut_type)
- return &utmp_data;
- case INIT_PROCESS:
- case LOGIN_PROCESS:
- case USER_PROCESS:
- case DEAD_PROCESS:
- if (id->ut_id == utmp_data.ut_id)
- return &utmp_data;
- default:
- abort ();
- }
- }
- return 0;
-}
-
-struct utmp *
-getutline (struct utmp *line)
-{
- while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
- {
- if ((utmp_data.ut_type == LOGIN_PROCESS ||
- utmp_data.ut_type == USER_PROCESS) &&
- !strncmp (utmp_data.ut_line, line->ut_line,
- sizeof (utmp_data.ut_line)))
- return &utmp_data;
- }
-
- return 0;
-}
diff --git a/newlib/libc/unix/pread.c b/newlib/libc/unix/pread.c
deleted file mode 100644
index 72087542e..000000000
--- a/newlib/libc/unix/pread.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-FUNCTION
-<<pread>>---read a file from specified position
-
-INDEX
- pread
-INDEX
- _pread_r
-
-ANSI_SYNOPSIS
- #include <unistd.h>
- ssize_t pread(int <[fd]>, void *<[buf]>, size_t <[n]>, off_t <[off]>);
- ssize_t _pread_r(struct _reent *<[rptr]>, int <[fd]>,
- void *<[buf]>, size_t <[n]>, off_t <[off]>);
-
-TRAD_SYNOPSIS
- #include <unistd.h>
- ssize_t pread(<[fd]>, <[buf]>, <[n]>, <[off]>)
- int <[fd]>;
- void *<[buf]>;
- size_t <[n]>;
- off_t <[off]>;
-
- ssize_t _pread_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>)
- struct _reent *<[rptr]>;
- int <[fd]>;
- void *<[buf]>;
- size_t <[n]>;
- off_t <[off]>;
-
-DESCRIPTION
-The <<pread>> function is similar to <<read>>. One difference is that
-<<pread>> has an additional parameter <[off]> which is the offset to
-position in the file before reading. The function also differs in that
-the file position is unchanged by the function (i.e. the file position
-is the same before and after a call to <<pread>>).
-
-The <<_pread_r>> function is the same as <<pread>>, only a reentrant
-struct pointer <[rptr]> is provided to preserve reentrancy.
-
-RETURNS
-<<pread>> returns the number of bytes read or <<-1>> if failure occurred.
-
-PORTABILITY
-<<pread>> is non-ANSI and is specified by the Single Unix Specification.
-
-Supporting OS subroutine required: <<read>>, <<lseek>>.
-*/
-
-#include <_ansi.h>
-#include <unistd.h>
-#include <reent.h>
-
-ssize_t
-_DEFUN (_pread_r, (rptr, fd, buf, n, off),
- struct _reent *rptr _AND
- int fd _AND
- _PTR buf _AND
- size_t n _AND
- off_t off)
-{
- off_t cur_pos;
- _READ_WRITE_RETURN_TYPE num_read;
-
- if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1)
- return -1;
-
- if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1)
- return -1;
-
- num_read = _read_r (rptr, fd, buf, n);
-
- if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1)
- return -1;
-
- return (ssize_t)num_read;
-}
-
-#ifndef _REENT_ONLY
-
-ssize_t
-_DEFUN (pread, (fd, buf, n, off),
- int fd _AND
- _PTR buf _AND
- size_t n _AND
- off_t off)
-{
- return _pread_r (_REENT, fd, buf, n, off);
-}
-
-#endif
diff --git a/newlib/libc/unix/pwrite.c b/newlib/libc/unix/pwrite.c
deleted file mode 100644
index 23979ac79..000000000
--- a/newlib/libc/unix/pwrite.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-FUNCTION
-<<pwrite>>---write a file from specified position
-
-INDEX
- pwrite
-INDEX
- _pwrite_r
-
-ANSI_SYNOPSIS
- #include <unistd.h>
- ssize_t pwrite(int <[fd]>, const void *<[buf]>,
- size_t <[n]>, off_t <[off]>);
- ssize_t _pwrite_r(struct _reent *<[rptr]>, int <[fd]>,
- const void *<[buf]>, size_t <[n]>, off_t <[off]>);
-
-TRAD_SYNOPSIS
- #include <unistd.h>
- ssize_t pwrite(<[fd]>, <[buf]>, <[n]>, <[off]>)
- int <[fd]>;
- const void *<[buf]>;
- size_t <[n]>;
- off_t <[off]>;
-
- ssize_t _pwrite_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>)
- struct _reent *<[rptr]>;
- int <[fd]>;
- const void *<[buf]>;
- size_t <[n]>;
- off_t <[off]>;
-
-DESCRIPTION
-The <<pwrite>> function is similar to <<write>>. One difference is that
-<<pwrite>> has an additional parameter <[off]> which is the offset to
-position in the file before writing. The function also differs in that
-the file position is unchanged by the function (i.e. the file position
-is the same before and after a call to <<pwrite>>).
-
-The <<_pwrite_r>> function is the same as <<pwrite>>, only a reentrant
-struct pointer <[rptr]> is provided to preserve reentrancy.
-
-RETURNS
-<<pwrite>> returns the number of bytes written or <<-1>> if failure occurred.
-
-PORTABILITY
-<<pwrite>> is non-ANSI and is specified by the Single Unix Specification.
-
-Supporting OS subroutine required: <<write>>, <<lseek>>.
-*/
-
-#include <_ansi.h>
-#include <unistd.h>
-#include <reent.h>
-
-ssize_t
-_DEFUN (_pwrite_r, (rptr, fd, buf, n, off),
- struct _reent *rptr _AND
- int fd _AND
- _CONST _PTR buf _AND
- size_t n _AND
- off_t off)
-{
- off_t cur_pos;
- _READ_WRITE_RETURN_TYPE num_written;
-
- if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1)
- return -1;
-
- if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1)
- return -1;
-
- num_written = _write_r (rptr, fd, buf, n);
-
- if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1)
- return -1;
-
- return (ssize_t)num_written;
-}
-
-#ifndef _REENT_ONLY
-
-ssize_t
-_DEFUN (pwrite, (fd, buf, n, off),
- int fd _AND
- _CONST _PTR buf _AND
- size_t n _AND
- off_t off)
-{
- return _pwrite_r (_REENT, fd, buf, n, off);
-}
-
-#endif
diff --git a/newlib/libc/unix/sigset.c b/newlib/libc/unix/sigset.c
deleted file mode 100644
index cd73a78c8..000000000
--- a/newlib/libc/unix/sigset.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-
-#if defined(SIG_SETMASK) && NSIG <= 32 /* easier than trying to remove from Makefile */
-
-#undef sigemptyset
-int
-sigemptyset (sigset_t * set)
-{
- *set = (sigset_t) 0;
- return 0;
-}
-
-int
-sigfillset (sigset_t * set)
-{
- *set = ~((sigset_t) 0);
- return 0;
-}
-
-#undef sigaddset
-int
-sigaddset (sigset_t * set, int signo)
-{
- if (signo >= NSIG || signo <= 0)
- {
- errno = EINVAL;
- return -1;
- }
- *set |= 1 << (signo - 1);
- return 0;
-}
-
-int
-sigdelset (sigset_t * set, int signo)
-{
- if (signo >= NSIG || signo <= 0)
- {
- errno = EINVAL;
- return -1;
- }
- *set &= ~(1 << (signo - 1));
- return 0;
-}
-
-int
-sigismember (const sigset_t * set, int signo)
-{
- if (signo >= NSIG || signo <= 0)
- {
- errno = EINVAL;
- return -1;
- }
-
- if (*set & (1 << (signo - 1)))
- return 1;
- else
- return 0;
-}
-
-#endif /* SIG_SETMASK */
diff --git a/newlib/libc/unix/ttyname.c b/newlib/libc/unix/ttyname.c
deleted file mode 100644
index 258ba25fe..000000000
--- a/newlib/libc/unix/ttyname.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 1988 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[] = "@(#)ttyname.c 5.10 (Berkeley) 5/6/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <termios.h>
-#include <unistd.h>
-#include <string.h>
-#include <paths.h>
-#include <_syslist.h>
-
-static char buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
-
-char *
-ttyname (fd)
- int fd;
-{
- struct stat sb;
- struct termios tty;
- struct dirent *dirp;
- DIR *dp;
- struct stat dsb;
- char *rval;
-
- /* Must be a terminal. */
- if (tcgetattr (fd, &tty) < 0)
- return NULL;
-
- /* Must be a character device. */
- if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
- return NULL;
-
- if ((dp = _opendir (_PATH_DEV)) == NULL)
- return NULL;
-
- for (rval = NULL; dirp = _readdir (dp);)
- {
- if (dirp->d_ino != sb.st_ino)
- continue;
- strcpy (buf + sizeof (_PATH_DEV) - 1, dirp->d_name);
- if (stat (buf, &dsb) || sb.st_dev != dsb.st_dev ||
- sb.st_ino != dsb.st_ino)
- continue;
- (void) _closedir (dp);
- rval = buf;
- break;
- }
- (void) _closedir (dp);
- return rval;
-}