162923Sbostic.\" Copyright (c) 1990, 1991, 1993 262923Sbostic.\" The Regents of the University of California. All rights reserved. 341581Sbostic.\" 441581Sbostic.\" %sccs.include.redist.man% 541581Sbostic.\" 6*67576Spendry.\" @(#)strmode.3 8.3 (Berkeley) 07/28/94 741581Sbostic.\" 848351Scael.Dd 948351Scael.Dt STRMODE 3 1048351Scael.Os 1148351Scael.Sh NAME 1248351Scael.Nm strmode 1348351Scael.Nd convert inode status information into a symbolic string 1448351Scael.Sh SYNOPSIS 1548351Scael.Fd #include <string.h> 1648351Scael.Ft void 1748351Scael.Fn strmode "mode_t mode" "char *bp" 1848351Scael.Sh DESCRIPTION 1948351ScaelThe 2048351Scael.Fn strmode 2148351Scaelfunction 2241581Sbosticconverts a file 2348351Scael.Fa mode 2441581Sbostic(the type and permission information associated with an inode, see 2548351Scael.Xr stat 2 ) 2641581Sbosticinto a symbolic string which is stored in the location referenced by 2748351Scael.Fa bp . 2850727ScaelThis stored string is eleven characters in length plus a trailing 2950727Scael.Dv NULL . 3048351Scael.Pp 3141581SbosticThe first character is the inode type, and will be one of the following: 3250727Scael.Pp 3350727Scael.Bl -tag -width flag -offset indent -compact 3448351Scael.It \- 3541581Sbosticregular file 3648351Scael.It b 3741581Sbosticblock special 3848351Scael.It c 3941581Sbosticcharacter special 4048351Scael.It d 4141581Sbosticdirectory 4248351Scael.It l 4341581Sbosticsymbolic link 4448351Scael.It p 4541581Sbosticfifo 4648351Scael.It s 4741581Sbosticsocket 48*67576Spendry.It w 49*67576Spendrywhiteout 5048351Scael.It ? 5141581Sbosticunknown inode type 5248351Scael.El 5348351Scael.Pp 5441581SbosticThe next nine characters encode three sets of permissions, in three 5541581Sbosticcharacters each. 5641581SbosticThe first three characters are the permissions for the owner of the 5741581Sbosticfile, the second three for the group the file belongs to, and the 5841581Sbosticthird for the ``other'', or default, set of users. 5948351Scael.Pp 6041581SbosticPermission checking is done as specifically as possible. 6141581SbosticIf read permission is denied to the owner of a file in the first set 6265099Smckusickof permissions, the owner of the file will not be able to read the file. 6341581SbosticThis is true even if the owner is in the file's group and the group 6441581Sbosticpermissions allow reading or the ``other'' permissions allow reading. 6548351Scael.Pp 6641581SbosticIf the first character of the three character set is an ``r'', the file is 6741581Sbosticreadable for that set of users; if a dash ``\-'', it is not readable. 6848351Scael.Pp 6941581SbosticIf the second character of the three character set is a ``w'', the file is 7041581Sbosticwritable for that set of users; if a dash ``\-'', it is not writable. 7148351Scael.Pp 7241581SbosticThe third character is the first of the following characters that apply: 7348351Scael.Bl -tag -width xxxx 7448351Scael.It S 7541581SbosticIf the character is part of the owner permissions and the file is not 7665099Smckusickexecutable or the directory is not searchable by the owner, and the 7741581Sbosticset-user-id bit is set. 7848351Scael.It S 7941581SbosticIf the character is part of the group permissions and the file is not 8065099Smckusickexecutable or the directory is not searchable by the group, and the 8141581Sbosticset-group-id bit is set. 8248351Scael.It T 8341581SbosticIf the character is part of the other permissions and the file is not 8465099Smckusickexecutable or the directory is not searchable by others, and the ``sticky'' 8548351Scael.Pq Dv S_ISVTX 8648351Scaelbit is set. 8748351Scael.It s 8841581SbosticIf the character is part of the owner permissions and the file is 8965099Smckusickexecutable or the directory searchable by the owner, and the set-user-id 9041581Sbosticbit is set. 9148351Scael.It s 9241581SbosticIf the character is part of the group permissions and the file is 9365099Smckusickexecutable or the directory searchable by the group, and the set-group-id 9441581Sbosticbit is set. 9548351Scael.It t 9641581SbosticIf the character is part of the other permissions and the file is 9765099Smckusickexecutable or the directory searchable by others, and the ``sticky'' 9848351Scael.Pq Dv S_ISVTX 9948351Scaelbit is set. 10048351Scael.It x 10141581SbosticThe file is executable or the directory is searchable. 10248351Scael.It \- 10341581SbosticNone of the above apply. 10448351Scael.El 10548351Scael.Pp 10641581SbosticThe last character is a plus sign ``+'' if any there are any alternate 10741581Sbosticor additional access control methods associated with the inode, otherwise 10841581Sbosticit will be a space. 10948351Scael.Sh RETURN VALUES 11048351ScaelThe 11148351Scael.Fn strmode 11248351Scaelfunction 11341581Sbosticalways returns 0. 11448351Scael.Sh SEE ALSO 11548351Scael.Xr chmod 1 , 11648351Scael.Xr find 1 , 11748351Scael.Xr stat 2 , 11848351Scael.Xr getmode 3 , 11948351Scael.Xr setmode 3 12048351Scael.Sh HISTORY 12148351ScaelThe 12248351Scael.Fn strmode 12362922Sbosticfunction first appeared in 4.4BSD. 124