免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2727 | 回复: 4
打印 上一主题 下一主题

[C++] 求教个关于fchmod的问题。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-05-12 09:24 |只看该作者 |倒序浏览
10可用积分
用fchmod(fdPara, 00700)对文件进行权限控制。得到的是正确的结果:
  1. -rwx------ 1 etl      etl        294 May 11 17:11 sqlldrPara26549
复制代码
但如果用fchmod(fdPara, 700),就会得到下面的结果:
  1. --w-rwxr-T 1 etl      etl        294 May 11 16:44 sqlldrPara22368
复制代码
这是为什么呢?麻烦高人给解下迷惑。

最佳答案

查看完整内容

00700 八进制700 十进制

论坛徽章:
0
2 [报告]
发表于 2010-05-12 09:24 |只看该作者
00700 八进制
700 十进制

论坛徽章:
0
3 [报告]
发表于 2010-05-12 09:52 |只看该作者


谢谢rain_fish

论坛徽章:
0
4 [报告]
发表于 2010-05-12 10:18 |只看该作者
fchmod的第二个参数是bit mask, 通过或(OR)操作来确定文件的权限, '00700' 和 '700'所表示的bit mask是不一致的,尽管在值上面他们相等

  1. S_ISUID (04000)
  2.     set-user-ID (set process effective user ID on execve(2))
  3. S_ISGID (02000)
  4.     set-group-ID (set process effective group ID on execve(2); mandatory locking, as described in fcntl(2); take a new file's group from parent directory, as described in chown(2) and mkdir(2))
  5. S_ISVTX (01000)
  6.     sticky bit (restricted deletion flag, as described in unlink(2))
  7. S_IRUSR (00400)
  8.     read by owner
  9. S_IWUSR (00200)
  10.     write by owner
  11. S_IXUSR (00100)
  12.     execute/search by owner ("search" applies for directories, and means that entries within the directory can be accessed)
  13. S_IRGRP (00040)
  14.     read by group
  15. S_IWGRP (00020)
  16.     write by group
  17. S_IXGRP (00010)
  18.     execute/search by group
  19. S_IROTH (00004)
  20.     read by others
  21. S_IWOTH (00002)
  22.     write by others
  23. S_IXOTH (00001)
  24.     execute/search by others
复制代码

论坛徽章:
0
5 [报告]
发表于 2010-05-12 10:48 |只看该作者
本帖最后由 toniz 于 2010-05-12 10:51 编辑



fchmod(fdPara, 700)和fchmod(fdPara, 01274)的结果是一样的,所以应该就是进制问题了。

同样谢谢climby  :)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP