程序源码
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc,char *argv[])
{
int fd,ret;
if(argc < 3){
printf("\nPlease input file path \n");
return 1;
}
//chmod test
ret = chmod(argv[1],0777);
if(ret < 0){
printf("Please make sure file path\n");
return 1;
}
printf("chmod %s is success!\n",argv[1]);
//fchmod test
fd = open(argv[2],O_RDWR|O_NOCTTY|O_NDELAY);
if(fd < 0){
printf("Please make sure file path\n");
return 1;
}
ret = fchmod(fd,0555);
if(ret){
printf("Please make sure file path\n");
return 1;
}
printf("fchmod %s is success!\n",argv[2]);
return 0;
}