access(2) System Calls Manual access(2) access, faccessat, faccessat2 - C (libc, -lc) #include int access(const char *path, int mode); #include /* AT_* */ #include int faccessat(int dirfd, const char *path, int mode, int flags); /* But see C library/kernel differences, below */ #include /* AT_* */ #include /* SYS_* */ #include int syscall(SYS_faccessat2, int dirfd, const char *path, int mode, int flags); glibc (. feature_test_macros(7)): faccessat(): glibc 2.10: _POSIX_C_SOURCE >= 200809L glibc 2.10: _ATFILE_SOURCE access() checks whether the calling process can access the file path. If path is a symbolic link, it is dereferenced. mode - ; F_OK, R_OK, W_OK X_OK. F_OK . R_OK, W_OK X_OK , , , . real (), () (UID) (GID) . (, open(2)). , root, , ; root- . set-user-ID (setuid) . access() << // ?>>. ( , setuid) : << the user who invoked me ( , ) // ?>>. set-user-ID , . (, UID 0), X_OK , , . faccessat() faccessat() , access(), , . If path is relative, then it is interpreted relative to the directory referred to by the file descriptor dirfd (rather than relative to the current working directory of the calling process, as is done by access() for a relative pathname). If path is relative and dirfd is the special value AT_FDCWD, then path is interpreted relative to the current working directory of the calling process (like access()). If path is absolute, then dirfd is ignored. flags : AT_EACCESS , . faccessat() ( access()). AT_EMPTY_PATH ( Linux 5.8) If path is an empty string, operate on the file referred to by dirfd (which may have been obtained using the open(2) O_PATH flag). In this case, dirfd can refer to any type of file, not just a directory. If dirfd is AT_FDCWD, the call operates on the current working directory. This flag is Linux-specific; define _GNU_SOURCE to obtain its definition. AT_SYMLINK_NOFOLLOW If path is a symbolic link, do not dereference it: instead return information about the link itself. openat(2) faccessat(). faccessat2() faccessat() POSIX.1 , glibc. glibc (. ""), , Linux faccessat() flags. , Linux 5.8 faccessat2(), flags - faccessat(). ( , mode - F_OK ), . ( , - , mode mode - F_OK , - ) -1 errno . EACCES The requested access would be denied to the file, or search permission is denied for one of the directories in the path prefix of path. (See also path_resolution(7).) EBADF (faccessat()) path is relative but dirfd is neither AT_FDCWD (faccessat()) nor a valid file descriptor. EFAULT path . EINVAL mode . EINVAL (faccessat()) flags. EIO -. ELOOP path . ENAMETOOLONG path . ENOENT A component of path does not exist or is a dangling symbolic link. ENOMEM . ENOTDIR A component used as a directory in path is not, in fact, a directory. ENOTDIR (faccessat()) path is relative and dirfd is a file descriptor referring to a file other than a directory. EPERM , . FS_IOC_SETFLAGS(const). EROFS , , . ETXTBSY , . (, ), POSIX.1-2001 X_OK, . Linux . C raw faccessat() . AT_EACCESS AT_SYMLINK_NOFOLLOW - glibc faccessat(). , - fstatat(2) , . glibc On older kernels where faccessat() is unavailable (and when the AT_EACCESS and AT_SYMLINK_NOFOLLOW flags are not specified), the glibc wrapper function falls back to the use of access(). When path is relative, glibc constructs a pathname based on the symbolic link in /proc/self/fd that corresponds to the dirfd argument. access() faccessat() POSIX.1-2008. faccessat2() Linux. access() SVr4, 4.3BSD, POSIX.1-2001. faccessat() Linux 2.6.16, glibc 2.4. faccessat2() Linux 5.8. Warning (): , , open(2), , . ( , open(2)). access() . , faccessat() AT_SYMLINK_NOFOLLOW. , mode, . A file is accessible only if the permissions on each of the directories in the path prefix of path grant search (i.e., execute) access. If any directory is inaccessible, then the access() call fails, regardless of the permissions on the file itself. , . , , , , , , , , . , DOS , execve(2) . access() NFSv2 UID, , ( NFS 3 ). FUSE. faccessat() Linux flags, - glibc faccessat(), glibc 2.32 , , faccessat() fstatat(2). . glibc 2.33, - , faccessat 2(), . Linux 2.4 ( ) X_OK . , , access(), -1, , mode X_OK; R_OK W_OK mode, access() 0 . Linux 2.6 ( Linux 2.6.3 ) , Linux 2.4. Linux 2.6.20 MS_NOEXEC, mount(2) . Linux 2.6.20, MS_NOEXEC . chmod(2), chown(2), open(2), setgid(2), setuid(2), stat(2), euidaccess(3), credentials(7), path_resolution(7), symlink(7) () Dmitry Bolkhovskikh , Yuri Kozlov , Aleksandr Felda Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.15 17 2025 . access(2)