xref: /csrg-svn/lib/libc/string/strmode.3 (revision 48351)
1*48351Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California.
241581Sbostic.\" All rights reserved.
341581Sbostic.\"
441581Sbostic.\" %sccs.include.redist.man%
541581Sbostic.\"
6*48351Scael.\"     @(#)strmode.3	5.3 (Berkeley) 04/19/91
741581Sbostic.\"
8*48351Scael.Dd
9*48351Scael.Dt STRMODE 3
10*48351Scael.Os
11*48351Scael.Sh NAME
12*48351Scael.Nm strmode
13*48351Scael.Nd convert inode status information into a symbolic string
14*48351Scael.Sh SYNOPSIS
15*48351Scael.Fd #include <string.h>
16*48351Scael.Ft void
17*48351Scael.Fn strmode "mode_t mode" "char *bp"
18*48351Scael.Sh DESCRIPTION
19*48351ScaelThe
20*48351Scael.Fn strmode
21*48351Scaelfunction
2241581Sbosticconverts a file
23*48351Scael.Fa mode
2441581Sbostic(the type and permission information associated with an inode, see
25*48351Scael.Xr stat 2 )
2641581Sbosticinto a symbolic string which is stored in the location referenced by
27*48351Scael.Fa bp .
2841581SbosticThis stored string is eleven characters in length plus a trailing NULL.
29*48351Scael.Pp
3041581SbosticThe first character is the inode type, and will be one of the following:
31*48351Scael.Bl -tag -width xxxx
32*48351Scael.It \-
3341581Sbosticregular file
34*48351Scael.It b
3541581Sbosticblock special
36*48351Scael.It c
3741581Sbosticcharacter special
38*48351Scael.It d
3941581Sbosticdirectory
40*48351Scael.It l
4141581Sbosticsymbolic link
42*48351Scael.It p
4341581Sbosticfifo
44*48351Scael.It s
4541581Sbosticsocket
46*48351Scael.It ?
4741581Sbosticunknown inode type
48*48351Scael.El
49*48351Scael.Pp
5041581SbosticThe next nine characters encode three sets of permissions, in three
5141581Sbosticcharacters each.
5241581SbosticThe first three characters are the permissions for the owner of the
5341581Sbosticfile, the second three for the group the file belongs to, and the
5441581Sbosticthird for the ``other'', or default, set of users.
55*48351Scael.Pp
5641581SbosticPermission checking is done as specifically as possible.
5741581SbosticIf read permission is denied to the owner of a file in the first set
5841581Sbosticof permssions, the owner of the file will not be able to read the file.
5941581SbosticThis is true even if the owner is in the file's group and the group
6041581Sbosticpermissions allow reading or the ``other'' permissions allow reading.
61*48351Scael.Pp
6241581SbosticIf the first character of the three character set is an ``r'', the file is
6341581Sbosticreadable for that set of users; if a dash ``\-'', it is not readable.
64*48351Scael.Pp
6541581SbosticIf the second character of the three character set is a ``w'', the file is
6641581Sbosticwritable for that set of users; if a dash ``\-'', it is not writable.
67*48351Scael.Pp
6841581SbosticThe third character is the first of the following characters that apply:
69*48351Scael.Bl -tag -width xxxx
70*48351Scael.It S
7141581SbosticIf the character is part of the owner permissions and the file is not
7241581Sbosticexecutable or the directory is not searchable, by the owner, and the
7341581Sbosticset-user-id bit is set.
74*48351Scael.It S
7541581SbosticIf the character is part of the group permissions and the file is not
7641581Sbosticexecutable or the directory is not searchable, by the group, and the
7741581Sbosticset-group-id bit is set.
78*48351Scael.It T
7941581SbosticIf the character is part of the other permissions and the file is not
8041581Sbosticexecutable or the directory is not searchable, by others, and the ``sticky''
81*48351Scael.Pq Dv S_ISVTX
82*48351Scaelbit is set.
83*48351Scael.It s
8441581SbosticIf the character is part of the owner permissions and the file is
8541581Sbosticexecutable or the directory searchable, by the owner, and the set-user-id
8641581Sbosticbit is set.
87*48351Scael.It s
8841581SbosticIf the character is part of the group permissions and the file is
8941581Sbosticexecutable or the directory searchable, by the group, and the set-group-id
9041581Sbosticbit is set.
91*48351Scael.It t
9241581SbosticIf the character is part of the other permissions and the file is
9341581Sbosticexecutable or the directory searchable, by others, and the ``sticky''
94*48351Scael.Pq Dv S_ISVTX
95*48351Scaelbit is set.
96*48351Scael.It x
9741581SbosticThe file is executable or the directory is searchable.
98*48351Scael.It \-
9941581SbosticNone of the above apply.
100*48351Scael.El
101*48351Scael.Pp
10241581SbosticThe last character is a plus sign ``+'' if any there are any alternate
10341581Sbosticor additional access control methods associated with the inode, otherwise
10441581Sbosticit will be a space.
105*48351Scael.Sh RETURN VALUES
106*48351ScaelThe
107*48351Scael.Fn strmode
108*48351Scaelfunction
10941581Sbosticalways returns 0.
110*48351Scael.Sh SEE ALSO
111*48351Scael.Xr chmod 1 ,
112*48351Scael.Xr find 1 ,
113*48351Scael.Xr stat 2 ,
114*48351Scael.Xr getmode 3 ,
115*48351Scael.Xr setmode 3
116*48351Scael.Sh HISTORY
117*48351ScaelThe
118*48351Scael.Fn strmode
119*48351Scaelfunction
120*48351Scael.Ud .
121