xref: /original-bsd/lib/libc/string/strmode.3 (revision 7bad34b3)
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)strmode.3	5.3 (Berkeley) 04/19/91
7.\"
8.Dd
9.Dt STRMODE 3
10.Os
11.Sh NAME
12.Nm strmode
13.Nd convert inode status information into a symbolic string
14.Sh SYNOPSIS
15.Fd #include <string.h>
16.Ft void
17.Fn strmode "mode_t mode" "char *bp"
18.Sh DESCRIPTION
19The
20.Fn strmode
21function
22converts a file
23.Fa mode
24(the type and permission information associated with an inode, see
25.Xr stat 2 )
26into a symbolic string which is stored in the location referenced by
27.Fa bp .
28This stored string is eleven characters in length plus a trailing NULL.
29.Pp
30The first character is the inode type, and will be one of the following:
31.Bl -tag -width xxxx
32.It \-
33regular file
34.It b
35block special
36.It c
37character special
38.It d
39directory
40.It l
41symbolic link
42.It p
43fifo
44.It s
45socket
46.It ?
47unknown inode type
48.El
49.Pp
50The next nine characters encode three sets of permissions, in three
51characters each.
52The first three characters are the permissions for the owner of the
53file, the second three for the group the file belongs to, and the
54third for the ``other'', or default, set of users.
55.Pp
56Permission checking is done as specifically as possible.
57If read permission is denied to the owner of a file in the first set
58of permssions, the owner of the file will not be able to read the file.
59This is true even if the owner is in the file's group and the group
60permissions allow reading or the ``other'' permissions allow reading.
61.Pp
62If the first character of the three character set is an ``r'', the file is
63readable for that set of users; if a dash ``\-'', it is not readable.
64.Pp
65If the second character of the three character set is a ``w'', the file is
66writable for that set of users; if a dash ``\-'', it is not writable.
67.Pp
68The third character is the first of the following characters that apply:
69.Bl -tag -width xxxx
70.It S
71If the character is part of the owner permissions and the file is not
72executable or the directory is not searchable, by the owner, and the
73set-user-id bit is set.
74.It S
75If the character is part of the group permissions and the file is not
76executable or the directory is not searchable, by the group, and the
77set-group-id bit is set.
78.It T
79If the character is part of the other permissions and the file is not
80executable or the directory is not searchable, by others, and the ``sticky''
81.Pq Dv S_ISVTX
82bit is set.
83.It s
84If the character is part of the owner permissions and the file is
85executable or the directory searchable, by the owner, and the set-user-id
86bit is set.
87.It s
88If the character is part of the group permissions and the file is
89executable or the directory searchable, by the group, and the set-group-id
90bit is set.
91.It t
92If the character is part of the other permissions and the file is
93executable or the directory searchable, by others, and the ``sticky''
94.Pq Dv S_ISVTX
95bit is set.
96.It x
97The file is executable or the directory is searchable.
98.It \-
99None of the above apply.
100.El
101.Pp
102The last character is a plus sign ``+'' if any there are any alternate
103or additional access control methods associated with the inode, otherwise
104it will be a space.
105.Sh RETURN VALUES
106The
107.Fn strmode
108function
109always returns 0.
110.Sh SEE ALSO
111.Xr chmod 1 ,
112.Xr find 1 ,
113.Xr stat 2 ,
114.Xr getmode 3 ,
115.Xr setmode 3
116.Sh HISTORY
117The
118.Fn strmode
119function
120.Ud .
121