chmod权限

使用命令"man 2 chmod"学习chmod函数
• int chmod(const char *path, mode_t mode);
– 参数*path:文件路径。
– 参数mode:直接使用数字即可。和前面命令中chmod 777 xxx 中的777 这
个参数含义类似,也可以使用文档中的组合值。
– 返回值:成功返回0,错误返回-1

• int fchmod(int fd, mode_t mode);
– 参数fd:文件描述符。
– 参数mode:直接使用数字即可。和前面命令中chmod 777 xxx 中的777 这
个参数含义类似,也可以使用文档中的组合值。
– 返回值:成功返回0,错误返回-1

#include <sys/stat.h>

#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h> int main(int argc, char *argv[])
{
int fd, ret; if(argc < ) {
printf("\nPlease input file apth \n");
return ;
} //chmod test
ret = chmod(argv[], );
if(ret < ) {
printf("Please makes sure file path\n");
return ;
}
printf("chmod %s is success.\n", argv[]); //fchmod test
fd = open(argv[], O_RDWR|O_NOCTTY|O_NDELAY);
if(fd < ) {
printf("Please makes sure file path\n");
return ;
}
ret = fchmod(fd, );
if(ret) {
printf("Please makes sure file path\n");
return ;
}
printf("fchmod %s is success.\n", argv[]); return ;
}

最新文章

  1. ajax回调打开新窗体防止浏览器拦截有效方法
  2. Jrebel是一套开发环境,用来实现热部署
  3. 处理返回结果(XML)
  4. informatica 常见问题及解决方案
  5. linux修改系统时间和linux查看时区、修改时区的方法
  6. Linux中与环境变量相关的函数
  7. WindowsApi 解压缩文件
  8. uva 11538 Chess Queen&lt;计数&gt;
  9. acess() 判断目录是否存在
  10. 快速学习bootstrap前台框架
  11. 打败Google的灵童今在何方?
  12. 【BZOJ 2453|bzoj 2120】 2453: 维护队列 (分块+二分)
  13. JZ2440开发笔记(5)——通过按键点亮LED
  14. [HNOI 2013] 旅行 (数学)
  15. 【原创】poj ----- 3009 curling 2 解题报告
  16. [转]5个JavaScript面试题
  17. angular6、7 兼容ie9、10、11
  18. 从构建分布式秒杀系统聊聊Lock锁使用中的坑
  19. Android P正式版即将到来:后台应用保活、消息推送的真正噩梦
  20. Linux-003-Resource temporarily unavailable

热门文章

  1. 学习HTML5 全局属性 accesskey-title
  2. poj2010 Moo University - Financial Aid 优先队列
  3. sourcetree for mac 使用
  4. Android 中三种启用线程的方法
  5. 简单谈谈Netty的高性能之道
  6. 推荐一个 Java 里面比较牛逼的公众号!
  7. 21、numpy—Matplotlib
  8. 1-for循环套生成器的面试题
  9. Codeforces - 1195D2 - Submarine in the Rybinsk Sea (hard edition) - 组合数学
  10. jquery+ajax获取本地json对应数据