怎么样int chmod(const char *path, mode_t mode)
和int fchmod(int fd, mode_t mode) ?
apropos chmod
man 2 chmod
Run Code Online (Sandbox Code Playgroud)
最基本的例子:
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
char * fpath = "/path/to/binary";
int ret=0;
if(ret = chmod(fpath, S_IRUSR|S_IXUSR) < 0){
perror("chmod failed");
exit(1);
}
printf("chmod ok\n");
exit(0);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1021 次 |
最近记录: |