1STRMODE(3) BSD Library Functions Manual STRMODE(3)
2
4 strmode — convert inode status information into a symbolic string
5
7 Utility functions from BSD systems (libbsd, -lbsd)
8
10 #include <string.h>
11
12 void
13 strmode(mode_t mode, char *bp);
14
16 The strmode() function converts a file mode (the type and permission
17 information associated with an inode, see stat(2)) into a symbolic string
18 which is stored in the location referenced by bp. This stored string is
19 eleven characters in length plus a trailing NUL.
20
21 The first character is the inode type, and will be one of the following:
22
23 - regular file
24 b block special
25 c character special
26 d directory
27 l symbolic link
28 p fifo
29 s socket
30 w whiteout
31 ? unknown inode type
32
33 The next nine characters encode three sets of permissions, in three char‐
34 acters each. The first three characters are the permissions for the
35 owner of the file, the second three for the group the file belongs to,
36 and the third for the ``other'', or default, set of users.
37
38 Permission checking is done as specifically as possible. If read permis‐
39 sion is denied to the owner of a file in the first set of permissions,
40 the owner of the file will not be able to read the file. This is true
41 even if the owner is in the file's group and the group permissions allow
42 reading or the ``other'' permissions allow reading.
43
44 If the first character of the three character set is an ``r'', the file
45 is readable for that set of users; if a dash ``-'', it is not readable.
46
47 If the second character of the three character set is a ``w'', the file
48 is writable for that set of users; if a dash ``-'', it is not writable.
49
50 The third character is the first of the following characters that apply:
51
52 S If the character is part of the owner permissions and the file is
53 not executable or the directory is not searchable by the owner, and
54 the set-user-id bit is set.
55
56 S If the character is part of the group permissions and the file is
57 not executable or the directory is not searchable by the group, and
58 the set-group-id bit is set.
59
60 T If the character is part of the other permissions and the file is
61 not executable or the directory is not searchable by others, and
62 the ``sticky'' (S_ISVTX) bit is set.
63
64 s If the character is part of the owner permissions and the file is
65 executable or the directory searchable by the owner, and the set-
66 user-id bit is set.
67
68 s If the character is part of the group permissions and the file is
69 executable or the directory searchable by the group, and the set-
70 group-id bit is set.
71
72 t If the character is part of the other permissions and the file is
73 executable or the directory searchable by others, and the
74 ``sticky'' (S_ISVTX) bit is set.
75
76 x The file is executable or the directory is searchable.
77
78 - None of the above apply.
79
80 The last character is a plus sign ``+'' if any there are any alternate or
81 additional access control methods associated with the inode, otherwise it
82 will be a space.
83
85 chmod(1), find(1), stat(2), getmode(3), setmode(3)
86
88 The strmode() function first appeared in 4.4BSD.
89
90BSD July 28, 1994 BSD