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