1FSTATAT(2) Linux Programmer's Manual FSTATAT(2)
2
3
4
6 fstatat - get file status relative to a directory file descriptor
7
9 #include <fcntl.h> /* Definition of AT_* constants */
10 #include <sys/stat.h>
11
12 int fstatat(int dirfd, const char *pathname, struct stat *buf,
13 int flags);
14
15 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17 fstatat():
18 Since glibc 2.10:
19 _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
20 Before glibc 2.10:
21 _ATFILE_SOURCE
22
24 The fstatat() system call operates in exactly the same way as stat(2),
25 except for the differences described in this manual page.
26
27 If the pathname given in pathname is relative, then it is interpreted
28 relative to the directory referred to by the file descriptor dirfd
29 (rather than relative to the current working directory of the calling
30 process, as is done by stat(2) for a relative pathname).
31
32 If pathname is relative and dirfd is the special value AT_FDCWD, then
33 pathname is interpreted relative to the current working directory of
34 the calling process (like stat(2)).
35
36 If pathname is absolute, then dirfd is ignored.
37
38 flags can either be 0, or include one or more of the following flags
39 ORed:
40
41 AT_EMPTY_PATH (since Linux 2.6.39)
42 If pathname is an empty string, operate on the file referred to
43 by in which case the call operates on the file referred to by
44 dirfd (which may have been obtained using the open(2) O_PATH
45 flag). In this case, dirfd can refer to any type of file, not
46 just a directory.
47
48
49 AT_NO_AUTOMOUNT (since Linux 2.6.38)
50 Don't automount the terminal ("basename") component of pathname
51 if it is a directory that is an automount point. This allows
52 the caller to gather attributes of an automount point (rather
53 than the location it would mount). This flag can be used in
54 tools that scan directories to prevent mass-automounting of a
55 directory of automount points. The AT_NO_AUTOMOUNT flag has no
56 effect if the mount point has already been mounted over.
57
58 AT_SYMLINK_NOFOLLOW
59 If pathname is a symbolic link, do not dereference it: instead
60 return information about the link itself, like lstat(2). (By
61 default, fstatat() dereferences symbolic links, like stat(2).)
62
64 On success, fstatat() returns 0. On error, -1 is returned and errno is
65 set to indicate the error.
66
68 The same errors that occur for stat(2) can also occur for fstatat().
69 The following additional errors can occur for fstatat():
70
71 EBADF dirfd is not a valid file descriptor.
72
73 EINVAL Invalid flag specified in flags.
74
75 ENOTDIR
76 pathname is relative and dirfd is a file descriptor referring to
77 a file other than a directory.
78
80 fstatat() was added to Linux in kernel 2.6.16; library support was
81 added to glibc in version 2.4.
82
84 POSIX.1-2008. A similar system call exists on Solaris.
85
87 See openat(2) for an explanation of the need for fstatat().
88
89 The underlying system call employed by the glibc fstatat() wrapper
90 function is actually called fstatat64().
91
93 openat(2), stat(2), path_resolution(7), symlink(7)
94
96 This page is part of release 3.53 of the Linux man-pages project. A
97 description of the project, and information about reporting bugs, can
98 be found at http://www.kernel.org/doc/man-pages/.
99
100
101
102Linux 2013-07-21 FSTATAT(2)