xref: /netbsd-src/lib/libc/sys/chflags.2 (revision ce63d6c20fc4ec8ddc95c84bb229e3c4ecf82b69)
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	@(#)chflags.2	6.6 (Berkeley) 7/25/91
33.\"
34.Dd July 25, 1991
35.Dt CHFLAGS 2
36.Os
37.Sh NAME
38.Nm chflags ,
39.Nm fchflags
40.Nd set file flags
41.Sh SYNOPSIS
42.Fd #include <unistd.h>
43.Ft int
44.Fn chflags "const char *path"  "long flags"
45.Ft int
46.Fn fchflags "int fd" "long flags"
47.Sh DESCRIPTION
48The file whose name
49is given by
50.Fa path
51or referenced by the descriptor
52.Fa fd
53has its flags changed to
54.Fa flags .
55.Pp
56Only the owner of a file (or the super-user) may change the flags.
57The owner may only change the lower 16 bits of the flags;
58the super-user may change all 32 bits of the flags.
59.Sh RETURN VALUES
60Upon successful completion, a value of 0 is returned.
61Otherwise, -1 is returned and the global variable
62.Va errno
63is set to indicate the error.
64.Sh ERRORS
65.Fn Chflags
66fails if:
67.Bl -tag -width Er
68.It Bq Er ENOTDIR
69A component of the path prefix is not a directory.
70.It Bq Er EINVAL
71The pathname contains a character with the high-order bit set.
72.It Bq Er ENAMETOOLONG
73A component of a pathname exceeded 255 characters,
74or an entire path name exceeded 1023 characters.
75.It Bq Er ENOENT
76The named file does not exist.
77.It Bq Er EACCES
78Search permission is denied for a component of the path prefix.
79.It Bq Er ELOOP
80Too many symbolic links were encountered in translating the pathname.
81.It Bq Er EPERM
82The effective user ID does not match the owner of the file and
83the effective user ID is not the super-user.
84.It Bq Er EROFS
85The named file resides on a read-only file system.
86.It Bq Er EFAULT
87.Fa Path
88points outside the process's allocated address space.
89.It Bq Er EIO
90An
91.Tn I/O
92error occurred while reading from or writing to the file system.
93.El
94.Pp
95.Fn Fchflags
96will fail if:
97.Bl -tag -width Er
98.It Bq Er EBADF
99The descriptor is not valid.
100.It Bq Er EINVAL
101.Fa Fd
102refers to a socket, not to a file.
103.It Bq Er EPERM
104The effective user ID does not match the owner of the file and
105the effective user ID is not the super-user.
106.It Bq Er EROFS
107The file resides on a read-only file system.
108.It Bq Er EIO
109An
110.Tn I/O
111error occurred while reading from or writing to the file system.
112.El
113.Sh SEE ALSO
114.Xr chmod 2 ,
115.Xr open 2 ,
116.Xr chown 2 ,
117.Xr stat 2
118.Sh HISTORY
119The
120.Nm chflags
121and
122.Nm fchflags
123function calls are
124.Ud .
125