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