stat 调用对于模式字段中的各个位具有一系列符号名称。来自统计(2)手册页:
The following mask values are defined for the file mode component of
the st_mode field:
S_ISUID 04000 set-user-ID bit
S_ISGID 02000 set-group-ID bit (see below)
S_ISVTX 01000 sticky bit (see below)
S_IRWXU 00700 owner has read, write, and execute permission
S_IRUSR 00400 owner has read permission
S_IWUSR 00200 owner has write permission
S_IXUSR 00100 owner has execute permission
S_IRWXG 00070 group has read, write, and execute permission
S_IRGRP 00040 group has read permission
S_IWGRP 00020 group has write permission
S_IXGRP 00010 group has execute permission
S_IRWXO 00007 others (not in group) have read, write, and
execute permission
S_IROTH 00004 others have read permission
S_IWOTH 00002 others have write permission
S_IXOTH 00001 others have execute permission
我可以看到它是和(用户的读取、写入和执行权限)S_IRWXU
的组合,并且是和(用户的读取权限)的组合。对于写入和执行以及组和其他人也是如此。rwx
u
S_IRUSR
R
usr
该S
部分可能以stat
功能命名。
但那I
部分又是什么意思呢?它是根据各种S_ISDIR
(“是目录”)宏建模的吗?
VTX
该部分来自什么S_ISVTX
?我无法将此缩写与“粘性位”联系起来。
答案1
现在是历史时刻了,孩子们! Stevens,“APUE”,第 4 章,第 10 节如此引用:
“S_ISVTX 位有一个有趣的历史......如果它被设置......程序文本的副本被保存在交换区域中......这导致程序下次更快地加载到内存......更高的版本Unix 将此称为保存的文本位,因此为常数 S_ISVTX。”