我熟悉定义用户、组和其他权限的 3 个文件模式“位”以及 setuid/setgid/sticky“位”,但是当我查看stat
MacOSX 笔记本电脑上的根级目录时,我会看到 1 到 2 个额外的权限字段。这些是什么?
[onlyanegg@macosx ~]$ stat -f '%p %N' /*
40775 /Applications
40755 /Library
40755 /Network
40755 /System
40755 /Users
41777 /Volumes
40755 /bin
41775 /cores
40555 /dev
120755 /etc
40555 /home
100644 /installer.failurerequests
40555 /mnt
40555 /net
40775 /opt
40755 /private
40755 /sbin
120755 /tmp
40755 /usr
120755 /var
答案1
stat(1)
指定%p
请求
文件类型和权限。
(在链接页面中查找“数据”)。显示的值是全部st_mode
(参见stat(2)
:
#define S_IFMT 0170000 /* type of file */ #define S_IFIFO 0010000 /* named pipe (fifo) */ #define S_IFCHR 0020000 /* character special */ #define S_IFDIR 0040000 /* directory */ #define S_IFBLK 0060000 /* block special */ #define S_IFREG 0100000 /* regular */ #define S_IFLNK 0120000 /* symbolic link */ #define S_IFSOCK 0140000 /* socket */ #define S_IFWHT 0160000 /* whiteout */ #define S_ISUID 0004000 /* set user id on execution */ #define S_ISGID 0002000 /* set group id on execution */ #define S_ISVTX 0001000 /* save swapped text even after use */ #define S_IRUSR 0000400 /* read permission, owner */ #define S_IWUSR 0000200 /* write permission, owner */ #define S_IXUSR 0000100 /* execute/search permission, owner */
这解释了您获得的值:
- 以 4 开头的值是目录 (
/Applications
,/Library
...) - 以 12 开头的值是符号链接 (
/etc
,/tmp
,/var
) - 以 10 开头的值是常规文件 (
/installer.failurerequests
)