xref: /freebsd/lib/libc/string/strmode.3 (revision dc36d6f9bb1753f3808552f3afd30eda9a7b206a)
158f0484fSRodney W. Grimes.\" Copyright (c) 1990, 1991, 1993
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
558f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
658f0484fSRodney W. Grimes.\" are met:
758f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
858f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
958f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1058f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1158f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12*3fb3b97cSEd Maste.\" 3. Neither the name of the University nor the names of its contributors
1358f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
1458f0484fSRodney W. Grimes.\"    without specific prior written permission.
1558f0484fSRodney W. Grimes.\"
1658f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1758f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1858f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1958f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2058f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2158f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2258f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2358f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2458f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2558f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2658f0484fSRodney W. Grimes.\" SUCH DAMAGE.
2758f0484fSRodney W. Grimes.\"
284ace1b52SPeter Wemm.Dd July 28, 1994
2958f0484fSRodney W. Grimes.Dt STRMODE 3
3058f0484fSRodney W. Grimes.Os
3158f0484fSRodney W. Grimes.Sh NAME
3258f0484fSRodney W. Grimes.Nm strmode
3358f0484fSRodney W. Grimes.Nd convert inode status information into a symbolic string
3425bb73e0SAlexey Zelkin.Sh LIBRARY
3525bb73e0SAlexey Zelkin.Lb libc
3658f0484fSRodney W. Grimes.Sh SYNOPSIS
3732eef9aeSRuslan Ermilov.In string.h
3858f0484fSRodney W. Grimes.Ft void
3958f0484fSRodney W. Grimes.Fn strmode "mode_t mode" "char *bp"
4058f0484fSRodney W. Grimes.Sh DESCRIPTION
4158f0484fSRodney W. GrimesThe
4258f0484fSRodney W. Grimes.Fn strmode
4358f0484fSRodney W. Grimesfunction
4458f0484fSRodney W. Grimesconverts a file
4558f0484fSRodney W. Grimes.Fa mode
4658f0484fSRodney W. Grimes(the type and permission information associated with an inode, see
4758f0484fSRodney W. Grimes.Xr stat 2 )
4858f0484fSRodney W. Grimesinto a symbolic string which is stored in the location referenced by
4958f0484fSRodney W. Grimes.Fa bp .
5058f0484fSRodney W. GrimesThis stored string is eleven characters in length plus a trailing
5166c15901SJames Raynard.Dv NUL .
5258f0484fSRodney W. Grimes.Pp
5358f0484fSRodney W. GrimesThe first character is the inode type, and will be one of the following:
5458f0484fSRodney W. Grimes.Pp
5558f0484fSRodney W. Grimes.Bl -tag -width flag -offset indent -compact
5658f0484fSRodney W. Grimes.It \-
5758f0484fSRodney W. Grimesregular file
5858f0484fSRodney W. Grimes.It b
5958f0484fSRodney W. Grimesblock special
6058f0484fSRodney W. Grimes.It c
6158f0484fSRodney W. Grimescharacter special
6258f0484fSRodney W. Grimes.It d
6358f0484fSRodney W. Grimesdirectory
6458f0484fSRodney W. Grimes.It l
6558f0484fSRodney W. Grimessymbolic link
6658f0484fSRodney W. Grimes.It p
6758f0484fSRodney W. Grimesfifo
6858f0484fSRodney W. Grimes.It s
6958f0484fSRodney W. Grimessocket
704ace1b52SPeter Wemm.It w
714ace1b52SPeter Wemmwhiteout
7258f0484fSRodney W. Grimes.It ?
7358f0484fSRodney W. Grimesunknown inode type
7458f0484fSRodney W. Grimes.El
7558f0484fSRodney W. Grimes.Pp
7658f0484fSRodney W. GrimesThe next nine characters encode three sets of permissions, in three
7758f0484fSRodney W. Grimescharacters each.
7858f0484fSRodney W. GrimesThe first three characters are the permissions for the owner of the
7958f0484fSRodney W. Grimesfile, the second three for the group the file belongs to, and the
8058f0484fSRodney W. Grimesthird for the ``other'', or default, set of users.
8158f0484fSRodney W. Grimes.Pp
8258f0484fSRodney W. GrimesPermission checking is done as specifically as possible.
8358f0484fSRodney W. GrimesIf read permission is denied to the owner of a file in the first set
8458f0484fSRodney W. Grimesof permissions, the owner of the file will not be able to read the file.
8558f0484fSRodney W. GrimesThis is true even if the owner is in the file's group and the group
8658f0484fSRodney W. Grimespermissions allow reading or the ``other'' permissions allow reading.
8758f0484fSRodney W. Grimes.Pp
8858f0484fSRodney W. GrimesIf the first character of the three character set is an ``r'', the file is
8958f0484fSRodney W. Grimesreadable for that set of users; if a dash ``\-'', it is not readable.
9058f0484fSRodney W. Grimes.Pp
9158f0484fSRodney W. GrimesIf the second character of the three character set is a ``w'', the file is
9258f0484fSRodney W. Grimeswritable for that set of users; if a dash ``\-'', it is not writable.
9358f0484fSRodney W. Grimes.Pp
9458f0484fSRodney W. GrimesThe third character is the first of the following characters that apply:
9558f0484fSRodney W. Grimes.Bl -tag -width xxxx
9658f0484fSRodney W. Grimes.It S
9758f0484fSRodney W. GrimesIf the character is part of the owner permissions and the file is not
9858f0484fSRodney W. Grimesexecutable or the directory is not searchable by the owner, and the
9958f0484fSRodney W. Grimesset-user-id bit is set.
10058f0484fSRodney W. Grimes.It S
10158f0484fSRodney W. GrimesIf the character is part of the group permissions and the file is not
10258f0484fSRodney W. Grimesexecutable or the directory is not searchable by the group, and the
10358f0484fSRodney W. Grimesset-group-id bit is set.
10458f0484fSRodney W. Grimes.It T
10558f0484fSRodney W. GrimesIf the character is part of the other permissions and the file is not
10658f0484fSRodney W. Grimesexecutable or the directory is not searchable by others, and the ``sticky''
10758f0484fSRodney W. Grimes.Pq Dv S_ISVTX
10858f0484fSRodney W. Grimesbit is set.
10958f0484fSRodney W. Grimes.It s
11058f0484fSRodney W. GrimesIf the character is part of the owner permissions and the file is
11158f0484fSRodney W. Grimesexecutable or the directory searchable by the owner, and the set-user-id
11258f0484fSRodney W. Grimesbit is set.
11358f0484fSRodney W. Grimes.It s
11458f0484fSRodney W. GrimesIf the character is part of the group permissions and the file is
11558f0484fSRodney W. Grimesexecutable or the directory searchable by the group, and the set-group-id
11658f0484fSRodney W. Grimesbit is set.
11758f0484fSRodney W. Grimes.It t
11858f0484fSRodney W. GrimesIf the character is part of the other permissions and the file is
11958f0484fSRodney W. Grimesexecutable or the directory searchable by others, and the ``sticky''
12058f0484fSRodney W. Grimes.Pq Dv S_ISVTX
12158f0484fSRodney W. Grimesbit is set.
12258f0484fSRodney W. Grimes.It x
12358f0484fSRodney W. GrimesThe file is executable or the directory is searchable.
12458f0484fSRodney W. Grimes.It \-
12558f0484fSRodney W. GrimesNone of the above apply.
12658f0484fSRodney W. Grimes.El
12758f0484fSRodney W. Grimes.Pp
128bab43babSEdward Tomasz NapieralaThe last character will always be a space.
12958f0484fSRodney W. Grimes.Sh SEE ALSO
13058f0484fSRodney W. Grimes.Xr chmod 1 ,
13158f0484fSRodney W. Grimes.Xr find 1 ,
13258f0484fSRodney W. Grimes.Xr stat 2 ,
13358f0484fSRodney W. Grimes.Xr getmode 3 ,
13458f0484fSRodney W. Grimes.Xr setmode 3
13558f0484fSRodney W. Grimes.Sh HISTORY
13658f0484fSRodney W. GrimesThe
13758f0484fSRodney W. Grimes.Fn strmode
1387bdf80e5SMike Pritchardfunction first appeared in
1397bdf80e5SMike Pritchard.Bx 4.4 .
140