annotate lib/openat.h @ 17255:d81be792518a

update from texinfo
author Karl Berry <karl@freefriends.org>
date Tue, 01 Jan 2013 15:51:49 -0800
parents e542fd46ad6f
children d536543d59a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 17099
diff changeset
2 Copyright (C) 2004-2006, 2008-2013 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
ded3ad24a7f4 openat-safer: new module
Eric Blake <ebb9@byu.net>
parents: 11934
diff changeset
19 #ifndef _GL_HEADER_OPENAT
ded3ad24a7f4 openat-safer: new module
Eric Blake <ebb9@byu.net>
parents: 11934
diff changeset
20 #define _GL_HEADER_OPENAT
ded3ad24a7f4 openat-safer: new module
Eric Blake <ebb9@byu.net>
parents: 11934
diff changeset
21
15582
c5fde8111cd7 Revert last commit.
Bruno Haible <bruno@clisp.org>
parents: 15581
diff changeset
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 <unistd.h>
6527
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
27 #include <stdbool.h>
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5955
diff changeset
28
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
29 _GL_INLINE_HEADER_BEGIN
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
30
11942
d1047ae4b8d5 openat: declare in POSIX headers
Eric Blake <ebb9@byu.net>
parents: 11937
diff changeset
31 #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
32
6527
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
33 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
34 int *cwd_errno);
7151
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
35 bool openat_needs_fchdir (void);
6527
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
36
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
37 #else
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
38
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
39 # define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
40 openat (Fd, File, Flags, Mode)
7151
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
41 # define openat_needs_fchdir() false
6527
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
42
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
43 #endif
6b31c8787689 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
44
15412
7f0f3e1ac6fd stdnoreturn, stdnoreturn-tests: remove modules
Paul Eggert <eggert@cs.ucla.edu>
parents: 15404
diff changeset
45 _Noreturn void openat_restore_fail (int);
7f0f3e1ac6fd stdnoreturn, stdnoreturn-tests: remove modules
Paul Eggert <eggert@cs.ucla.edu>
parents: 15404
diff changeset
46 _Noreturn void openat_save_fail (int);
7151
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
47
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
48 /* Using these function names makes application code
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
49 slightly more readable than it would be with
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
50 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
51
fb7a82c2a615 New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 15582
diff changeset
52 #if GNULIB_FCHOWNAT
fb7a82c2a615 New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 15582
diff changeset
53
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
54 # ifndef FCHOWNAT_INLINE
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
55 # define FCHOWNAT_INLINE _GL_INLINE
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
56 # endif
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
57
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
58 FCHOWNAT_INLINE int
7151
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
59 chownat (int fd, char const *file, uid_t owner, gid_t group)
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
60 {
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
61 return fchownat (fd, file, owner, group, 0);
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
62 }
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
63
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
64 FCHOWNAT_INLINE int
7151
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
65 lchownat (int fd, char const *file, uid_t owner, gid_t group)
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
66 {
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
67 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
68 }
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
69
16012
fb7a82c2a615 New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 15582
diff changeset
70 #endif
fb7a82c2a615 New module 'fchownat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 15582
diff changeset
71
16021
ab92e00caa02 New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16012
diff changeset
72 #if GNULIB_FCHMODAT
ab92e00caa02 New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16012
diff changeset
73
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
74 # ifndef FCHMODAT_INLINE
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
75 # define FCHMODAT_INLINE _GL_INLINE
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
76 # endif
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
77
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
78 FCHMODAT_INLINE int
7151
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
79 chmodat (int fd, char const *file, mode_t mode)
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
80 {
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
81 return fchmodat (fd, file, mode, 0);
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
82 }
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
83
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
84 FCHMODAT_INLINE int
7151
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
85 lchmodat (int fd, char const *file, mode_t mode)
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
86 {
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
87 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
43e3888c56c4 Update from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 6647
diff changeset
88 }
11937
ded3ad24a7f4 openat-safer: new module
Eric Blake <ebb9@byu.net>
parents: 11934
diff changeset
89
16021
ab92e00caa02 New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16012
diff changeset
90 #endif
ab92e00caa02 New module 'fchmodat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16012
diff changeset
91
16023
dc33aa820898 New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16021
diff changeset
92 #if GNULIB_FSTATAT
dc33aa820898 New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16021
diff changeset
93
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
94 # ifndef FSTATAT_INLINE
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
95 # define FSTATAT_INLINE _GL_INLINE
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
96 # endif
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
97
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
98 FSTATAT_INLINE int
11969
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
99 statat (int fd, char const *name, struct stat *st)
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
100 {
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
101 return fstatat (fd, name, st, 0);
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
102 }
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
103
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
104 FSTATAT_INLINE int
11969
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
105 lstatat (int fd, char const *name, struct stat *st)
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
106 {
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
107 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
108 }
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
109
16023
dc33aa820898 New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16021
diff changeset
110 #endif
dc33aa820898 New module 'fstatat', split off from module 'openat'.
Bruno Haible <bruno@clisp.org>
parents: 16021
diff changeset
111
11969
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
112 /* 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
113 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
114 since access rights on symlinks are of limited utility. Likewise,
9ef7abcf9136 faccessat: remove unused wrappers
Eric Blake <eblake@redhat.com>
parents: 12559
diff changeset
115 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
116 avoid dragging in -lgen on some platforms. */
11969
25d12bf7e5bf openat: provide more convenience names
Eric Blake <ebb9@byu.net>
parents: 11942
diff changeset
117
17099
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
118 _GL_INLINE_HEADER_END
66fafd5c6640 fchmodat, fchownat, fstatat: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
119
11937
ded3ad24a7f4 openat-safer: new module
Eric Blake <ebb9@byu.net>
parents: 11934
diff changeset
120 #endif /* _GL_HEADER_OPENAT */