chmod(2) System Calls Manual chmod(2) chmod, fchmod, fchmodat - LIBRARY Standard C library (libc, -lc) #include int chmod(const char *pathname, mode_t mode); int fchmod(int fd, mode_t mode); #include /* AT_* */ #include int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags); glibc (. feature_test_macros(7)): fchmod(): Since glibc 2.24: _POSIX_C_SOURCE >= 199309L glibc 2.19 to glibc 2.23 _POSIX_C_SOURCE glibc 2.16 to glibc 2.19: _BSD_SOURCE || _POSIX_C_SOURCE glibc 2.12 to glibc 2.16: _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L glibc 2.11 and earlier: _BSD_SOURCE || _XOPEN_SOURCE >= 500 fchmodat(): glibc 2.10: _POSIX_C_SOURCE >= 200809L glibc 2.10: _ATFILE_SOURCE chmod() fchmod() ( set-user-ID, set-group-ID ) : o chmod() , pathname, , . o fchown() , fd. mode , : S_ISUID (04000) set-user-ID ( execve(2)) S_ISGID (02000) set-group-ID ( execve(2); , fcntl(2); , chown(2) mkdir(2)) S_ISVTX (01000) ( , unlink(2)) S_IRUSR (00400) S_IWUSR (00200) S_IXUSR (00100) ("" , ) S_IRGRP (00040) - S_IWGRP (00020) - S_IXGRP (00010) - S_IROTH (00004) S_IWOTH (00002) S_IXOTH (00001) (UID) UID (Linux: CAP_FOWNER). (Linux: CAP_FSETID), - ID , S_ISGID , . set-user-ID set-group-ID ( Linux , CAP_FSETID). , . , set-user-ID set-group-ID inode(7). NFS , , . , . fchmodat() fchmodat() chmod(), , . pathname , , dirfd ( , chmod()). pathname dirfd AT_FDCWD, pathname ( chmod()). pathname , dirfd . flags 0, : AT_SYMLINK_NOFOLLOW pathname , , . . openat(2) fchmodat(). On success, zero is returned. On error, -1 is returned, and errno is set to indicate the error. , . chmod() : EACCES - (. path_resolution(7).) EBADF (fchmod()) fd . EBADF (fchmodat()) pathname is relative but dirfd is neither AT_FDCWD nor a valid file descriptor. EFAULT pathname . EINVAL (fchmodat()) flags. EIO -. ELOOP pathname . ENAMETOOLONG pathname. ENOENT . ENOMEM . ENOTDIR . ENOTDIR (fchmodat()) pathname dirfd , , . ENOTSUP (fchmodat()) flags AT_SYMLINK_NOFOLLOW, . EPERM UID , (Linux: CAP_FOWNER). EPERM (immutable) ( ioctl_iflags(2)). EROFS , . C fchmodat() GNU C, POSIX-. Linux , flags. glibc , fchmodat() , glibc chmod(). pathname , glibc /proc/self/fd, dirfd. POSIX.1-2008. chmod() fchmod() 4.4BSD, SVr4, POSIX.1-2001. fchmodat() POSIX.1-2008. Linux 2.6.16, glibc 2.4. . chmod(1), chown(2), execve(2), open(2), stat(2), inode(7), path_resolution(7), symlink(7) Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , Katrin Kutepova , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . chmod(2)