Mercurial > hg > octave-kai > gnulib-hg
annotate lib/openat-priv.h @ 7151:43e3888c56c4
Update from coreutils.
* lib/__fpending.h: Add copyright notice.
* lib/fprintftime.h: Likewise.
* lib/savedir.c: Use (C) in copyright notice.
* lib/savedir.h: Likewise.
2006-08-15 Jim Meyering <jim@meyering.net>
* lib/at-func.c: New file, with the logic of all emulated at-functions.
* lib/openat-priv.h: Include <errno.h> and define ENOSYS,
in support of the EXPECTED_ERRNO macro.
* lib/openat.c (fstatat, unlinkat, fchownat): Remove function definitions.
Instead, define the appropriate symbols and include "at-func.c".
* lib/mkdirat.c (mkdirat): Likewise.
* lib/fchmodat.c (fchmodat): Likewise.
(ENOSYS): Remove definition.
* lib/openat.c: Don't include <errno.h>, now that "openat-priv.h" does it.
Don't include "unistd--.h" -- it wasn't ever used.
2006-01-17 Jim Meyering <jim@meyering.net>
Rewrite fts.c not to change the current working directory,
by using openat, fstatat, fdopendir, etc..
* lib/fts.c [! _LIBC]: Include "openat.h" and "unistd--.h".
(HAVE_OPENAT_SUPPORT): Define.
[_LIBC] (fchdir): Don't undef or define; no longer used.
(FCHDIR): Define in terms of cwd_advance_fd rather than fchdir.
Now, this `function' always succeeds, and consumes its file descriptor
parameter -- so callers must not close such FDs. Update callers.
(diropen_fd, opendirat, cwd_advance_fd): New functions.
(diropen): Add parameter, SP. Adjust all callers.
Implement using diropen_fd, rather than open.
(fts_open): Initialize new member, fts_cwd_fd.
Remove fts_rft-setting code.
(fts_close): Close fts_cwd_fd, if necessary.
(__opendir2): Define in terms of opendir or opendirat,
depending on whether the FST_NOCHDIR flag is set.
(fts_build): Since fts_safe_changedir consumes its FD, and since
this code must do `closedir(dirp)', dup the dirfd(dirp) argument,
and close the dup'd file descriptor upon failure.
(fts_stat): Use fstatat(...AT_SYMLINK_NOFOLLOW) in place of lstat.
(fts_safe_changedir): Tweak semantics to reflect that this function
now calls cwd_advance_fd and hence consumes its FD argument.
* lib/fts_.h [struct FTS] (fts_cwd_fd): New member.
[struct FTS] (fts_rft): Remove now-unused member.
[struct FTS] (fts_cycle.state): Improve comment.
* lib/openat.c (openat_needs_fchdir): New function.
* lib/openat.h (openat_needs_fchdir): Declare it.
2006-08-15 Jim Meyering <jim@meyering.net>
* m4/openat.m4 (gl_FUNC_OPENAT): Add at-func.c via AC_LIBSOURCES.
2006-01-17 Jim Meyering <jim@meyering.net>
* m4/fts.m4 (gl_FUNC_FTS_CORE): Depend on gl_FUNC_OPENAT.
2006-01-11 Jim Meyering <jim@meyering.net>
* m4/openat.m4 (gl_FUNC_OPENAT): Require and compile fchmodat.c.
Check for the lchmod function.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 17 Aug 2006 20:34:21 +0000 |
parents | 6b31c8787689 |
children | 0f8d70c02f29 |
rev | line source |
---|---|
6527 | 1 /* macros used by openat-like functions |
2 Copyright (C) 2005 Free Software Foundation, Inc. | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software Foundation, | |
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
17 | |
18 /* written by Jim Meyering */ | |
19 | |
20 #include <stdio.h> | |
21 #include <string.h> | |
7151 | 22 #include <errno.h> |
6527 | 23 #include "alloca.h" |
24 #include "intprops.h" | |
25 | |
26 /* Set PROC_FD_FILENAME to the expansion of "/proc/self/fd/%d/%s" in | |
27 alloca'd memory, using FD and FILE, respectively for %d and %s. */ | |
28 #define BUILD_PROC_NAME(Proc_fd_filename, Fd, File) \ | |
29 do \ | |
30 { \ | |
31 size_t filelen = strlen (File); \ | |
32 static const char procfd[] = "/proc/self/fd/%d/%s"; \ | |
33 /* Buffer for the file name we are going to use. It consists of \ | |
34 - the string /proc/self/fd/ \ | |
35 - the file descriptor number \ | |
36 - the file name provided. \ | |
37 The final NUL is included in the sizeof. \ | |
38 Subtract 4 to account for %d and %s. */ \ | |
39 size_t buflen = sizeof (procfd) - 4 + INT_STRLEN_BOUND (Fd) + filelen; \ | |
40 (Proc_fd_filename) = alloca (buflen); \ | |
41 snprintf ((Proc_fd_filename), buflen, procfd, (Fd), (File)); \ | |
42 } \ | |
43 while (0) | |
44 | |
7151 | 45 /* Some systems don't have ENOSYS. */ |
46 #ifndef ENOSYS | |
47 # ifdef ENOTSUP | |
48 # define ENOSYS ENOTSUP | |
49 # else | |
50 /* Some systems don't have ENOTSUP either. */ | |
51 # define ENOSYS EINVAL | |
52 # endif | |
53 #endif | |
54 | |
6527 | 55 /* Trying to access a BUILD_PROC_NAME file will fail on systems without |
56 /proc support, and even on systems *with* ProcFS support. Return | |
57 nonzero if the failure may be legitimate, e.g., because /proc is not | |
58 readable, or the particular .../fd/N directory is not present. */ | |
59 #define EXPECTED_ERRNO(Errno) \ | |
60 ((Errno) == ENOTDIR || (Errno) == ENOENT \ | |
61 || (Errno) == EPERM || (Errno) == EACCES \ | |
62 || (Errno) == ENOSYS /* Solaris 8 */ \ | |
63 || (Errno) == EOPNOTSUPP /* FreeBSD */) |