免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3948 | 回复: 11
打印 上一主题 下一主题

chmod中的mode=0140777是什么意思? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-23 21:35 |只看该作者 |倒序浏览
CUPS的代码中:

chmod("/var/run/cups/cups.sock", 0140777)

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
2 [报告]
发表于 2010-04-23 21:40 |只看该作者
就0777有用吧?

论坛徽章:
0
3 [报告]
发表于 2010-04-23 21:50 |只看该作者
回复 2# yecheng_110

不是吧,
那CUPS的作者为什么会这么写?

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
4 [报告]
发表于 2010-04-23 21:52 |只看该作者
回复  yecheng_110

不是吧,
那CUPS的作者为什么会这么写?
entertainyou 发表于 2010-04-23 21:50



    可能前几位有特殊意义
查查资料

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
5 [报告]
发表于 2010-04-23 21:57 |只看该作者
应该是设置 SUID、SGID和Sticky Bit之类的
看看帮助吧

论坛徽章:
0
6 [报告]
发表于 2010-04-24 09:30 |只看该作者
  1. /* Encoding of the file mode.  */

  2. #define __S_IFMT        0170000 /* These bits determine file type.  */

  3. /* File types.  */
  4. #define __S_IFDIR       0040000 /* Directory.  */
  5. #define __S_IFCHR       0020000 /* Character device.  */
  6. #define __S_IFBLK       0060000 /* Block device.  */
  7. #define __S_IFREG       0100000 /* Regular file.  */
  8. #define __S_IFIFO       0010000 /* FIFO.  */
  9. #define __S_IFLNK       0120000 /* Symbolic link.  */
  10. #define __S_IFSOCK      0140000 /* Socket.  */

  11. /* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
  12.    they do it by enforcing the correct use of the macros.  */
  13. #define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
  14. #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
  15. #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)

  16. /* Protection bits.  */

  17. #define __S_ISUID       04000   /* Set user ID on execution.  */
  18. #define __S_ISGID       02000   /* Set group ID on execution.  */
  19. #define __S_ISVTX       01000   /* Save swapped text after use (sticky).  */
  20. #define __S_IREAD       0400    /* Read by owner.  */
  21. #define __S_IWRITE      0200    /* Write by owner.  */
  22. #define __S_IEXEC       0100    /* Execute by owner.  */
复制代码
0140777说明这个文件是socket类型 的。看上面的bits/stat.h中macro,不用再解释了吧?

论坛徽章:
0
7 [报告]
发表于 2010-04-24 09:39 |只看该作者
本帖最后由 lengyuex 于 2010-04-24 09:41 编辑

回复 1# entertainyou


    在sys/stat.h中有定义。一般应该用macro的,怎么就直接写数了呢。
这个应该写成

  1. chmod("file",((S_IFSOCK) || (ACCESSPERMS)))
复制代码

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
8 [报告]
发表于 2010-04-24 10:46 |只看该作者
回复  entertainyou


    在sys/stat.h中有定义。一般应该用macro的,怎么就直接写数了呢。
这个应该 ...
lengyuex 发表于 2010-04-24 09:39

原来如此 这个mode意义还真丰富

论坛徽章:
0
9 [报告]
发表于 2010-04-24 11:04 |只看该作者
用宏__S_IFSOCK | 多好  好理解....

论坛徽章:
0
10 [报告]
发表于 2010-04-24 11:59 |只看该作者
回复 6# lengyuex


    谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP