xref: /netbsd-src/lib/libc/string/strmode.3 (revision 1a64d82da5bc129cc68f0719e7f18fb075f6247a)
15f8a6c06Sperry.\" Copyright (c) 1990, 1991, 1993
25f8a6c06Sperry.\"	The Regents of the University of California.  All rights reserved.
361f28255Scgd.\"
461f28255Scgd.\" Redistribution and use in source and binary forms, with or without
561f28255Scgd.\" modification, are permitted provided that the following conditions
661f28255Scgd.\" are met:
761f28255Scgd.\" 1. Redistributions of source code must retain the above copyright
861f28255Scgd.\"    notice, this list of conditions and the following disclaimer.
961f28255Scgd.\" 2. Redistributions in binary form must reproduce the above copyright
1061f28255Scgd.\"    notice, this list of conditions and the following disclaimer in the
1161f28255Scgd.\"    documentation and/or other materials provided with the distribution.
12eb7c1594Sagc.\" 3. Neither the name of the University nor the names of its contributors
1361f28255Scgd.\"    may be used to endorse or promote products derived from this software
1461f28255Scgd.\"    without specific prior written permission.
1561f28255Scgd.\"
1661f28255Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1761f28255Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1861f28255Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1961f28255Scgd.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2061f28255Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2161f28255Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2261f28255Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2361f28255Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2461f28255Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2561f28255Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2661f28255Scgd.\" SUCH DAMAGE.
2761f28255Scgd.\"
285f8a6c06Sperry.\"     from: @(#)strmode.3	8.3 (Berkeley) 7/28/94
29*1a64d82dSwiz.\"	$NetBSD: strmode.3,v 1.17 2006/10/16 08:48:45 wiz Exp $
3061f28255Scgd.\"
315f8a6c06Sperry.Dd July 28, 1994
3261f28255Scgd.Dt STRMODE 3
3361f28255Scgd.Os
3461f28255Scgd.Sh NAME
3561f28255Scgd.Nm strmode
3661f28255Scgd.Nd convert inode status information into a symbolic string
37312aca53Sperry.Sh LIBRARY
38312aca53Sperry.Lb libc
3961f28255Scgd.Sh SYNOPSIS
40472351e1Swiz.In unistd.h
4161f28255Scgd.Ft void
4261f28255Scgd.Fn strmode "mode_t mode" "char *bp"
4361f28255Scgd.Sh DESCRIPTION
4461f28255ScgdThe
4561f28255Scgd.Fn strmode
4661f28255Scgdfunction
4761f28255Scgdconverts a file
4861f28255Scgd.Fa mode
4961f28255Scgd(the type and permission information associated with an inode, see
5061f28255Scgd.Xr stat 2 )
5161f28255Scgdinto a symbolic string which is stored in the location referenced by
5261f28255Scgd.Fa bp .
53*1a64d82dSwizThis stored string is eleven characters in length plus a trailing nul byte.
5461f28255Scgd.Pp
5561f28255ScgdThe first character is the inode type, and will be one of the following:
5661f28255Scgd.Pp
5761f28255Scgd.Bl -tag -width flag -offset indent -compact
5861f28255Scgd.It \-
5961f28255Scgdregular file
600217e4fdSwrstuden.It a
610217e4fdSwrstudenregular file in archive state 1
620217e4fdSwrstuden.It A
630217e4fdSwrstudenregular file in archive state 2
6461f28255Scgd.It b
6561f28255Scgdblock special
6661f28255Scgd.It c
6761f28255Scgdcharacter special
6861f28255Scgd.It d
6961f28255Scgddirectory
7061f28255Scgd.It l
7161f28255Scgdsymbolic link
7261f28255Scgd.It p
7361f28255Scgdfifo
7461f28255Scgd.It s
7561f28255Scgdsocket
7697a71285Smatthias.It w
7797a71285Smatthiaswhiteout
7861f28255Scgd.It ?
7961f28255Scgdunknown inode type
8061f28255Scgd.El
8161f28255Scgd.Pp
8261f28255ScgdThe next nine characters encode three sets of permissions, in three
8361f28255Scgdcharacters each.
8461f28255ScgdThe first three characters are the permissions for the owner of the
8561f28255Scgdfile, the second three for the group the file belongs to, and the
8661f28255Scgdthird for the ``other'', or default, set of users.
8761f28255Scgd.Pp
8861f28255ScgdPermission checking is done as specifically as possible.
8961f28255ScgdIf read permission is denied to the owner of a file in the first set
9062c2139aSjtcof permissions, the owner of the file will not be able to read the file.
9161f28255ScgdThis is true even if the owner is in the file's group and the group
9261f28255Scgdpermissions allow reading or the ``other'' permissions allow reading.
9361f28255Scgd.Pp
9461f28255ScgdIf the first character of the three character set is an ``r'', the file is
9561f28255Scgdreadable for that set of users; if a dash ``\-'', it is not readable.
9661f28255Scgd.Pp
9761f28255ScgdIf the second character of the three character set is a ``w'', the file is
9861f28255Scgdwritable for that set of users; if a dash ``\-'', it is not writable.
9961f28255Scgd.Pp
10061f28255ScgdThe third character is the first of the following characters that apply:
10161f28255Scgd.Bl -tag -width xxxx
10261f28255Scgd.It S
10361f28255ScgdIf the character is part of the owner permissions and the file is not
1045f8a6c06Sperryexecutable or the directory is not searchable by the owner, and the
10561f28255Scgdset-user-id bit is set.
10661f28255Scgd.It S
10761f28255ScgdIf the character is part of the group permissions and the file is not
1085f8a6c06Sperryexecutable or the directory is not searchable by the group, and the
10961f28255Scgdset-group-id bit is set.
11061f28255Scgd.It T
11161f28255ScgdIf the character is part of the other permissions and the file is not
1125f8a6c06Sperryexecutable or the directory is not searchable by others, and the ``sticky''
11361f28255Scgd.Pq Dv S_ISVTX
11461f28255Scgdbit is set.
11561f28255Scgd.It s
11661f28255ScgdIf the character is part of the owner permissions and the file is
1175f8a6c06Sperryexecutable or the directory searchable by the owner, and the set-user-id
11861f28255Scgdbit is set.
11961f28255Scgd.It s
12061f28255ScgdIf the character is part of the group permissions and the file is
1215f8a6c06Sperryexecutable or the directory searchable by the group, and the set-group-id
12261f28255Scgdbit is set.
12361f28255Scgd.It t
12461f28255ScgdIf the character is part of the other permissions and the file is
1255f8a6c06Sperryexecutable or the directory searchable by others, and the ``sticky''
12661f28255Scgd.Pq Dv S_ISVTX
12761f28255Scgdbit is set.
12861f28255Scgd.It x
12961f28255ScgdThe file is executable or the directory is searchable.
13061f28255Scgd.It \-
13161f28255ScgdNone of the above apply.
13261f28255Scgd.El
13361f28255Scgd.Pp
134e8f2050aSmikelThe last character is a plus sign ``+'' if there are any alternative
13561f28255Scgdor additional access control methods associated with the inode, otherwise
13661f28255Scgdit will be a space.
1370217e4fdSwrstuden.Pp
1380217e4fdSwrstudenArchive state 1 and archive state 2 represent file system dependent
1396569c5c5Swizarchive state for a file.
1406569c5c5SwizMost file systems do not retain file archive
1410217e4fdSwrstudenstate, and so will not report files in either archive state.
1420217e4fdSwrstudenmsdosfs will report a file in archive state 1 if it has been
1436569c5c5Swizarchived more recently than modified.
1446569c5c5SwizHierarchical storage systems may have multiple archive states for a
1456569c5c5Swizfile and may define archive states 1 and 2 as appropriate.
14661f28255Scgd.Sh SEE ALSO
14761f28255Scgd.Xr chmod 1 ,
14861f28255Scgd.Xr find 1 ,
14961f28255Scgd.Xr stat 2 ,
15061f28255Scgd.Xr getmode 3 ,
15161f28255Scgd.Xr setmode 3
15261f28255Scgd.Sh HISTORY
15361f28255ScgdThe
15461f28255Scgd.Fn strmode
155e8f2050aSmikelfunction first appeared in
156e8f2050aSmikel.Bx 4.4 .
157