X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Ffchdir.c;h=969e984c9555b11a95f3e411f15a0ff6bdc581bd;hb=fa3486514bd8f15f8eb4c49821d0356b52e5a335;hp=7a30448fb0380a832360d278ef6cecb0901f5509;hpb=1e60b920564d9b30c65c53553a4293b1c76863d8;p=gnulib.git diff --git a/lib/fchdir.c b/lib/fchdir.c index 7a30448fb..969e984c9 100644 --- a/lib/fchdir.c +++ b/lib/fchdir.c @@ -19,6 +19,7 @@ /* Specification. */ #include +#include #include #include #include @@ -26,10 +27,8 @@ #include #include #include -#include #include "canonicalize.h" -#include "dirfd.h" /* This replacement assumes that a directory is not renamed while opened through a file descriptor. */ @@ -105,52 +104,6 @@ _gl_register_fd (int fd, const char *filename) } } -/* Override open() and close(), to keep track of the open file descriptors. */ - -int -rpl_close (int fd) -#undef close -{ - int retval = close (fd); - - if (retval >= 0) - _gl_unregister_fd (fd); - return retval; -} - -int -rpl_open (const char *filename, int flags, ...) -#undef open -{ - mode_t mode; - int fd; - struct stat statbuf; - - mode = 0; - if (flags & O_CREAT) - { - va_list arg; - va_start (arg, flags); - - /* If mode_t is narrower than int, use the promoted type (int), - not mode_t. Use sizeof to guess whether mode_t is narrower; - we don't know of any practical counterexamples. */ - mode = (sizeof (mode_t) < sizeof (int) - ? va_arg (arg, int) - : va_arg (arg, mode_t)); - - va_end (arg); - } -#if defined GNULIB_OPEN && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) - if (strcmp (filename, "/dev/null") == 0) - filename = "NUL"; -#endif - fd = open (filename, flags, mode); - if (fd >= 0) - _gl_register_fd (fd, filename); - return fd; -} - /* Override opendir() and closedir(), to keep track of the open file descriptors. Needed because there is a function dirfd(). */