xref: /original-bsd/lib/libc/sys/chflags.2 (revision c4695039)
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"	@(#)chflags.2	6.9 (Berkeley) 03/04/93
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 ARCHIVED
43.\"File is archived.
44.It SF_IMMUTABLE
45The file may not be changed.
46.It SF_APPEND
47The file may only be appended to.
48.El
49.Pp
50The
51.Dq UF_IMMUTABLE
52and
53.Dq UF_APPEND
54flags may be set or unset by either the owner of a file or the super-user.
55.Pp
56The
57.Dq SF_IMMUTABLE
58and
59.Dq SF_APPEND
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.)
66.Sh RETURN VALUES
67Upon successful completion, a value of 0 is returned.
68Otherwise, -1 is returned and the global variable
69.Va errno
70is set to indicate the error.
71.Sh ERRORS
72.Fn Chflags
73will fail it:
74.Bl -tag -width Er
75.It Bq Er ENOTDIR
76A component of the path prefix is not a directory.
77.It Bq Er EINVAL
78The pathname contains a character with the high-order bit set.
79.It Bq Er ENAMETOOLONG
80A component of a pathname exceeded 255 characters,
81or an entire path name exceeded 1023 characters.
82.It Bq Er ENOENT
83The named file does not exist.
84.It Bq Er EACCES
85Search permission is denied for a component of the path prefix.
86.It Bq Er ELOOP
87Too many symbolic links were encountered in translating the pathname.
88.It Bq Er EPERM
89The effective user ID does not match the owner of the file and
90the effective user ID is not the super-user.
91.It Bq Er EROFS
92The named file resides on a read-only file system.
93.It Bq Er EFAULT
94.Fa Path
95points outside the process's allocated address space.
96.It Bq Er EIO
97An
98.Tn I/O
99error occurred while reading from or writing to the file system.
100.El
101.Pp
102.Fn Fchflags
103will fail if:
104.Bl -tag -width Er
105.It Bq Er EBADF
106The descriptor is not valid.
107.It Bq Er EINVAL
108.Fa Fd
109refers to a socket, not to a file.
110.It Bq Er EPERM
111The effective user ID does not match the owner of the file and
112the effective user ID is not the super-user.
113.It Bq Er EROFS
114The file resides on a read-only file system.
115.It Bq Er EIO
116An
117.Tn I/O
118error occurred while reading from or writing to the file system.
119.El
120.Sh SEE ALSO
121.Xr chflags 1,
122.Xr init 8
123.Sh HISTORY
124The
125.Nm chflags
126and
127.Nm fchflags
128function calls are
129.Ud .
130