summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mkdirat.c34
-rw-r--r--lib/openat.c32
2 files changed, 3 insertions, 63 deletions
diff --git a/lib/mkdirat.c b/lib/mkdirat.c
index 140f96a96..b9ba52dcd 100644
--- a/lib/mkdirat.c
+++ b/lib/mkdirat.c
@@ -1,5 +1,5 @@
/* provide a replacement openat function
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,47 +24,17 @@
#include "openat.h"
#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
-#include "alloca.h"
#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
-#include "intprops.h"
#include "save-cwd.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
-/* Set PROC_FD_FILENAME to the expansion of "/proc/self/fd/%d/%s" in
- alloca'd memory, using FD and FILE, respectively for %d and %s. */
-#define BUILD_PROC_NAME(Proc_fd_filename, Fd, File) \
- do \
- { \
- size_t filelen = strlen (File); \
- static const char procfd[] = "/proc/self/fd/%d/%s"; \
- /* Buffer for the file name we are going to use. It consists of \
- - the string /proc/self/fd/ \
- - the file descriptor number \
- - the file name provided. \
- The final NUL is included in the sizeof. \
- Subtract 4 to account for %d and %s. */ \
- size_t buflen = sizeof (procfd) - 4 + INT_STRLEN_BOUND (Fd) + filelen; \
- (Proc_fd_filename) = alloca (buflen); \
- snprintf ((Proc_fd_filename), buflen, procfd, (Fd), (File)); \
- } \
- while (0)
-
-/* Trying to access a BUILD_PROC_NAME file will fail on systems without
- /proc support, and even on systems *with* ProcFS support. Return
- nonzero if the failure may be legitimate, e.g., because /proc is not
- readable, or the particular .../fd/N directory is not present. */
-#define EXPECTED_ERRNO(Errno) \
- ((Errno) == ENOTDIR || (Errno) == ENOENT \
- || (Errno) == EPERM || (Errno) == EACCES \
- || (Errno) == EOPNOTSUPP /* FreeBSD */)
+#include "openat-priv.h"
/* Solaris 10 has no function like this.
Create a subdirectory, FILE, with mode MODE, in the directory
diff --git a/lib/openat.c b/lib/openat.c
index 32424eb4f..1c6d6d728 100644
--- a/lib/openat.c
+++ b/lib/openat.c
@@ -25,47 +25,17 @@
#include <stdlib.h>
#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
-#include "alloca.h"
#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
-#include "intprops.h"
#include "save-cwd.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
-/* Set PROC_FD_FILENAME to the expansion of "/proc/self/fd/%d/%s" in
- alloca'd memory, using FD and FILE, respectively for %d and %s. */
-#define BUILD_PROC_NAME(Proc_fd_filename, Fd, File) \
- do \
- { \
- size_t filelen = strlen (File); \
- static const char procfd[] = "/proc/self/fd/%d/%s"; \
- /* Buffer for the file name we are going to use. It consists of \
- - the string /proc/self/fd/ \
- - the file descriptor number \
- - the file name provided. \
- The final NUL is included in the sizeof. \
- Subtract 4 to account for %d and %s. */ \
- size_t buflen = sizeof (procfd) - 4 + INT_STRLEN_BOUND (Fd) + filelen; \
- (Proc_fd_filename) = alloca (buflen); \
- snprintf ((Proc_fd_filename), buflen, procfd, (Fd), (File)); \
- } \
- while (0)
-
-/* Trying to access a BUILD_PROC_NAME file will fail on systems without
- /proc support, and even on systems *with* ProcFS support. Return
- nonzero if the failure may be legitimate, e.g., because /proc is not
- readable, or the particular .../fd/N directory is not present. */
-#define EXPECTED_ERRNO(Errno) \
- ((Errno) == ENOTDIR || (Errno) == ENOENT \
- || (Errno) == EPERM || (Errno) == EACCES \
- || (Errno) == EOPNOTSUPP /* FreeBSD */)
+#include "openat-priv.h"
/* Replacement for Solaris' openat function.
<http://www.google.com/search?q=openat+site:docs.sun.com>