VirtualBox

source: kBuild/vendor/grep/2.12/lib/openat.h@ 3576

Last change on this file since 3576 was 2595, checked in by bird, 13 years ago

gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1/* provide a replacement openat function
2 Copyright (C) 2004-2006, 2008-2012 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 3 of the License, or
7 (at your option) 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, see <http://www.gnu.org/licenses/>. */
16
17/* written by Jim Meyering */
18
19#ifndef _GL_HEADER_OPENAT
20#define _GL_HEADER_OPENAT
21
22#include <fcntl.h>
23
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <unistd.h>
27#include <stdbool.h>
28
29#if !HAVE_OPENAT
30
31int openat_permissive (int fd, char const *file, int flags, mode_t mode,
32 int *cwd_errno);
33bool openat_needs_fchdir (void);
34
35#else
36
37# define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
38 openat (Fd, File, Flags, Mode)
39# define openat_needs_fchdir() false
40
41#endif
42
43_Noreturn void openat_restore_fail (int);
44_Noreturn void openat_save_fail (int);
45
46/* Using these function names makes application code
47 slightly more readable than it would be with
48 fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */
49
50#if GNULIB_FCHOWNAT
51
52static inline int
53chownat (int fd, char const *file, uid_t owner, gid_t group)
54{
55 return fchownat (fd, file, owner, group, 0);
56}
57
58static inline int
59lchownat (int fd, char const *file, uid_t owner, gid_t group)
60{
61 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
62}
63
64#endif
65
66#if GNULIB_FCHMODAT
67
68static inline int
69chmodat (int fd, char const *file, mode_t mode)
70{
71 return fchmodat (fd, file, mode, 0);
72}
73
74static inline int
75lchmodat (int fd, char const *file, mode_t mode)
76{
77 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
78}
79
80#endif
81
82#if GNULIB_FSTATAT
83
84static inline int
85statat (int fd, char const *name, struct stat *st)
86{
87 return fstatat (fd, name, st, 0);
88}
89
90static inline int
91lstatat (int fd, char const *name, struct stat *st)
92{
93 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
94}
95
96#endif
97
98/* For now, there are no wrappers named laccessat or leuidaccessat,
99 since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
100 since access rights on symlinks are of limited utility. Likewise,
101 wrappers are not provided for accessat or euidaccessat, so as to
102 avoid dragging in -lgen on some platforms. */
103
104#endif /* _GL_HEADER_OPENAT */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette