162901Sbostic.\" Copyright (c) 1989, 1993 262901Sbostic.\" The Regents of the University of California. All rights reserved. 338244Smckusick.\" 450487Scael.\" %sccs.include.redist.roff% 538244Smckusick.\" 6*69173Smckusick.\" @(#)chflags.2 8.3 (Berkeley) 05/02/95 738244Smckusick.\" 847208Scael.Dd 950540Scael.Dt CHFLAGS 2 1050487Scael.Os 1147208Scael.Sh NAME 1247208Scael.Nm chflags , 1347208Scael.Nm fchflags 1447208Scael.Nd set file flags 1547208Scael.Sh SYNOPSIS 1658426Sbostic.Fd #include <sys/stat.h> 1747208Scael.Fd #include <unistd.h> 1847208Scael.Ft int 1958426Sbostic.Fn chflags "const char *path" "u_long flags" 2047208Scael.Ft int 2158426Sbostic.Fn fchflags "int fd" "u_long flags" 2247208Scael.Sh DESCRIPTION 2338244SmckusickThe file whose name 2447208Scaelis given by 2547208Scael.Fa path 2638244Smckusickor referenced by the descriptor 2747208Scael.Fa fd 2838244Smckusickhas its flags changed to 2947208Scael.Fa flags . 3047208Scael.Pp 3158430SbosticThe flags specified are formed by 3258430Sbostic.Em or Ns 'ing 3358430Sbosticthe following values 3458430Sbostic.Pp 3558454Sbostic.Bl -tag -width "SF_IMMUTABLE" -compact -offset indent 3658454Sbostic.It UF_NODUMP 3758430SbosticDo not dump the file. 3858454Sbostic.It UF_IMMUTABLE 3958430SbosticThe file may not be changed. 4058454Sbostic.It UF_APPEND 4158430SbosticThe file may only be appended to. 4267575Spendry.It UF_OPAQUE 4367575SpendryThe directory is opaque when viewed through a union stack. 4458430Sbostic.\".It ARCHIVED 4558430Sbostic.\"File is archived. 4658454Sbostic.It SF_IMMUTABLE 4758430SbosticThe file may not be changed. 4858454Sbostic.It SF_APPEND 4958430SbosticThe file may only be appended to. 5058430Sbostic.El 5158430Sbostic.Pp 5258430SbosticThe 5358454Sbostic.Dq UF_IMMUTABLE 5458430Sbosticand 5558454Sbostic.Dq UF_APPEND 5658430Sbosticflags may be set or unset by either the owner of a file or the super-user. 5758430Sbostic.Pp 5858430SbosticThe 5958454Sbostic.Dq SF_IMMUTABLE 6058430Sbosticand 6158454Sbostic.Dq SF_APPEND 6258430Sbosticflags may only be set or unset by the super-user. 63*69173SmckusickAttempts by the non-super-user to set the super-user only flags 64*69173Smckusickare silently ignored. 65*69173SmckusickThese flags may be set at any time, but normally may only be unset when 6658430Sbosticthe system is in single-user mode. 6758430Sbostic(See 6858430Sbostic.Xr init 8 6958430Sbosticfor details.) 7047208Scael.Sh RETURN VALUES 7138244SmckusickUpon successful completion, a value of 0 is returned. 7247208ScaelOtherwise, -1 is returned and the global variable 7347208Scael.Va errno 7438244Smckusickis set to indicate the error. 7547208Scael.Sh ERRORS 7647208Scael.Fn Chflags 7758430Sbosticwill fail it: 7847208Scael.Bl -tag -width Er 7947208Scael.It Bq Er ENOTDIR 8038244SmckusickA component of the path prefix is not a directory. 8147208Scael.It Bq Er EINVAL 8238244SmckusickThe pathname contains a character with the high-order bit set. 8347208Scael.It Bq Er ENAMETOOLONG 8438244SmckusickA component of a pathname exceeded 255 characters, 8538244Smckusickor an entire path name exceeded 1023 characters. 8647208Scael.It Bq Er ENOENT 8738244SmckusickThe named file does not exist. 8847208Scael.It Bq Er EACCES 8938244SmckusickSearch permission is denied for a component of the path prefix. 9047208Scael.It Bq Er ELOOP 9138244SmckusickToo many symbolic links were encountered in translating the pathname. 9247208Scael.It Bq Er EPERM 9338244SmckusickThe effective user ID does not match the owner of the file and 9438244Smckusickthe effective user ID is not the super-user. 9547208Scael.It Bq Er EROFS 9638244SmckusickThe named file resides on a read-only file system. 9747208Scael.It Bq Er EFAULT 9847208Scael.Fa Path 9938244Smckusickpoints outside the process's allocated address space. 10047208Scael.It Bq Er EIO 10150487ScaelAn 10250487Scael.Tn I/O 10350487Scaelerror occurred while reading from or writing to the file system. 10447208Scael.El 10547208Scael.Pp 10647208Scael.Fn Fchflags 10738244Smckusickwill fail if: 10847208Scael.Bl -tag -width Er 10947208Scael.It Bq Er EBADF 11038244SmckusickThe descriptor is not valid. 11147208Scael.It Bq Er EINVAL 11247208Scael.Fa Fd 11338244Smckusickrefers to a socket, not to a file. 11447208Scael.It Bq Er EPERM 11538244SmckusickThe effective user ID does not match the owner of the file and 11638244Smckusickthe effective user ID is not the super-user. 11747208Scael.It Bq Er EROFS 11838244SmckusickThe file resides on a read-only file system. 11947208Scael.It Bq Er EIO 12050487ScaelAn 12150487Scael.Tn I/O 12250487Scaelerror occurred while reading from or writing to the file system. 12347208Scael.El 12447208Scael.Sh SEE ALSO 12567575Spendry.Xr chflags 1 , 12667575Spendry.Xr init 8 , 12767575Spendry.Xr mount_union 8 12847208Scael.Sh HISTORY 12947208ScaelThe 13050487Scael.Nm chflags 13150487Scaeland 13250487Scael.Nm fchflags 13362900Sbosticfunctions first appeared in 4.4BSD. 134