Posted on 2009-03-05 15:02
Prayer 閱讀(3165)
評論(0) 編輯 收藏 引用 所屬分類:
LINUX/UNIX/AIX
函數semget( mykey, numsems, IPC_CREAT | 0660 ) 中,0660是什么意思
學習一下umask
0660表示用戶和同組用戶有讀寫權限,其他用戶沒有任何訪問權限。
- C/C++ code
-
/* 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 */
- BatchFile code
-
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.
0660:
從左向右:
第一位:(我不清楚,也沒有用過)
第二位:當前用戶的經權限:6=110(二進制),每一位分別對就 可讀,可寫,可執行,,6說明當前用戶可讀可寫不可執行
第三位:group組用戶,6的意義同上
第四位:其它用戶,每一位的意義同上,0表示不可讀不可寫也不可執行
0660:
從左向右:
第一位:(我不清楚,也沒有用過)
第二位:當前用戶的經權限:6=110(二進制),每一位分別對就 可讀,可寫,可執行,,6說明當前用戶可讀可寫不可執行
第三位:group組用戶,6的意義同上
第四位:其它用戶,每一位的意義同上,0表示不可讀不可寫也不可執行
第一位0表示這是個八進制數。