Mercurial > hg > octave-shane > gnulib-hg
annotate lib/openat.h @ 16023:dc33aa820898
New module 'fstatat', split off from module 'openat'.
* lib/openat.h (statat, lstatat): Enable only if GNULIB_FSTATAT is
defined.
* m4/fstatat.m4: New file. extracted from m4/openat.m4.
* m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_FSTATAT. Don't invoke
gl_FUNC_FSTATAT.
(gl_FUNC_FSTATAT): Moved to m4/fstatat.m4.
* modules/fstatat: New file, extracted from modules/openat.
* modules/openat (Files): Remove lib/fstatat.c.
(Depends-on): Remove lstat.
(configure.ac): Remove AC_LIBOBJ of fstatat.
* modules/fstatat-tests: New file, extracted from modules/openat-tests.
* modules/openat-tests (Files): Remove tests/test-fstatat.c,
tests/test-lstat.h, tests/test-stat.h.
(Depends-on): Remove getcwd-lgpl.
(Makefile.am): Remove rules for test-fstatat.
* doc/posix-functions/fstatat.texi: Mention module 'fstatat' instead
of module 'openat'.
* NEWS: Mention the change.
* modules/getcwd (Depends-on): Add fstatat.
* modules/linkat (Depends-on): Likewise.
* modules/mkfifoat-tests (Depends-on): Likewise.
* modules/utimensat (Depends-on): Add fstatat. Remove openat.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 03 Nov 2011 12:03:53 +0100 |
parents | ab92e00caa02 |
children | 1ae8bbf66d04 |
rev | line source |
---|---|
5588
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
1 /* provide a replacement openat function |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13765
diff
changeset
|
2 Copyright (C) 2004-2006, 2008-2011 Free Software Foundation, Inc. |
5588
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7677
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
5588
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7677
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7677
diff
changeset
|
7 (at your option) any later version. |
5588
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
8 |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
13 |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7677
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
5588
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
16 |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
17 /* written by Jim Meyering */ |
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
18 |
11937 | 19 #ifndef _GL_HEADER_OPENAT |
20 #define _GL_HEADER_OPENAT | |
21 | |
15582 | 22 #include <fcntl.h> |
5588
14b330875e48
* modules/chdir-long, modules/openat: New files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
23 |
5609
84f75cbb306a
* modules/chdir-long (Depends-on): Remove mempcpy.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5588
diff
changeset
|
24 #include <sys/types.h> |
84f75cbb306a
* modules/chdir-long (Depends-on): Remove mempcpy.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5588
diff
changeset
|
25 #include <sys/stat.h> |
84f75cbb306a
* modules/chdir-long (Depends-on): Remove mempcpy.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5588
diff
changeset
|
26 #include <dirent.h> |
84f75cbb306a
* modules/chdir-long (Depends-on): Remove mempcpy.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5588
diff
changeset
|
27 #include <unistd.h> |
6527 | 28 #include <stdbool.h> |
6272
3baa574549ae
* modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5955
diff
changeset
|
29 |
11942
d1047ae4b8d5
openat: declare in POSIX headers
Eric Blake <ebb9@byu.net>
parents:
11937
diff
changeset
|
30 #if !HAVE_OPENAT |
6647
ca74ccfe8d1b
* getcwd.c (AT_FDCWD): Work around a bug in Solaris 9 and 10, where
Paul Eggert <eggert@cs.ucla.edu>
parents:
6527
diff
changeset
|
31 |
6527 | 32 int openat_permissive (int fd, char const *file, int flags, mode_t mode, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11969
diff
changeset
|
33 int *cwd_errno); |
7151 | 34 bool openat_needs_fchdir (void); |
6527 | 35 |
36 #else | |
37 | |
38 # define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \ | |
39 openat (Fd, File, Flags, Mode) | |
7151 | 40 # define openat_needs_fchdir() false |
6527 | 41 |
42 #endif | |
43 | |
15412
7f0f3e1ac6fd
stdnoreturn, stdnoreturn-tests: remove modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
15404
diff
changeset
|
44 _Noreturn void openat_restore_fail (int); |
7f0f3e1ac6fd
stdnoreturn, stdnoreturn-tests: remove modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
15404
diff
changeset
|
45 _Noreturn void openat_save_fail (int); |
7151 | 46 |
47 /* Using these function names makes application code | |
48 slightly more readable than it would be with | |
49 fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */ | |
16012
fb7a82c2a615
New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
15582
diff
changeset
|
50 |
fb7a82c2a615
New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
15582
diff
changeset
|
51 #if GNULIB_FCHOWNAT |
fb7a82c2a615
New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
15582
diff
changeset
|
52 |
7151 | 53 static inline int |
54 chownat (int fd, char const *file, uid_t owner, gid_t group) | |
55 { | |
56 return fchownat (fd, file, owner, group, 0); | |
57 } | |
58 | |
59 static inline int | |
60 lchownat (int fd, char const *file, uid_t owner, gid_t group) | |
61 { | |
62 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW); | |
63 } | |
64 | |
16012
fb7a82c2a615
New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
15582
diff
changeset
|
65 #endif |
fb7a82c2a615
New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
15582
diff
changeset
|
66 |
16021
ab92e00caa02
New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16012
diff
changeset
|
67 #if GNULIB_FCHMODAT |
ab92e00caa02
New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16012
diff
changeset
|
68 |
7151 | 69 static inline int |
70 chmodat (int fd, char const *file, mode_t mode) | |
71 { | |
72 return fchmodat (fd, file, mode, 0); | |
73 } | |
74 | |
75 static inline int | |
76 lchmodat (int fd, char const *file, mode_t mode) | |
77 { | |
78 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW); | |
79 } | |
11937 | 80 |
16021
ab92e00caa02
New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16012
diff
changeset
|
81 #endif |
ab92e00caa02
New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16012
diff
changeset
|
82 |
16023
dc33aa820898
New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16021
diff
changeset
|
83 #if GNULIB_FSTATAT |
dc33aa820898
New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16021
diff
changeset
|
84 |
11969
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
85 static inline int |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
86 statat (int fd, char const *name, struct stat *st) |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
87 { |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
88 return fstatat (fd, name, st, 0); |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
89 } |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
90 |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
91 static inline int |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
92 lstatat (int fd, char const *name, struct stat *st) |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
93 { |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
94 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW); |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
95 } |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
96 |
16023
dc33aa820898
New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16021
diff
changeset
|
97 #endif |
dc33aa820898
New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents:
16021
diff
changeset
|
98 |
11969
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
99 /* For now, there are no wrappers named laccessat or leuidaccessat, |
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
100 since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and |
13765
9ef7abcf9136
faccessat: remove unused wrappers
Eric Blake <eblake@redhat.com>
parents:
12559
diff
changeset
|
101 since access rights on symlinks are of limited utility. Likewise, |
9ef7abcf9136
faccessat: remove unused wrappers
Eric Blake <eblake@redhat.com>
parents:
12559
diff
changeset
|
102 wrappers are not provided for accessat or euidaccessat, so as to |
9ef7abcf9136
faccessat: remove unused wrappers
Eric Blake <eblake@redhat.com>
parents:
12559
diff
changeset
|
103 avoid dragging in -lgen on some platforms. */ |
11969
25d12bf7e5bf
openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents:
11942
diff
changeset
|
104 |
11937 | 105 #endif /* _GL_HEADER_OPENAT */ |