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