Commit | Line | Data |
---|---|---|
4b89d5d6 KB |
1 | .\" Copyright (c) 1989, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
c334d3e6 | 3 | .\" |
faf7e3e0 | 4 | .\" %sccs.include.redist.roff% |
c334d3e6 | 5 | .\" |
4b89d5d6 | 6 | .\" @(#)chflags.2 8.1 (Berkeley) %G% |
c334d3e6 | 7 | .\" |
931b8415 | 8 | .Dd |
66a33ad7 | 9 | .Dt CHFLAGS 2 |
faf7e3e0 | 10 | .Os |
931b8415 CL |
11 | .Sh NAME |
12 | .Nm chflags , | |
13 | .Nm fchflags | |
14 | .Nd set file flags | |
15 | .Sh SYNOPSIS | |
0f511b0a | 16 | .Fd #include <sys/stat.h> |
931b8415 CL |
17 | .Fd #include <unistd.h> |
18 | .Ft int | |
0f511b0a | 19 | .Fn chflags "const char *path" "u_long flags" |
931b8415 | 20 | .Ft int |
0f511b0a | 21 | .Fn fchflags "int fd" "u_long flags" |
931b8415 | 22 | .Sh DESCRIPTION |
c334d3e6 | 23 | The file whose name |
931b8415 CL |
24 | is given by |
25 | .Fa path | |
c334d3e6 | 26 | or referenced by the descriptor |
931b8415 | 27 | .Fa fd |
c334d3e6 | 28 | has its flags changed to |
931b8415 CL |
29 | .Fa flags . |
30 | .Pp | |
13cd6a98 KB |
31 | The flags specified are formed by |
32 | .Em or Ns 'ing | |
33 | the following values | |
34 | .Pp | |
359e7bb4 KB |
35 | .Bl -tag -width "SF_IMMUTABLE" -compact -offset indent |
36 | .It UF_NODUMP | |
13cd6a98 | 37 | Do not dump the file. |
359e7bb4 | 38 | .It UF_IMMUTABLE |
13cd6a98 | 39 | The file may not be changed. |
359e7bb4 | 40 | .It UF_APPEND |
13cd6a98 KB |
41 | The file may only be appended to. |
42 | .\".It ARCHIVED | |
43 | .\"File is archived. | |
359e7bb4 | 44 | .It SF_IMMUTABLE |
13cd6a98 | 45 | The file may not be changed. |
359e7bb4 | 46 | .It SF_APPEND |
13cd6a98 KB |
47 | The file may only be appended to. |
48 | .El | |
49 | .Pp | |
50 | The | |
359e7bb4 | 51 | .Dq UF_IMMUTABLE |
13cd6a98 | 52 | and |
359e7bb4 | 53 | .Dq UF_APPEND |
13cd6a98 KB |
54 | flags may be set or unset by either the owner of a file or the super-user. |
55 | .Pp | |
56 | The | |
359e7bb4 | 57 | .Dq SF_IMMUTABLE |
13cd6a98 | 58 | and |
359e7bb4 | 59 | .Dq SF_APPEND |
13cd6a98 KB |
60 | flags may only be set or unset by the super-user. |
61 | They may be set at any time, but normally may only be unset when | |
62 | the system is in single-user mode. | |
63 | (See | |
64 | .Xr init 8 | |
65 | for details.) | |
931b8415 | 66 | .Sh RETURN VALUES |
c334d3e6 | 67 | Upon successful completion, a value of 0 is returned. |
931b8415 CL |
68 | Otherwise, -1 is returned and the global variable |
69 | .Va errno | |
c334d3e6 | 70 | is set to indicate the error. |
931b8415 CL |
71 | .Sh ERRORS |
72 | .Fn Chflags | |
13cd6a98 | 73 | will fail it: |
931b8415 CL |
74 | .Bl -tag -width Er |
75 | .It Bq Er ENOTDIR | |
c334d3e6 | 76 | A component of the path prefix is not a directory. |
931b8415 | 77 | .It Bq Er EINVAL |
c334d3e6 | 78 | The pathname contains a character with the high-order bit set. |
931b8415 | 79 | .It Bq Er ENAMETOOLONG |
c334d3e6 KM |
80 | A component of a pathname exceeded 255 characters, |
81 | or an entire path name exceeded 1023 characters. | |
931b8415 | 82 | .It Bq Er ENOENT |
c334d3e6 | 83 | The named file does not exist. |
931b8415 | 84 | .It Bq Er EACCES |
c334d3e6 | 85 | Search permission is denied for a component of the path prefix. |
931b8415 | 86 | .It Bq Er ELOOP |
c334d3e6 | 87 | Too many symbolic links were encountered in translating the pathname. |
931b8415 | 88 | .It Bq Er EPERM |
c334d3e6 KM |
89 | The effective user ID does not match the owner of the file and |
90 | the effective user ID is not the super-user. | |
931b8415 | 91 | .It Bq Er EROFS |
c334d3e6 | 92 | The named file resides on a read-only file system. |
931b8415 CL |
93 | .It Bq Er EFAULT |
94 | .Fa Path | |
c334d3e6 | 95 | points outside the process's allocated address space. |
931b8415 | 96 | .It Bq Er EIO |
faf7e3e0 CL |
97 | An |
98 | .Tn I/O | |
99 | error occurred while reading from or writing to the file system. | |
931b8415 CL |
100 | .El |
101 | .Pp | |
102 | .Fn Fchflags | |
c334d3e6 | 103 | will fail if: |
931b8415 CL |
104 | .Bl -tag -width Er |
105 | .It Bq Er EBADF | |
c334d3e6 | 106 | The descriptor is not valid. |
931b8415 CL |
107 | .It Bq Er EINVAL |
108 | .Fa Fd | |
c334d3e6 | 109 | refers to a socket, not to a file. |
931b8415 | 110 | .It Bq Er EPERM |
c334d3e6 KM |
111 | The effective user ID does not match the owner of the file and |
112 | the effective user ID is not the super-user. | |
931b8415 | 113 | .It Bq Er EROFS |
c334d3e6 | 114 | The file resides on a read-only file system. |
931b8415 | 115 | .It Bq Er EIO |
faf7e3e0 CL |
116 | An |
117 | .Tn I/O | |
118 | error occurred while reading from or writing to the file system. | |
931b8415 CL |
119 | .El |
120 | .Sh SEE ALSO | |
13cd6a98 KB |
121 | .Xr chflags 1, |
122 | .Xr init 8 | |
931b8415 CL |
123 | .Sh HISTORY |
124 | The | |
faf7e3e0 CL |
125 | .Nm chflags |
126 | and | |
127 | .Nm fchflags | |
8eca62d1 | 128 | functions first appeared in 4.4BSD. |