summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-10-02 02:09:38 +0000
committerJim Meyering <jim@meyering.net>1994-10-02 02:09:38 +0000
commitf17c045d219e48e96f7a35d37f239627fa0f8fcf (patch)
treec1cc2f8565c315aebefda2e283632a00595fa4d0 /lib
parentb055972c6b12e52f0e41a47d47b711e10b530c1b (diff)
downloadcoreutils-f17c045d219e48e96f7a35d37f239627fa0f8fcf.tar.xz
.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.in47
-rw-r--r--lib/backupfile.c20
-rw-r--r--lib/mkdir.c81
-rw-r--r--lib/savedir.c20
4 files changed, 68 insertions, 100 deletions
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 5737aa4ef..b84df8b5f 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -23,14 +23,12 @@ VPATH = @srcdir@
CC = @CC@
AR = ar
RANLIB = @RANLIB@
-DEFS = -DCONFIG_BROKETS -Dlint @DEFS@
+DEFS = -Dlint @DEFS@
CFLAGS = @CFLAGS@
YACC = @YACC@
-prefix = @prefix@
-exec_prefix = $(prefix)
+exec_prefix = @exec_prefix@
libdir = $(exec_prefix)/lib
-
SOURCES = getdate.y posixtm.y \
argmatch.c backupfile.c basename.c dirname.c eaccess.c \
error.c filemode.c fsusage.c full-write.c getopt.c getopt1.c \
@@ -49,19 +47,21 @@ stripslash.o xgetcwd.o xmalloc.o xstrdup.o userspec.o yesno.o \
@LIBOBJS@ @ALLOCA@
DISTFILES = Makefile.in backupfile.h getopt.h modechange.h \
-fnmatch.h fsusage.h mountlist.h pathmax.h safe-xstat.c.in safe-xstat.h.in \
+fnmatch.h fsusage.h mountlist.h pathmax.h safe-xstat.cin safe-xstat.hin \
getdate.c posixtm.c $(SOURCES)
all: libfu.a
-.SUFFIXES =
-.SUFFIXES = .c .o
+.SUFFIXES:
+.SUFFIXES: .c .o
.c.o:
$(CC) -c $(CPPFLAGS) $(DEFS) -I. -I.. -I$(srcdir) $(CFLAGS) $<
Makefile: ../config.status Makefile.in
- CONFIG_FILES=$@ CONFIG_HEADERS= ../config.status
+ cd ..; CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
+
+installdirs:
install: all
@@ -78,12 +78,13 @@ clean:
mostlyclean: clean
distclean: clean
- rm -f Makefile *.tab.c getdate.c *posixtm.c
+ rm -f Makefile *.tab.c getdate.c *posixtm.c \
+ safe-stat.c safe-stat.h safe-lstat.c safe-lstat.h
realclean: distclean
- rm -f TAGS safe-stat.c safe-stat.h safe-lstat.c safe-lstat.h
+ rm -f TAGS
-distdir = ../`cat ../.fname`/lib
+distdir = ../`cat ../distname`/$(subdir)
dist: $(DISTFILES)
for file in $(DISTFILES); do \
ln $$file $(distdir) \
@@ -98,21 +99,21 @@ libfu.a: $(OBJECTS)
extract_stat = sed -e 's/@l@//g' -e 's/@L@//g'
extract_lstat = sed -e 's/@l@/l/g' -e 's/@L@/L/g'
-safe-lstat.c: safe-xstat.c.in
- $(extract_lstat) $(srcdir)/safe-xstat.c.in > $@-tmp
- mv $@-tmp $@
+safe-lstat.c: safe-xstat.cin
+ $(extract_lstat) $(srcdir)/safe-xstat.cin > $@-t
+ mv $@-t $@
-safe-lstat.h: safe-xstat.h.in
- $(extract_lstat) $(srcdir)/safe-xstat.h.in > $@-tmp
- mv $@-tmp $@
+safe-lstat.h: safe-xstat.hin
+ $(extract_lstat) $(srcdir)/safe-xstat.hin > $@-t
+ mv $@-t $@
-safe-stat.c: safe-xstat.c.in
- $(extract_stat) $(srcdir)/safe-xstat.c.in > $@-tmp
- mv $@-tmp $@
+safe-stat.c: safe-xstat.cin
+ $(extract_stat) $(srcdir)/safe-xstat.cin > $@-t
+ mv $@-t $@
-safe-stat.h: safe-xstat.h.in
- $(extract_stat) $(srcdir)/safe-xstat.h.in > $@-tmp
- mv $@-tmp $@
+safe-stat.h: safe-xstat.hin
+ $(extract_stat) $(srcdir)/safe-xstat.hin > $@-t
+ mv $@-t $@
safe-stat.o: safe-stat.h
safe-lstat.o: safe-lstat.h
diff --git a/lib/backupfile.c b/lib/backupfile.c
index 2ef0f0b48..36094af5e 100644
--- a/lib/backupfile.c
+++ b/lib/backupfile.c
@@ -45,24 +45,24 @@
#include <strings.h>
#endif
-#ifdef DIRENT
+#ifdef HAVE_DIRENT_H
#include <dirent.h>
#define NLENGTH(direct) (strlen((direct)->d_name))
-#else /* not DIRENT */
+#else /* not HAVE_DIRENT_H */
#define dirent direct
#define NLENGTH(direct) ((direct)->d_namlen)
-#ifdef SYSNDIR
+#ifdef HAVE_SYS_NDIR_H
#include <sys/ndir.h>
-#endif /* SYSNDIR */
-#ifdef SYSDIR
+#endif /* HAVE_SYS_NDIR_H */
+#ifdef HAVE_SYS_DIR_H
#include <sys/dir.h>
-#endif /* SYSDIR */
-#ifdef NDIR
+#endif /* HAVE_SYS_DIR_H */
+#ifdef HAVE_NDIR_H
#include <ndir.h>
-#endif /* NDIR */
-#endif /* DIRENT */
+#endif /* HAVE_NDIR_H */
+#endif /* HAVE_DIRENT_H */
-#ifdef VOID_CLOSEDIR
+#ifdef CLOSEDIR_VOID
/* Fake a return value. */
#define CLOSEDIR(d) (closedir (d), 0)
#else
diff --git a/lib/mkdir.c b/lib/mkdir.c
index b1eb47333..3726cbbcc 100644
--- a/lib/mkdir.c
+++ b/lib/mkdir.c
@@ -1,4 +1,4 @@
-/* mkdir.c -- BSD compatible directory functions for System V
+/* mkdir.c -- BSD compatible make directory function for System V
Copyright (C) 1988, 1990 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -28,14 +28,15 @@
#include <sys/types.h>
#include <sys/stat.h>
+
#include <errno.h>
-#ifndef STDC_HEADERS
+#ifndef errno
extern int errno;
#endif
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
-#endif /* STAT_MACROS_BROKEN. */
+#endif
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
@@ -43,7 +44,7 @@ extern int errno;
#include "safe-stat.h"
-/* mkdir and rmdir adapted from GNU tar. */
+/* mkdir adapted from GNU tar. */
/* Make directory DPATH, with permission mode DMODE.
@@ -66,7 +67,7 @@ mkdir (dpath, dmode)
if (SAFE_STAT (dpath, &statbuf) == 0)
{
- errno = EEXIST; /* stat worked, so it already exists. */
+ errno = EEXIST; /* stat worked, it already exists */
return -1;
}
@@ -77,70 +78,36 @@ mkdir (dpath, dmode)
cpid = fork ();
switch (cpid)
{
- case -1: /* Cannot fork. */
- return -1; /* errno is set already. */
+ case -1: /* cannot fork */
+ return -1; /* errno already set */
+
+ case 0: /* child process */
- case 0: /* Child process. */
/* Cheap hack to set mode of new directory. Since this child
- process is going away anyway, we zap its umask.
- This won't suffice to set SUID, SGID, etc. on this
- directory, so the parent process calls chmod afterward. */
- status = umask (0); /* Get current umask. */
- umask (status | (0777 & ~dmode)); /* Set for mkdir. */
+ process is going away anyway, we zap its umask. This won't
+ suffice to set SUID, SGID, etc. on this directory, so the parent
+ process calls chmod afterward. */
+
+ status = umask (0);
+ umask (status | (0777 & ~dmode));
execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
_exit (1);
- default: /* Parent process. */
- while (wait (&status) != cpid) /* Wait for kid to finish. */
- /* Do nothing. */ ;
+ default: /* parent process */
- if (status & 0xFFFF)
- {
- errno = EIO; /* /bin/mkdir failed. */
- return -1;
- }
- return chmod (dpath, dmode);
- }
-}
-
-/* Remove directory DPATH.
- Return 0 if successful, -1 if not. */
+ /* Wait for kid to finish. */
-int
-rmdir (dpath)
- char *dpath;
-{
- int cpid, status;
- struct stat statbuf;
-
- if (SAFE_STAT (dpath, &statbuf) != 0)
- return -1; /* stat set errno. */
-
- if (!S_ISDIR (statbuf.st_mode))
- {
- errno = ENOTDIR;
- return -1;
- }
-
- cpid = fork ();
- switch (cpid)
- {
- case -1: /* Cannot fork. */
- return -1; /* errno is set already. */
-
- case 0: /* Child process. */
- execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
- _exit (1);
-
- default: /* Parent process. */
- while (wait (&status) != cpid) /* Wait for kid to finish. */
+ while (wait (&status) != cpid)
/* Do nothing. */ ;
if (status & 0xFFFF)
{
- errno = EIO; /* /bin/rmdir failed. */
+
+ /* /bin/mkdir failed. */
+
+ errno = EIO;
return -1;
}
- return 0;
+ return chmod (dpath, dmode);
}
}
diff --git a/lib/savedir.c b/lib/savedir.c
index b831c1fe9..cdf1288a3 100644
--- a/lib/savedir.c
+++ b/lib/savedir.c
@@ -34,24 +34,24 @@
#include <unistd.h>
#endif
-#ifdef DIRENT
+#ifdef HAVE_DIRENT_H
#include <dirent.h>
#define NLENGTH(direct) (strlen((direct)->d_name))
-#else /* not DIRENT */
+#else /* not HAVE_DIRENT_H */
#define dirent direct
#define NLENGTH(direct) ((direct)->d_namlen)
-#ifdef SYSNDIR
+#ifdef HAVE_SYS_NDIR_H
#include <sys/ndir.h>
-#endif /* SYSNDIR */
-#ifdef SYSDIR
+#endif /* HAVE_SYS_NDIR_H */
+#ifdef HAVE_SYS_DIR_H
#include <sys/dir.h>
-#endif /* SYSDIR */
-#ifdef NDIR
+#endif /* HAVE_SYS_DIR_H */
+#ifdef HAVE_NDIR_H
#include <ndir.h>
-#endif /* NDIR */
-#endif /* DIRENT */
+#endif /* HAVE_NDIR_H */
+#endif /* HAVE_DIRENT_H */
-#ifdef VOID_CLOSEDIR
+#ifdef CLOSEDIR_VOID
/* Fake a return value. */
#define CLOSEDIR(d) (closedir (d), 0)
#else