xref: /minix3/lib/libc/string/strmode.3 (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras.\" Copyright (c) 1990, 1991, 1993
2*2fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
3*2fe8fb19SBen Gras.\"
4*2fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
5*2fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
6*2fe8fb19SBen Gras.\" are met:
7*2fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
8*2fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
9*2fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
10*2fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
11*2fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
12*2fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
13*2fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
14*2fe8fb19SBen Gras.\"    without specific prior written permission.
15*2fe8fb19SBen Gras.\"
16*2fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17*2fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*2fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*2fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20*2fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*2fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*2fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*2fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*2fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*2fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*2fe8fb19SBen Gras.\" SUCH DAMAGE.
27*2fe8fb19SBen Gras.\"
28*2fe8fb19SBen Gras.\"     from: @(#)strmode.3	8.3 (Berkeley) 7/28/94
29*2fe8fb19SBen Gras.\"	$NetBSD: strmode.3,v 1.17 2006/10/16 08:48:45 wiz Exp $
30*2fe8fb19SBen Gras.\"
31*2fe8fb19SBen Gras.Dd July 28, 1994
32*2fe8fb19SBen Gras.Dt STRMODE 3
33*2fe8fb19SBen Gras.Os
34*2fe8fb19SBen Gras.Sh NAME
35*2fe8fb19SBen Gras.Nm strmode
36*2fe8fb19SBen Gras.Nd convert inode status information into a symbolic string
37*2fe8fb19SBen Gras.Sh LIBRARY
38*2fe8fb19SBen Gras.Lb libc
39*2fe8fb19SBen Gras.Sh SYNOPSIS
40*2fe8fb19SBen Gras.In unistd.h
41*2fe8fb19SBen Gras.Ft void
42*2fe8fb19SBen Gras.Fn strmode "mode_t mode" "char *bp"
43*2fe8fb19SBen Gras.Sh DESCRIPTION
44*2fe8fb19SBen GrasThe
45*2fe8fb19SBen Gras.Fn strmode
46*2fe8fb19SBen Grasfunction
47*2fe8fb19SBen Grasconverts a file
48*2fe8fb19SBen Gras.Fa mode
49*2fe8fb19SBen Gras(the type and permission information associated with an inode, see
50*2fe8fb19SBen Gras.Xr stat 2 )
51*2fe8fb19SBen Grasinto a symbolic string which is stored in the location referenced by
52*2fe8fb19SBen Gras.Fa bp .
53*2fe8fb19SBen GrasThis stored string is eleven characters in length plus a trailing nul byte.
54*2fe8fb19SBen Gras.Pp
55*2fe8fb19SBen GrasThe first character is the inode type, and will be one of the following:
56*2fe8fb19SBen Gras.Pp
57*2fe8fb19SBen Gras.Bl -tag -width flag -offset indent -compact
58*2fe8fb19SBen Gras.It \-
59*2fe8fb19SBen Grasregular file
60*2fe8fb19SBen Gras.It a
61*2fe8fb19SBen Grasregular file in archive state 1
62*2fe8fb19SBen Gras.It A
63*2fe8fb19SBen Grasregular file in archive state 2
64*2fe8fb19SBen Gras.It b
65*2fe8fb19SBen Grasblock special
66*2fe8fb19SBen Gras.It c
67*2fe8fb19SBen Grascharacter special
68*2fe8fb19SBen Gras.It d
69*2fe8fb19SBen Grasdirectory
70*2fe8fb19SBen Gras.It l
71*2fe8fb19SBen Grassymbolic link
72*2fe8fb19SBen Gras.It p
73*2fe8fb19SBen Grasfifo
74*2fe8fb19SBen Gras.It s
75*2fe8fb19SBen Grassocket
76*2fe8fb19SBen Gras.It w
77*2fe8fb19SBen Graswhiteout
78*2fe8fb19SBen Gras.It ?
79*2fe8fb19SBen Grasunknown inode type
80*2fe8fb19SBen Gras.El
81*2fe8fb19SBen Gras.Pp
82*2fe8fb19SBen GrasThe next nine characters encode three sets of permissions, in three
83*2fe8fb19SBen Grascharacters each.
84*2fe8fb19SBen GrasThe first three characters are the permissions for the owner of the
85*2fe8fb19SBen Grasfile, the second three for the group the file belongs to, and the
86*2fe8fb19SBen Grasthird for the ``other'', or default, set of users.
87*2fe8fb19SBen Gras.Pp
88*2fe8fb19SBen GrasPermission checking is done as specifically as possible.
89*2fe8fb19SBen GrasIf read permission is denied to the owner of a file in the first set
90*2fe8fb19SBen Grasof permissions, the owner of the file will not be able to read the file.
91*2fe8fb19SBen GrasThis is true even if the owner is in the file's group and the group
92*2fe8fb19SBen Graspermissions allow reading or the ``other'' permissions allow reading.
93*2fe8fb19SBen Gras.Pp
94*2fe8fb19SBen GrasIf the first character of the three character set is an ``r'', the file is
95*2fe8fb19SBen Grasreadable for that set of users; if a dash ``\-'', it is not readable.
96*2fe8fb19SBen Gras.Pp
97*2fe8fb19SBen GrasIf the second character of the three character set is a ``w'', the file is
98*2fe8fb19SBen Graswritable for that set of users; if a dash ``\-'', it is not writable.
99*2fe8fb19SBen Gras.Pp
100*2fe8fb19SBen GrasThe third character is the first of the following characters that apply:
101*2fe8fb19SBen Gras.Bl -tag -width xxxx
102*2fe8fb19SBen Gras.It S
103*2fe8fb19SBen GrasIf the character is part of the owner permissions and the file is not
104*2fe8fb19SBen Grasexecutable or the directory is not searchable by the owner, and the
105*2fe8fb19SBen Grasset-user-id bit is set.
106*2fe8fb19SBen Gras.It S
107*2fe8fb19SBen GrasIf the character is part of the group permissions and the file is not
108*2fe8fb19SBen Grasexecutable or the directory is not searchable by the group, and the
109*2fe8fb19SBen Grasset-group-id bit is set.
110*2fe8fb19SBen Gras.It T
111*2fe8fb19SBen GrasIf the character is part of the other permissions and the file is not
112*2fe8fb19SBen Grasexecutable or the directory is not searchable by others, and the ``sticky''
113*2fe8fb19SBen Gras.Pq Dv S_ISVTX
114*2fe8fb19SBen Grasbit is set.
115*2fe8fb19SBen Gras.It s
116*2fe8fb19SBen GrasIf the character is part of the owner permissions and the file is
117*2fe8fb19SBen Grasexecutable or the directory searchable by the owner, and the set-user-id
118*2fe8fb19SBen Grasbit is set.
119*2fe8fb19SBen Gras.It s
120*2fe8fb19SBen GrasIf the character is part of the group permissions and the file is
121*2fe8fb19SBen Grasexecutable or the directory searchable by the group, and the set-group-id
122*2fe8fb19SBen Grasbit is set.
123*2fe8fb19SBen Gras.It t
124*2fe8fb19SBen GrasIf the character is part of the other permissions and the file is
125*2fe8fb19SBen Grasexecutable or the directory searchable by others, and the ``sticky''
126*2fe8fb19SBen Gras.Pq Dv S_ISVTX
127*2fe8fb19SBen Grasbit is set.
128*2fe8fb19SBen Gras.It x
129*2fe8fb19SBen GrasThe file is executable or the directory is searchable.
130*2fe8fb19SBen Gras.It \-
131*2fe8fb19SBen GrasNone of the above apply.
132*2fe8fb19SBen Gras.El
133*2fe8fb19SBen Gras.Pp
134*2fe8fb19SBen GrasThe last character is a plus sign ``+'' if there are any alternative
135*2fe8fb19SBen Grasor additional access control methods associated with the inode, otherwise
136*2fe8fb19SBen Grasit will be a space.
137*2fe8fb19SBen Gras.Pp
138*2fe8fb19SBen GrasArchive state 1 and archive state 2 represent file system dependent
139*2fe8fb19SBen Grasarchive state for a file.
140*2fe8fb19SBen GrasMost file systems do not retain file archive
141*2fe8fb19SBen Grasstate, and so will not report files in either archive state.
142*2fe8fb19SBen Grasmsdosfs will report a file in archive state 1 if it has been
143*2fe8fb19SBen Grasarchived more recently than modified.
144*2fe8fb19SBen GrasHierarchical storage systems may have multiple archive states for a
145*2fe8fb19SBen Grasfile and may define archive states 1 and 2 as appropriate.
146*2fe8fb19SBen Gras.Sh SEE ALSO
147*2fe8fb19SBen Gras.Xr chmod 1 ,
148*2fe8fb19SBen Gras.Xr find 1 ,
149*2fe8fb19SBen Gras.Xr stat 2 ,
150*2fe8fb19SBen Gras.Xr getmode 3 ,
151*2fe8fb19SBen Gras.Xr setmode 3
152*2fe8fb19SBen Gras.Sh HISTORY
153*2fe8fb19SBen GrasThe
154*2fe8fb19SBen Gras.Fn strmode
155*2fe8fb19SBen Grasfunction first appeared in
156*2fe8fb19SBen Gras.Bx 4.4 .
157