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*65099Smckusick.\" @(#)strmode.3 8.2 (Berkeley) 12/11/93 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 4848351Scael.It ? 4941581Sbosticunknown inode type 5048351Scael.El 5148351Scael.Pp 5241581SbosticThe next nine characters encode three sets of permissions, in three 5341581Sbosticcharacters each. 5441581SbosticThe first three characters are the permissions for the owner of the 5541581Sbosticfile, the second three for the group the file belongs to, and the 5641581Sbosticthird for the ``other'', or default, set of users. 5748351Scael.Pp 5841581SbosticPermission checking is done as specifically as possible. 5941581SbosticIf read permission is denied to the owner of a file in the first set 60*65099Smckusickof permissions, the owner of the file will not be able to read the file. 6141581SbosticThis is true even if the owner is in the file's group and the group 6241581Sbosticpermissions allow reading or the ``other'' permissions allow reading. 6348351Scael.Pp 6441581SbosticIf the first character of the three character set is an ``r'', the file is 6541581Sbosticreadable for that set of users; if a dash ``\-'', it is not readable. 6648351Scael.Pp 6741581SbosticIf the second character of the three character set is a ``w'', the file is 6841581Sbosticwritable for that set of users; if a dash ``\-'', it is not writable. 6948351Scael.Pp 7041581SbosticThe third character is the first of the following characters that apply: 7148351Scael.Bl -tag -width xxxx 7248351Scael.It S 7341581SbosticIf the character is part of the owner permissions and the file is not 74*65099Smckusickexecutable or the directory is not searchable by the owner, and the 7541581Sbosticset-user-id bit is set. 7648351Scael.It S 7741581SbosticIf the character is part of the group permissions and the file is not 78*65099Smckusickexecutable or the directory is not searchable by the group, and the 7941581Sbosticset-group-id bit is set. 8048351Scael.It T 8141581SbosticIf the character is part of the other permissions and the file is not 82*65099Smckusickexecutable or the directory is not searchable by others, and the ``sticky'' 8348351Scael.Pq Dv S_ISVTX 8448351Scaelbit is set. 8548351Scael.It s 8641581SbosticIf the character is part of the owner permissions and the file is 87*65099Smckusickexecutable or the directory searchable by the owner, and the set-user-id 8841581Sbosticbit is set. 8948351Scael.It s 9041581SbosticIf the character is part of the group permissions and the file is 91*65099Smckusickexecutable or the directory searchable by the group, and the set-group-id 9241581Sbosticbit is set. 9348351Scael.It t 9441581SbosticIf the character is part of the other permissions and the file is 95*65099Smckusickexecutable or the directory searchable by others, and the ``sticky'' 9648351Scael.Pq Dv S_ISVTX 9748351Scaelbit is set. 9848351Scael.It x 9941581SbosticThe file is executable or the directory is searchable. 10048351Scael.It \- 10141581SbosticNone of the above apply. 10248351Scael.El 10348351Scael.Pp 10441581SbosticThe last character is a plus sign ``+'' if any there are any alternate 10541581Sbosticor additional access control methods associated with the inode, otherwise 10641581Sbosticit will be a space. 10748351Scael.Sh RETURN VALUES 10848351ScaelThe 10948351Scael.Fn strmode 11048351Scaelfunction 11141581Sbosticalways returns 0. 11248351Scael.Sh SEE ALSO 11348351Scael.Xr chmod 1 , 11448351Scael.Xr find 1 , 11548351Scael.Xr stat 2 , 11648351Scael.Xr getmode 3 , 11748351Scael.Xr setmode 3 11848351Scael.Sh HISTORY 11948351ScaelThe 12048351Scael.Fn strmode 12162922Sbosticfunction first appeared in 4.4BSD. 122