added whiteout
[unix-history] / usr / src / lib / libc / string / strmode.3
CommitLineData
8c0da00b
KB
1.\" Copyright (c) 1990, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
37291407
KB
3.\"
4.\" %sccs.include.redist.man%
5.\"
f69b3713 6.\" @(#)strmode.3 8.3 (Berkeley) %G%
37291407 7.\"
ae59e04c
CL
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
37291407 22converts a file
ae59e04c 23.Fa mode
37291407 24(the type and permission information associated with an inode, see
ae59e04c 25.Xr stat 2 )
37291407 26into a symbolic string which is stored in the location referenced by
ae59e04c 27.Fa bp .
bd8ecad4
CL
28This stored string is eleven characters in length plus a trailing
29.Dv NULL .
ae59e04c 30.Pp
37291407 31The first character is the inode type, and will be one of the following:
bd8ecad4
CL
32.Pp
33.Bl -tag -width flag -offset indent -compact
ae59e04c 34.It \-
37291407 35regular file
ae59e04c 36.It b
37291407 37block special
ae59e04c 38.It c
37291407 39character special
ae59e04c 40.It d
37291407 41directory
ae59e04c 42.It l
37291407 43symbolic link
ae59e04c 44.It p
37291407 45fifo
ae59e04c 46.It s
37291407 47socket
f69b3713
JSP
48.It w
49whiteout
ae59e04c 50.It ?
37291407 51unknown inode type
ae59e04c
CL
52.El
53.Pp
37291407
KB
54The next nine characters encode three sets of permissions, in three
55characters each.
56The first three characters are the permissions for the owner of the
57file, the second three for the group the file belongs to, and the
58third for the ``other'', or default, set of users.
ae59e04c 59.Pp
37291407
KB
60Permission checking is done as specifically as possible.
61If read permission is denied to the owner of a file in the first set
653ba8b6 62of permissions, the owner of the file will not be able to read the file.
37291407
KB
63This is true even if the owner is in the file's group and the group
64permissions allow reading or the ``other'' permissions allow reading.
ae59e04c 65.Pp
37291407
KB
66If the first character of the three character set is an ``r'', the file is
67readable for that set of users; if a dash ``\-'', it is not readable.
ae59e04c 68.Pp
37291407
KB
69If the second character of the three character set is a ``w'', the file is
70writable for that set of users; if a dash ``\-'', it is not writable.
ae59e04c 71.Pp
37291407 72The third character is the first of the following characters that apply:
ae59e04c
CL
73.Bl -tag -width xxxx
74.It S
37291407 75If the character is part of the owner permissions and the file is not
653ba8b6 76executable or the directory is not searchable by the owner, and the
37291407 77set-user-id bit is set.
ae59e04c 78.It S
37291407 79If the character is part of the group permissions and the file is not
653ba8b6 80executable or the directory is not searchable by the group, and the
37291407 81set-group-id bit is set.
ae59e04c 82.It T
37291407 83If the character is part of the other permissions and the file is not
653ba8b6 84executable or the directory is not searchable by others, and the ``sticky''
ae59e04c
CL
85.Pq Dv S_ISVTX
86bit is set.
87.It s
37291407 88If the character is part of the owner permissions and the file is
653ba8b6 89executable or the directory searchable by the owner, and the set-user-id
37291407 90bit is set.
ae59e04c 91.It s
37291407 92If the character is part of the group permissions and the file is
653ba8b6 93executable or the directory searchable by the group, and the set-group-id
37291407 94bit is set.
ae59e04c 95.It t
37291407 96If the character is part of the other permissions and the file is
653ba8b6 97executable or the directory searchable by others, and the ``sticky''
ae59e04c
CL
98.Pq Dv S_ISVTX
99bit is set.
100.It x
37291407 101The file is executable or the directory is searchable.
ae59e04c 102.It \-
37291407 103None of the above apply.
ae59e04c
CL
104.El
105.Pp
37291407
KB
106The last character is a plus sign ``+'' if any there are any alternate
107or additional access control methods associated with the inode, otherwise
108it will be a space.
ae59e04c
CL
109.Sh RETURN VALUES
110The
111.Fn strmode
112function
37291407 113always returns 0.
ae59e04c
CL
114.Sh SEE ALSO
115.Xr chmod 1 ,
116.Xr find 1 ,
117.Xr stat 2 ,
118.Xr getmode 3 ,
119.Xr setmode 3
120.Sh HISTORY
121The
122.Fn strmode
7e76fa85 123function first appeared in 4.4BSD.