it's used now, it's also a u_long
[unix-history] / usr / src / lib / libc / sys / chflags.2
CommitLineData
c334d3e6
KM
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
faf7e3e0 4.\" %sccs.include.redist.roff%
c334d3e6 5.\"
66a33ad7 6.\" @(#)chflags.2 6.6 (Berkeley) %G%
c334d3e6 7.\"
931b8415 8.Dd
66a33ad7 9.Dt CHFLAGS 2
faf7e3e0 10.Os
931b8415
CL
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
c334d3e6 22The file whose name
931b8415
CL
23is given by
24.Fa path
c334d3e6 25or referenced by the descriptor
931b8415 26.Fa fd
c334d3e6 27has its flags changed to
931b8415
CL
28.Fa flags .
29.Pp
c334d3e6
KM
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.
931b8415 33.Sh RETURN VALUES
c334d3e6 34Upon successful completion, a value of 0 is returned.
931b8415
CL
35Otherwise, -1 is returned and the global variable
36.Va errno
c334d3e6 37is set to indicate the error.
931b8415
CL
38.Sh ERRORS
39.Fn Chflags
40fails if:
41.Bl -tag -width Er
42.It Bq Er ENOTDIR
c334d3e6 43A component of the path prefix is not a directory.
931b8415 44.It Bq Er EINVAL
c334d3e6 45The pathname contains a character with the high-order bit set.
931b8415 46.It Bq Er ENAMETOOLONG
c334d3e6
KM
47A component of a pathname exceeded 255 characters,
48or an entire path name exceeded 1023 characters.
931b8415 49.It Bq Er ENOENT
c334d3e6 50The named file does not exist.
931b8415 51.It Bq Er EACCES
c334d3e6 52Search permission is denied for a component of the path prefix.
931b8415 53.It Bq Er ELOOP
c334d3e6 54Too many symbolic links were encountered in translating the pathname.
931b8415 55.It Bq Er EPERM
c334d3e6
KM
56The effective user ID does not match the owner of the file and
57the effective user ID is not the super-user.
931b8415 58.It Bq Er EROFS
c334d3e6 59The named file resides on a read-only file system.
931b8415
CL
60.It Bq Er EFAULT
61.Fa Path
c334d3e6 62points outside the process's allocated address space.
931b8415 63.It Bq Er EIO
faf7e3e0
CL
64An
65.Tn I/O
66error occurred while reading from or writing to the file system.
931b8415
CL
67.El
68.Pp
69.Fn Fchflags
c334d3e6 70will fail if:
931b8415
CL
71.Bl -tag -width Er
72.It Bq Er EBADF
c334d3e6 73The descriptor is not valid.
931b8415
CL
74.It Bq Er EINVAL
75.Fa Fd
c334d3e6 76refers to a socket, not to a file.
931b8415 77.It Bq Er EPERM
c334d3e6
KM
78The effective user ID does not match the owner of the file and
79the effective user ID is not the super-user.
931b8415 80.It Bq Er EROFS
c334d3e6 81The file resides on a read-only file system.
931b8415 82.It Bq Er EIO
faf7e3e0
CL
83An
84.Tn I/O
85error occurred while reading from or writing to the file system.
931b8415
CL
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
faf7e3e0
CL
94.Nm chflags
95and
96.Nm fchflags
97function calls are
98.Ud .