xref: /minix3/lib/libc/sys/chflags.2 (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc.\"	$NetBSD: chflags.2,v 1.28 2013/06/08 06:05:03 kardel Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 1989, 1993
42fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
152fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
162fe8fb19SBen Gras.\"    without specific prior written permission.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
192fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
222fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
252fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282fe8fb19SBen Gras.\" SUCH DAMAGE.
292fe8fb19SBen Gras.\"
302fe8fb19SBen Gras.\"	@(#)chflags.2	8.3 (Berkeley) 5/2/95
312fe8fb19SBen Gras.\"
32f14fb602SLionel Sambuc.Dd August 6, 2011
332fe8fb19SBen Gras.Dt CHFLAGS 2
342fe8fb19SBen Gras.Os
352fe8fb19SBen Gras.Sh NAME
362fe8fb19SBen Gras.Nm chflags ,
372fe8fb19SBen Gras.Nm lchflags ,
382fe8fb19SBen Gras.Nm fchflags
392fe8fb19SBen Gras.Nd set file flags
402fe8fb19SBen Gras.Sh LIBRARY
412fe8fb19SBen Gras.Lb libc
422fe8fb19SBen Gras.Sh SYNOPSIS
432fe8fb19SBen Gras.In sys/stat.h
442fe8fb19SBen Gras.In unistd.h
452fe8fb19SBen Gras.Ft int
462fe8fb19SBen Gras.Fn chflags "const char *path"  "u_long flags"
472fe8fb19SBen Gras.Ft int
482fe8fb19SBen Gras.Fn lchflags "const char *path"  "u_long flags"
492fe8fb19SBen Gras.Ft int
502fe8fb19SBen Gras.Fn fchflags "int fd" "u_long flags"
512fe8fb19SBen Gras.Sh DESCRIPTION
522fe8fb19SBen GrasThe file whose name
532fe8fb19SBen Grasis given by
542fe8fb19SBen Gras.Fa path
552fe8fb19SBen Grasor referenced by the descriptor
562fe8fb19SBen Gras.Fa fd
572fe8fb19SBen Grashas its flags changed to
582fe8fb19SBen Gras.Fa flags .
592fe8fb19SBen GrasFor
602fe8fb19SBen Gras.Fn lchflags ,
612fe8fb19SBen Grassymbolic links are not traversed and thus their modes may be changed with
622fe8fb19SBen Grasthis call.
632fe8fb19SBen Gras.Pp
642fe8fb19SBen GrasThe flags specified are formed by
652fe8fb19SBen Gras.Em or Ns 'ing
662fe8fb19SBen Grasthe following values:
672fe8fb19SBen Gras.Pp
682fe8fb19SBen Gras.Bl -tag -width "SF_IMMUTABLE" -compact -offset indent
692fe8fb19SBen Gras.It Dv UF_NODUMP
702fe8fb19SBen GrasDo not dump the file.
712fe8fb19SBen Gras.It Dv UF_IMMUTABLE
722fe8fb19SBen GrasThe file may not be changed.
732fe8fb19SBen Gras.It Dv UF_APPEND
742fe8fb19SBen GrasThe file may only be appended to.
752fe8fb19SBen Gras.It Dv UF_OPAQUE
762fe8fb19SBen GrasThe file (if a directory) is opaque for union mounts.
772fe8fb19SBen Gras.It Dv SF_ARCHIVED
782fe8fb19SBen GrasThe file is archived.
792fe8fb19SBen Gras.It Dv SF_IMMUTABLE
802fe8fb19SBen GrasThe file may not be changed.
812fe8fb19SBen Gras.It Dv SF_APPEND
822fe8fb19SBen GrasThe file may only be appended to.
832fe8fb19SBen Gras.El
842fe8fb19SBen Gras.Pp
852fe8fb19SBen GrasThe
862fe8fb19SBen Gras.Dv UF_NODUMP ,
872fe8fb19SBen Gras.Dv UF_IMMUTABLE ,
882fe8fb19SBen Gras.Dv UF_APPEND ,
892fe8fb19SBen Grasand
902fe8fb19SBen Gras.Dv UF_OPAQUE
912fe8fb19SBen Grasflags may be set or unset by either the owner of a file or the super-user,
922fe8fb19SBen Grasexcept on block and character devices, where only the super-user may set
932fe8fb19SBen Grasor unset them.
942fe8fb19SBen Gras.Pp
952fe8fb19SBen GrasThe
962fe8fb19SBen Gras.Dv SF_ARCHIVED ,
972fe8fb19SBen Gras.Dv SF_IMMUTABLE ,
982fe8fb19SBen Grasand
992fe8fb19SBen Gras.Dv SF_APPEND
1002fe8fb19SBen Grasflags may only be set or unset by the super-user.
1012fe8fb19SBen GrasThese flags may be set at any time, but normally may only be unset when
1022fe8fb19SBen Grasthe system is in single-user mode.
1032fe8fb19SBen Gras(See
1042fe8fb19SBen Gras.Xr init 8
1052fe8fb19SBen Grasfor details.)
1062fe8fb19SBen Gras.Sh RETURN VALUES
1072fe8fb19SBen GrasUpon successful completion, a value of 0 is returned.
1082fe8fb19SBen GrasOtherwise, \-1 is returned and the global variable
1092fe8fb19SBen Gras.Va errno
1102fe8fb19SBen Grasis set to indicate the error.
1112fe8fb19SBen Gras.Sh ERRORS
1122fe8fb19SBen Gras.Fn chflags
1132fe8fb19SBen Graswill fail if:
1142fe8fb19SBen Gras.Bl -tag -width Er
1152fe8fb19SBen Gras.It Bq Er ENOTDIR
1162fe8fb19SBen GrasA component of the path prefix is not a directory.
1172fe8fb19SBen Gras.It Bq Er ENAMETOOLONG
1182fe8fb19SBen GrasA component of a pathname exceeded
1192fe8fb19SBen Gras.Brq Dv NAME_MAX
1202fe8fb19SBen Grascharacters, or an entire path name exceeded
1212fe8fb19SBen Gras.Brq Dv PATH_MAX
1222fe8fb19SBen Grascharacters.
1232fe8fb19SBen Gras.It Bq Er ENOENT
1242fe8fb19SBen GrasThe named file does not exist.
1252fe8fb19SBen Gras.It Bq Er EACCES
1262fe8fb19SBen GrasSearch permission is denied for a component of the path prefix.
1272fe8fb19SBen Gras.It Bq Er ELOOP
1282fe8fb19SBen GrasToo many symbolic links were encountered in translating the pathname.
1292fe8fb19SBen Gras.It Bq Er EPERM
1302fe8fb19SBen GrasThe effective user ID does not match the owner of the file and
1312fe8fb19SBen Grasthe effective user ID is not the super-user, or
1322fe8fb19SBen Grasthe effective user ID is not the super-user and one or more of the
1332fe8fb19SBen Grassuper-user-only flags for the named file would be changed.
1342fe8fb19SBen Gras.It Bq Er EOPNOTSUPP
1352fe8fb19SBen GrasThe named file resides on a file system that does not support file
1362fe8fb19SBen Grasflags.
1372fe8fb19SBen Gras.It Bq Er EROFS
1382fe8fb19SBen GrasThe named file resides on a read-only file system.
1392fe8fb19SBen Gras.It Bq Er EFAULT
1402fe8fb19SBen Gras.Fa path
1412fe8fb19SBen Graspoints outside the process's allocated address space.
1422fe8fb19SBen Gras.It Bq Er EIO
1432fe8fb19SBen GrasAn
1442fe8fb19SBen Gras.Tn I/O
1452fe8fb19SBen Graserror occurred while reading from or writing to the file system.
1462fe8fb19SBen Gras.El
1472fe8fb19SBen Gras.Pp
1482fe8fb19SBen Gras.Fn fchflags
1492fe8fb19SBen Graswill fail if:
1502fe8fb19SBen Gras.Bl -tag -width Er
1512fe8fb19SBen Gras.It Bq Er EBADF
1522fe8fb19SBen GrasThe descriptor is not valid.
1532fe8fb19SBen Gras.It Bq Er EINVAL
1542fe8fb19SBen Gras.Fa fd
1552fe8fb19SBen Grasrefers to a socket, not to a file.
1562fe8fb19SBen Gras.It Bq Er EPERM
1572fe8fb19SBen GrasThe effective user ID does not match the owner of the file and
1582fe8fb19SBen Grasthe effective user ID is not the super-user, or
1592fe8fb19SBen Grasthe effective user ID is not the super-user and one or more of the
1602fe8fb19SBen Grassuper-user-only flags for the file would be changed.
1612fe8fb19SBen Gras.It Bq Er EOPNOTSUPP
1622fe8fb19SBen GrasThe file resides on a file system that does not support file flags.
1632fe8fb19SBen Gras.It Bq Er EROFS
1642fe8fb19SBen GrasThe file resides on a read-only file system.
1652fe8fb19SBen Gras.It Bq Er EIO
1662fe8fb19SBen GrasAn
1672fe8fb19SBen Gras.Tn I/O
1682fe8fb19SBen Graserror occurred while reading from or writing to the file system.
1692fe8fb19SBen Gras.El
1702fe8fb19SBen Gras.Sh SEE ALSO
1712fe8fb19SBen Gras.Xr chflags 1 ,
1722fe8fb19SBen Gras.Xr stat 2 ,
173f14fb602SLionel Sambuc.Xr stat_flags 3 ,
1742fe8fb19SBen Gras.Xr init 8 ,
1752fe8fb19SBen Gras.Xr mount_union 8
1762fe8fb19SBen Gras.Sh HISTORY
1772fe8fb19SBen GrasThe
1782fe8fb19SBen Gras.Fn chflags
1792fe8fb19SBen Grasand
1802fe8fb19SBen Gras.Fn fchflags
1812fe8fb19SBen Grasfunctions first appeared in
1822fe8fb19SBen Gras.Bx 4.4 .
1832fe8fb19SBen GrasThe
1842fe8fb19SBen Gras.Fn lchflags
1852fe8fb19SBen Grasfunction first appeared in
1862fe8fb19SBen Gras.Nx 1.5 .
187