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.3 1993/11/25 00:38:28 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 EINVAL 72The pathname contains a character with the high-order bit set. 73.It Bq Er ENAMETOOLONG 74A component of a pathname exceeded 255 characters, 75or an entire path name exceeded 1023 characters. 76.It Bq Er ENOENT 77The named file does not exist. 78.It Bq Er EACCES 79Search permission is denied for a component of the path prefix. 80.It Bq Er ELOOP 81Too many symbolic links were encountered in translating the pathname. 82.It Bq Er EPERM 83The effective user ID does not match the owner of the file and 84the effective user ID is not the super-user. 85.It Bq Er EROFS 86The named file resides on a read-only file system. 87.It Bq Er EFAULT 88.Fa Path 89points outside the process's allocated address space. 90.It Bq Er EIO 91An 92.Tn I/O 93error occurred while reading from or writing to the file system. 94.El 95.Pp 96.Fn Fchflags 97will fail if: 98.Bl -tag -width Er 99.It Bq Er EBADF 100The descriptor is not valid. 101.It Bq Er EINVAL 102.Fa Fd 103refers to a socket, not to a file. 104.It Bq Er EPERM 105The effective user ID does not match the owner of the file and 106the effective user ID is not the super-user. 107.It Bq Er EROFS 108The file resides on a read-only file system. 109.It Bq Er EIO 110An 111.Tn I/O 112error occurred while reading from or writing to the file system. 113.El 114.Sh SEE ALSO 115.Xr chmod 2 , 116.Xr open 2 , 117.Xr chown 2 , 118.Xr stat 2 119.Sh HISTORY 120The 121.Fn chflags 122and 123.Fn fchflags 124function calls are 125.Ud . 126