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