xref: /original-bsd/lib/libc/sys/chflags.2 (revision 6a39c8ab)
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.6 (Berkeley) 07/25/91
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 <unistd.h>
17.Ft int
18.Fn chflags "const char *path"  "long flags"
19.Ft int
20.Fn fchflags "int fd" "long flags"
21.Sh DESCRIPTION
22The file whose name
23is given by
24.Fa path
25or referenced by the descriptor
26.Fa fd
27has its flags changed to
28.Fa flags .
29.Pp
30Only the owner of a file (or the super-user) may change the flags.
31The owner may only change the lower 16 bits of the flags;
32the super-user may change all 32 bits of the flags.
33.Sh RETURN VALUES
34Upon successful completion, a value of 0 is returned.
35Otherwise, -1 is returned and the global variable
36.Va errno
37is set to indicate the error.
38.Sh ERRORS
39.Fn Chflags
40fails if:
41.Bl -tag -width Er
42.It Bq Er ENOTDIR
43A component of the path prefix is not a directory.
44.It Bq Er EINVAL
45The pathname contains a character with the high-order bit set.
46.It Bq Er ENAMETOOLONG
47A component of a pathname exceeded 255 characters,
48or an entire path name exceeded 1023 characters.
49.It Bq Er ENOENT
50The named file does not exist.
51.It Bq Er EACCES
52Search permission is denied for a component of the path prefix.
53.It Bq Er ELOOP
54Too many symbolic links were encountered in translating the pathname.
55.It Bq Er EPERM
56The effective user ID does not match the owner of the file and
57the effective user ID is not the super-user.
58.It Bq Er EROFS
59The named file resides on a read-only file system.
60.It Bq Er EFAULT
61.Fa Path
62points outside the process's allocated address space.
63.It Bq Er EIO
64An
65.Tn I/O
66error occurred while reading from or writing to the file system.
67.El
68.Pp
69.Fn Fchflags
70will fail if:
71.Bl -tag -width Er
72.It Bq Er EBADF
73The descriptor is not valid.
74.It Bq Er EINVAL
75.Fa Fd
76refers to a socket, not to a file.
77.It Bq Er EPERM
78The effective user ID does not match the owner of the file and
79the effective user ID is not the super-user.
80.It Bq Er EROFS
81The file resides on a read-only file system.
82.It Bq Er EIO
83An
84.Tn I/O
85error occurred while reading from or writing to the file system.
86.El
87.Sh SEE ALSO
88.Xr chmod 2 ,
89.Xr open 2 ,
90.Xr chown 2 ,
91.Xr stat 2
92.Sh HISTORY
93The
94.Nm chflags
95and
96.Nm fchflags
97function calls are
98.Ud .
99