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