fchmod - change mode of a file
#include <sys/stat.h> int fchmod(int fildes, mode_t mode);
The fchmod() function has the same effect as chmod() except that the file whose permissions are to be changed is specified by the file descriptor fildes.If the Shared Memory Objects option is supported, and fildes references a shared memory object, the fchmod() function need only affect the S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH file permission bits.
Upon successful completion, fchmod() returns 0. Otherwise, it returns -1 and sets errno to indicate the error.
The fchmod() function will fail if:
- [EBADF]
- The fildes argument is not an open file descriptor.
- [EPERM]
- The effective user ID does not match the owner of the file and the process does not have appropriate privilege.
- [EROFS]
- The file referred to by fildes resides on a read-only file system.
The fchmod() function may fail if:
- [EINTR]
- The fchmod() function was interrupted by a signal.
- [EINVAL]
- The value of the mode argument is invalid.
- [EINVAL]
- The fildes argument refers to a pipe and the implementation disallows execution of fchmod() on a pipe.
None.
None.
None.
chmod(), chown(), creat(), fcntl(), fstatvfs(), mknod(), open(), read(), stat(), write(), <sys/stat.h>.