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