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