Date: Sun, 05 Jun 2011 16:19:34 +0000 From: gk@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r222837 - in soc2011/gk/ino64-head: include lib/libc/gen Message-ID: <20110605161935.009AC1065670@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gk Date: Sun Jun 5 16:19:34 2011 New Revision: 222837 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=222837 Log: Replace dirfd() macro with exported libc symbol Use _dirfd() macro internally Added: soc2011/gk/ino64-head/lib/libc/gen/dirfd.c - copied, changed from r222836, soc2011/gk/ino64-head/lib/libc/gen/dirent-private.h Modified: soc2011/gk/ino64-head/include/dirent.h soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc soc2011/gk/ino64-head/lib/libc/gen/Symbol.map soc2011/gk/ino64-head/lib/libc/gen/dirent-private.h soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c soc2011/gk/ino64-head/lib/libc/gen/fts.c soc2011/gk/ino64-head/lib/libc/gen/getcwd.c Modified: soc2011/gk/ino64-head/include/dirent.h ============================================================================== --- soc2011/gk/ino64-head/include/dirent.h Sun Jun 5 16:19:18 2011 (r222836) +++ soc2011/gk/ino64-head/include/dirent.h Sun Jun 5 16:19:34 2011 (r222837) @@ -79,6 +79,7 @@ DIR *__opendir2(const char *, int); int getdents(int, char *, int); int getdirentries(int, char *, int, long *); +int dirfd(DIR *); #endif DIR *opendir(const char *); DIR *fdopendir(int); Modified: soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc Sun Jun 5 16:19:18 2011 (r222836) +++ soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc Sun Jun 5 16:19:34 2011 (r222837) @@ -9,7 +9,7 @@ _thread_init.c \ alarm.c arc4random.c assert.c aux.c basename.c check_utility_compat.c \ clock.c closedir.c confstr.c \ - crypt.c ctermid.c daemon.c devname.c dirname.c disklabel.c \ + crypt.c ctermid.c daemon.c devname.c dirfd.c dirname.c disklabel.c \ dlfcn.c drand48.c elf_utils.c erand48.c err.c errlst.c errno.c \ exec.c fdevname.c feature_present.c fmtcheck.c fmtmsg.c fnmatch.c \ fpclassify.c frexp.c fstab.c ftok.c fts.c fts-compat.c ftw.c \ Modified: soc2011/gk/ino64-head/lib/libc/gen/Symbol.map ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/Symbol.map Sun Jun 5 16:19:18 2011 (r222836) +++ soc2011/gk/ino64-head/lib/libc/gen/Symbol.map Sun Jun 5 16:19:34 2011 (r222837) @@ -359,6 +359,7 @@ FBSD_1.2 { basename_r; cfmakesane; + dirfd; endutxent; getpagesizes; getutxent; Modified: soc2011/gk/ino64-head/lib/libc/gen/dirent-private.h ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/dirent-private.h Sun Jun 5 16:19:18 2011 (r222836) +++ soc2011/gk/ino64-head/lib/libc/gen/dirent-private.h Sun Jun 5 16:19:34 2011 (r222837) @@ -49,6 +49,6 @@ struct _telldir *dd_td; /* telldir position recording */ }; -#define dirfd(dirp) ((dirp)->dd_fd) +#define _dirfd(dirp) ((dirp)->dd_fd) #endif /* !_DIRENT_PRIVATE_H_ */ Copied and modified: soc2011/gk/ino64-head/lib/libc/gen/dirfd.c (from r222836, soc2011/gk/ino64-head/lib/libc/gen/dirent-private.h) ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/dirent-private.h Sun Jun 5 16:19:18 2011 (r222836, copy source) +++ soc2011/gk/ino64-head/lib/libc/gen/dirfd.c Sun Jun 5 16:19:34 2011 (r222837) @@ -29,26 +29,22 @@ * $FreeBSD$ */ -#ifndef _DIRENT_PRIVATE_H_ -#define _DIRENT_PRIVATE_H_ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); -struct _telldir; /* see telldir.h */ -struct pthread_mutex; +#include "namespace.h" +#include <sys/param.h> -/* structure describing an open directory. */ -struct _dirdesc { - int dd_fd; /* file descriptor associated with directory */ - long dd_loc; /* offset in current buffer */ - long dd_size; /* amount of data returned by getdirentries */ - char *dd_buf; /* data buffer */ - int dd_len; /* size of data buffer */ - long dd_seek; /* magic cookie returned by getdirentries */ - long dd_rewind; /* magic cookie for rewinding */ - int dd_flags; /* flags for readdir */ - struct pthread_mutex *dd_lock; /* lock */ - struct _telldir *dd_td; /* telldir position recording */ -}; +#include <dirent.h> +#include "un-namespace.h" -#define dirfd(dirp) ((dirp)->dd_fd) +#include "dirent-private.h" -#endif /* !_DIRENT_PRIVATE_H_ */ +int +dirfd(DIR *dirp) +{ + if (dirp == NULL) + return (-1); + + return (_dirfd(dirp)); +} Modified: soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c Sun Jun 5 16:19:18 2011 (r222836) +++ soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c Sun Jun 5 16:19:34 2011 (r222837) @@ -713,7 +713,7 @@ */ cderrno = 0; if (nlinks || type == BREAD) { - if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { + if (fts_safe_changedir(sp, cur, _dirfd(dirp), NULL)) { if (nlinks && type == BREAD) cur->fts_errno = errno; cur->fts_flags |= FTS_DONTCHDIR; Modified: soc2011/gk/ino64-head/lib/libc/gen/fts.c ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/fts.c Sun Jun 5 16:19:18 2011 (r222836) +++ soc2011/gk/ino64-head/lib/libc/gen/fts.c Sun Jun 5 16:19:34 2011 (r222837) @@ -710,7 +710,7 @@ */ cderrno = 0; if (nlinks || type == BREAD) { - if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { + if (fts_safe_changedir(sp, cur, _dirfd(dirp), NULL)) { if (nlinks && type == BREAD) cur->fts_errno = errno; cur->fts_flags |= FTS_DONTCHDIR; Modified: soc2011/gk/ino64-head/lib/libc/gen/getcwd.c ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/getcwd.c Sun Jun 5 16:19:18 2011 (r222836) +++ soc2011/gk/ino64-head/lib/libc/gen/getcwd.c Sun Jun 5 16:19:34 2011 (r222837) @@ -119,7 +119,7 @@ for (first = 1;; first = 0) { /* Stat the current level. */ - if (dir != NULL ? _fstat(dirfd(dir), &s) : lstat(".", &s)) + if (dir != NULL ? _fstat(_dirfd(dir), &s) : lstat(".", &s)) goto err; /* Save current node values. */ @@ -141,13 +141,13 @@ } /* Open and stat parent directory. */ - fd = _openat(dir != NULL ? dirfd(dir) : AT_FDCWD, + fd = _openat(dir != NULL ? _dirfd(dir) : AT_FDCWD, "..", O_RDONLY); if (fd == -1) goto err; if (dir) (void) closedir(dir); - if (!(dir = fdopendir(fd)) || _fstat(dirfd(dir), &s)) { + if (!(dir = fdopendir(fd)) || _fstat(_dirfd(dir), &s)) { _close(fd); goto err; } @@ -173,7 +173,7 @@ continue; /* Save the first error for later. */ - if (fstatat(dirfd(dir), dp->d_name, &s, + if (fstatat(_dirfd(dir), dp->d_name, &s, AT_SYMLINK_NOFOLLOW)) { if (!save_errno) save_errno = errno;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110605161935.009AC1065670>