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.\" from: @(#)chflags.2 6.6 (Berkeley) 7/25/91 33.\" $Id: chflags.2,v 1.5 1994/04/22 00:13:27 jtc Exp $ 34.\" 35.Dd July 25, 1991 36.Dt CHFLAGS 2 37.Os 38.Sh NAME 39.Nm chflags , 40.Nm fchflags 41.Nd set file flags 42.Sh SYNOPSIS 43.Fd #include <unistd.h> 44.Ft int 45.Fn chflags "const char *path" "long flags" 46.Ft int 47.Fn fchflags "int fd" "long flags" 48.Sh DESCRIPTION 49The file whose name 50is given by 51.Fa path 52or referenced by the descriptor 53.Fa fd 54has its flags changed to 55.Fa flags . 56.Pp 57Only the owner of a file (or the super-user) may change the flags. 58The owner may only change the lower 16 bits of the flags; 59the super-user may change all 32 bits of the flags. 60.Sh RETURN VALUES 61Upon successful completion, a value of 0 is returned. 62Otherwise, -1 is returned and the global variable 63.Va errno 64is set to indicate the error. 65.Sh ERRORS 66.Fn Chflags 67fails if: 68.Bl -tag -width Er 69.It Bq Er ENOTDIR 70A component of the path prefix is not a directory. 71.It Bq Er ENAMETOOLONG 72A component of a pathname exceeded 73.Dv {NAME_MAX} 74characters, or an entire path name exceeded 75.Dv {PATH_MAX} 76characters. 77.It Bq Er ENOENT 78The named file does not exist. 79.It Bq Er EACCES 80Search permission is denied for a component of the path prefix. 81.It Bq Er ELOOP 82Too many symbolic links were encountered in translating the pathname. 83.It Bq Er EPERM 84The effective user ID does not match the owner of the file and 85the effective user ID is not the super-user. 86.It Bq Er EROFS 87The named file resides on a read-only file system. 88.It Bq Er EFAULT 89.Fa Path 90points outside the process's allocated address space. 91.It Bq Er EIO 92An 93.Tn I/O 94error occurred while reading from or writing to the file system. 95.El 96.Pp 97.Fn Fchflags 98will fail if: 99.Bl -tag -width Er 100.It Bq Er EBADF 101The descriptor is not valid. 102.It Bq Er EINVAL 103.Fa Fd 104refers to a socket, not to a file. 105.It Bq Er EPERM 106The effective user ID does not match the owner of the file and 107the effective user ID is not the super-user. 108.It Bq Er EROFS 109The file resides on a read-only file system. 110.It Bq Er EIO 111An 112.Tn I/O 113error occurred while reading from or writing to the file system. 114.El 115.Sh SEE ALSO 116.Xr chmod 2 , 117.Xr open 2 , 118.Xr chown 2 , 119.Xr stat 2 120.Sh HISTORY 121The 122.Fn chflags 123and 124.Fn fchflags 125function calls are 126.Ud . 127