xref: /original-bsd/lib/libc/sys/chflags.2 (revision deff14a8)
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.2 (Berkeley) 07/28/94
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.
63They may be set at any time, but normally may only be unset when
64the system is in single-user mode.
65(See
66.Xr init 8
67for details.)
68.Sh RETURN VALUES
69Upon successful completion, a value of 0 is returned.
70Otherwise, -1 is returned and the global variable
71.Va errno
72is set to indicate the error.
73.Sh ERRORS
74.Fn Chflags
75will fail it:
76.Bl -tag -width Er
77.It Bq Er ENOTDIR
78A component of the path prefix is not a directory.
79.It Bq Er EINVAL
80The pathname contains a character with the high-order bit set.
81.It Bq Er ENAMETOOLONG
82A component of a pathname exceeded 255 characters,
83or an entire path name exceeded 1023 characters.
84.It Bq Er ENOENT
85The named file does not exist.
86.It Bq Er EACCES
87Search permission is denied for a component of the path prefix.
88.It Bq Er ELOOP
89Too many symbolic links were encountered in translating the pathname.
90.It Bq Er EPERM
91The effective user ID does not match the owner of the file and
92the effective user ID is not the super-user.
93.It Bq Er EROFS
94The named file resides on a read-only file system.
95.It Bq Er EFAULT
96.Fa Path
97points outside the process's allocated address space.
98.It Bq Er EIO
99An
100.Tn I/O
101error occurred while reading from or writing to the file system.
102.El
103.Pp
104.Fn Fchflags
105will fail if:
106.Bl -tag -width Er
107.It Bq Er EBADF
108The descriptor is not valid.
109.It Bq Er EINVAL
110.Fa Fd
111refers to a socket, not to a file.
112.It Bq Er EPERM
113The effective user ID does not match the owner of the file and
114the effective user ID is not the super-user.
115.It Bq Er EROFS
116The file resides on a read-only file system.
117.It Bq Er EIO
118An
119.Tn I/O
120error occurred while reading from or writing to the file system.
121.El
122.Sh SEE ALSO
123.Xr chflags 1 ,
124.Xr init 8 ,
125.Xr mount_union 8
126.Sh HISTORY
127The
128.Nm chflags
129and
130.Nm fchflags
131functions first appeared in 4.4BSD.
132