Posted on 2009-03-05 15:02
Prayer 閱讀(3165)
評(píng)論(0) 編輯 收藏 引用 所屬分類(lèi):
LINUX/UNIX/AIX
函數(shù)semget( mykey, numsems, IPC_CREAT | 0660 ) 中,0660是什么意思
學(xué)習(xí)一下umask
0660表示用戶(hù)和同組用戶(hù)有讀寫(xiě)權(quán)限,其他用戶(hù)沒(méi)有任何訪問(wèn)權(quán)限。
- 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:
從左向右:
第一位:(我不清楚,也沒(méi)有用過(guò))
第二位:當(dāng)前用戶(hù)的經(jīng)權(quán)限:6=110(二進(jìn)制),每一位分別對(duì)就 可讀,可寫(xiě),可執(zhí)行,,6說(shuō)明當(dāng)前用戶(hù)可讀可寫(xiě)不可執(zhí)行
第三位:group組用戶(hù),6的意義同上
第四位:其它用戶(hù),每一位的意義同上,0表示不可讀不可寫(xiě)也不可執(zhí)行
0660:
從左向右:
第一位:(我不清楚,也沒(méi)有用過(guò))
第二位:當(dāng)前用戶(hù)的經(jīng)權(quán)限:6=110(二進(jìn)制),每一位分別對(duì)就 可讀,可寫(xiě),可執(zhí)行,,6說(shuō)明當(dāng)前用戶(hù)可讀可寫(xiě)不可執(zhí)行
第三位:group組用戶(hù),6的意義同上
第四位:其它用戶(hù),每一位的意義同上,0表示不可讀不可寫(xiě)也不可執(zhí)行
第一位0表示這是個(gè)八進(jìn)制數(shù)。