1.\" Copyright (c) 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)strmode.3 8.2 (Berkeley) 12/11/93 7.\" 8.Dd 9.Dt STRMODE 3 10.Os 11.Sh NAME 12.Nm strmode 13.Nd convert inode status information into a symbolic string 14.Sh SYNOPSIS 15.Fd #include <string.h> 16.Ft void 17.Fn strmode "mode_t mode" "char *bp" 18.Sh DESCRIPTION 19The 20.Fn strmode 21function 22converts a file 23.Fa mode 24(the type and permission information associated with an inode, see 25.Xr stat 2 ) 26into a symbolic string which is stored in the location referenced by 27.Fa bp . 28This stored string is eleven characters in length plus a trailing 29.Dv NULL . 30.Pp 31The first character is the inode type, and will be one of the following: 32.Pp 33.Bl -tag -width flag -offset indent -compact 34.It \- 35regular file 36.It b 37block special 38.It c 39character special 40.It d 41directory 42.It l 43symbolic link 44.It p 45fifo 46.It s 47socket 48.It ? 49unknown inode type 50.El 51.Pp 52The next nine characters encode three sets of permissions, in three 53characters each. 54The first three characters are the permissions for the owner of the 55file, the second three for the group the file belongs to, and the 56third for the ``other'', or default, set of users. 57.Pp 58Permission checking is done as specifically as possible. 59If read permission is denied to the owner of a file in the first set 60of permissions, the owner of the file will not be able to read the file. 61This is true even if the owner is in the file's group and the group 62permissions allow reading or the ``other'' permissions allow reading. 63.Pp 64If the first character of the three character set is an ``r'', the file is 65readable for that set of users; if a dash ``\-'', it is not readable. 66.Pp 67If the second character of the three character set is a ``w'', the file is 68writable for that set of users; if a dash ``\-'', it is not writable. 69.Pp 70The third character is the first of the following characters that apply: 71.Bl -tag -width xxxx 72.It S 73If the character is part of the owner permissions and the file is not 74executable or the directory is not searchable by the owner, and the 75set-user-id bit is set. 76.It S 77If the character is part of the group permissions and the file is not 78executable or the directory is not searchable by the group, and the 79set-group-id bit is set. 80.It T 81If the character is part of the other permissions and the file is not 82executable or the directory is not searchable by others, and the ``sticky'' 83.Pq Dv S_ISVTX 84bit is set. 85.It s 86If the character is part of the owner permissions and the file is 87executable or the directory searchable by the owner, and the set-user-id 88bit is set. 89.It s 90If the character is part of the group permissions and the file is 91executable or the directory searchable by the group, and the set-group-id 92bit is set. 93.It t 94If the character is part of the other permissions and the file is 95executable or the directory searchable by others, and the ``sticky'' 96.Pq Dv S_ISVTX 97bit is set. 98.It x 99The file is executable or the directory is searchable. 100.It \- 101None of the above apply. 102.El 103.Pp 104The last character is a plus sign ``+'' if any there are any alternate 105or additional access control methods associated with the inode, otherwise 106it will be a space. 107.Sh RETURN VALUES 108The 109.Fn strmode 110function 111always returns 0. 112.Sh SEE ALSO 113.Xr chmod 1 , 114.Xr find 1 , 115.Xr stat 2 , 116.Xr getmode 3 , 117.Xr setmode 3 118.Sh HISTORY 119The 120.Fn strmode 121function first appeared in 4.4BSD. 122