StudyingUnixInterface/4/fileDirectory/chmod.c
2020-12-07 12:17:01 +08:00

23 lines
408 B
C

#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#define RWRWRW S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
#define RWRR S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
int main(void){
int fd = open("./test/test2", O_RDWR);
if(fd == -1){
printf("open file test1 error\n");
}
fchmod(fd, RWRWRW);
close(fd);
chmod("./test/test1", RWRR);
return 0;
}