IPC_CREAT | 0660 的意义是什么?

orangeabc 2008-07-12 11:17:13
如在函数semget( mykey, numsems, IPC_CREAT | 0660 ) 中,0660是什么意思?在网上搜了说是读写权限,但是怎么知道它对应的是什么权限呢?有规律或规则吗?
...全文
3353 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 mymtom 的回复:]
0660表示用户和同组用户有读写权限,其他用户没有任何访问权限。
C/C++ code

/* sys/ipc.h */
/* common mode bits */
#define IPC_R 000400 /* read permission */
#define IPC_W 000200 /* write/alter p……
[/Quote]
很好!学习了!
wmr0324 2010-12-06
  • 打赏
  • 举报
回复
mark
mymtom 2008-07-12
  • 打赏
  • 举报
回复 1
[Quote=引用 3 楼 gezichong 的回复:]
0660:
从左向右:
第一位:(我不清楚,也没有用过)
第二位:当前用户的经权限:6=110(二进制),每一位分别对就 可读,可写,可执行,,6说明当前用户可读可写不可执行
第三位:group组用户,6的意义同上
第四位:其它用户,每一位的意义同上,0表示不可读不可写也不可执行

[/Quote]
第一位0表示这是个八进制数。
gezichong 2008-07-12
  • 打赏
  • 举报
回复 3
0660:
从左向右:
第一位:(我不清楚,也没有用过)
第二位:当前用户的经权限:6=110(二进制),每一位分别对就 可读,可写,可执行,,6说明当前用户可读可写不可执行
第三位:group组用户,6的意义同上
第四位:其它用户,每一位的意义同上,0表示不可读不可写也不可执行
mymtom 2008-07-12
  • 打赏
  • 举报
回复
0660表示用户和同组用户有读写权限,其他用户没有任何访问权限。

/* sys/ipc.h */
/* common mode bits */
#define IPC_R 000400 /* read permission */
#define IPC_W 000200 /* write/alter permission */
#define IPC_M 010000 /* permission to change control info */
#endif

/* SVID required constants (same values as system 5) */
#define IPC_CREAT 001000 /* create entry if key does not exist */
#define IPC_EXCL 002000 /* fail if key exists */
#define IPC_NOWAIT 004000 /* error if request must wait */

#define IPC_PRIVATE (key_t)0 /* private key */

#define IPC_RMID 0 /* remove identifier */
#define IPC_SET 1 /* set options */
#define IPC_STAT 2 /* get options */

/* sys/sem.h */
/*
* Permissions
*/
#define SEM_A IPC_W /* alter permission */
#define SEM_R IPC_R /* read permission */

[code=BatchFile]
The mode of a newly created IPC object is determined by OR'ing the fol-
lowing constants into the flag argument:

SEM_R Read access for user.

SEM_A Alter access for user.

(SEM_R>>3) Read access for group.

(SEM_A>>3) Alter access for group.

(SEM_R>>6) Read access for other.

(SEM_A>>6) Alter access for other.
[/code]
windowsxp0925 2008-07-12
  • 打赏
  • 举报
回复
建议你学习一下umask

23,120

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧