1.\" Copyright (c) 1989, 1993 2.\" The Regents of the University of California. 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 8.1 (Berkeley) 6/9/93 33.\" 34.Dd June 9, 1993 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 <sys/stat.h> 43.Fd #include <unistd.h> 44.Ft int 45.Fn chflags "const char *path" "u_long flags" 46.Ft int 47.Fn fchflags "int fd" "u_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 57The flags specified are formed by 58.Em or Ns 'ing 59the following values 60.Pp 61.Bl -tag -width "SF_IMMUTABLE" -compact -offset indent 62.It UF_NODUMP 63Do not dump the file. 64.It UF_IMMUTABLE 65The file may not be changed. 66.It UF_APPEND 67The file may only be appended to. 68.\".It ARCHIVED 69.\"File is archived. 70.It SF_IMMUTABLE 71The file may not be changed. 72.It SF_APPEND 73The file may only be appended to. 74.El 75.Pp 76The 77.Dq UF_IMMUTABLE 78and 79.Dq UF_APPEND 80flags may be set or unset by either the owner of a file or the super-user. 81.Pp 82The 83.Dq SF_IMMUTABLE 84and 85.Dq SF_APPEND 86flags may only be set or unset by the super-user. 87They may be set at any time, but normally may only be unset when 88the system is in single-user mode. 89(See 90.Xr init 8 91for details.) 92.Sh RETURN VALUES 93Upon successful completion, a value of 0 is returned. 94Otherwise, -1 is returned and the global variable 95.Va errno 96is set to indicate the error. 97.Sh ERRORS 98.Fn Chflags 99will fail it: 100.Bl -tag -width Er 101.It Bq Er ENOTDIR 102A component of the path prefix is not a directory. 103.It Bq Er EINVAL 104The pathname contains a character with the high-order bit set. 105.It Bq Er ENAMETOOLONG 106A component of a pathname exceeded 255 characters, 107or an entire path name exceeded 1023 characters. 108.It Bq Er ENOENT 109The named file does not exist. 110.It Bq Er EACCES 111Search permission is denied for a component of the path prefix. 112.It Bq Er ELOOP 113Too many symbolic links were encountered in translating the pathname. 114.It Bq Er EPERM 115The effective user ID does not match the owner of the file and 116the effective user ID is not the super-user. 117.It Bq Er EROFS 118The named file resides on a read-only file system. 119.It Bq Er EFAULT 120.Fa Path 121points outside the process's allocated address space. 122.It Bq Er EIO 123An 124.Tn I/O 125error occurred while reading from or writing to the file system. 126.El 127.Pp 128.Fn Fchflags 129will fail if: 130.Bl -tag -width Er 131.It Bq Er EBADF 132The descriptor is not valid. 133.It Bq Er EINVAL 134.Fa Fd 135refers to a socket, not to a file. 136.It Bq Er EPERM 137The effective user ID does not match the owner of the file and 138the effective user ID is not the super-user. 139.It Bq Er EROFS 140The file resides on a read-only file system. 141.It Bq Er EIO 142An 143.Tn I/O 144error occurred while reading from or writing to the file system. 145.El 146.Sh SEE ALSO 147.Xr chflags 1, 148.Xr init 8 149.Sh HISTORY 150The 151.Nm chflags 152and 153.Nm fchflags 154functions first appeared in 4.4BSD. 155