fchmod - change mode of a file
#include <sys/stat.h>
int fchmod(int fildes, mode_t mode);
The fchmod() function shall be equivalent to chmod() except that the file whose permissions are changed is specified by the file descriptor fildes.
If 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.
If fildes references a typed memory object, the behavior of fchmod() is unspecified.
If fildes refers to a socket, the behavior of fchmod() is unspecified.
If fildes refers to a STREAM (which is fattach()-ed into the file system name space) the call returns successfully, doing nothing.
Upon successful completion, fchmod() shall return 0. Otherwise, it shall return -1 and set errno to indicate the error.
The fchmod() function shall fail if:
The fchmod() function may fail if:
The following sections are informative.
The following example shows how to change the permissions for a file named /home/cnd/mod1 so that the owner and group have read/write/execute permissions, but the world only has read/write permissions.
#include <sys/stat.h>
#include <fcntl.h>
mode_t mode;
int fildes;
...
fildes = open("/home/cnd/mod1", O_RDWR);
fchmod(fildes, S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH);
chmod() , chown() , creat() , fcntl() , fstatvfs() , mknod() , open() , read() , stat() , write() , the Base Definitions volume of IEEE Std 1003.1-2001, <sys/stat.h>
|
Закладки на сайте Проследить за страницей |
Created 1996-2025 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |