Subject: chflags - immutable|appendonly files come to 2BSD (#199 - Part 3 of 14) Index: bin,etc,lib,sys/many_files 2.11BSD Description: Files/directories can not be declared append-only, immutable, archived or not to be dumped under 2.11BSD. dump(8) lacked the ability to bypass files marked for 'nodump'. Upper case only and Hazeltine terminal support made the tty driver (and several utilities - 'vi' and 'getty' to name two) needlessly complicated and larger (especially since those devices are obsolete). open(2) can not provide for atomically obtaining a flock(2)'d file descriptor. open(2)ing with O_NDELAY (now called O_NONBLOCK) would not wait for carrier on the first i/o operation. Obsolete stub system calls 'setdopt' and 'getdopt' were still present in the kernel even though they have never done anything except take up space. Repeat-By: This section does not apply this time since this is an 'update' which adds new functionality rather than fixing an existing bug. Fix: Refer to part 1 (#197) for the complete description and installation instructions. This is part 3 of 14 (#199). Files affected by this part are: /usr/src/bin/chflags /usr/src/bin/ls/Makefile /usr/src/bin/ls/stat_flags.c /usr/src/bin/ls/strsep.c /usr/src/lib/libc/pdp/sys/chflags.s /usr/src/lib/libc/pdp/sys/fchflags.s /usr/src/man/man2/chflags.2 =====================cut here======================== #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # /usr/src/bin/chflags # /usr/src/bin/ls/Makefile # /usr/src/bin/ls/stat_flags.c # /usr/src/bin/ls/strsep.c # /usr/src/lib/libc/pdp/sys/chflags.s # /usr/src/lib/libc/pdp/sys/fchflags.s # /usr/src/man/man2/chflags.2 # This archive created: Thu Dec 15 21:12:57 1994 export PATH; PATH=/bin:/usr/bin:$PATH if test ! -d '/usr/src/bin/chflags' then mkdir '/usr/src/bin/chflags' fi cd '/usr/src/bin/chflags' if test -f 'chflags.c' then echo shar: "will not over-write existing file 'chflags.c'" else sed 's/^X//' << \SHAR_EOF > 'chflags.c' X/* X * Program Name: symcompact.c X * Date: December 3, 1994 X * Author: S.M. Schultz X * X * ----------------- Modification History --------------- X * Version Date Reason For Modification X * 1.0 03Dec94 1. Initial release into the public domain. X*/ X X#include X#include X#include X#include X#include X#include X Xstatic char *fmsg = "Can't fchdir() back to starting directory"; Xstatic int oct, status, fflag, rflag; Xstatic u_short set, clear; Xstatic struct stat st; Xstatic void usage(); X Xextern long strtol(); Xextern int optind, errno; Xextern u_short string_to_flags(); /* from ../ls */ X Xmain(argc, argv) X int argc; X char *argv[]; X { X register char *p; X char *flags, *ep; X int ch, fcurdir; X long tmp; X X while ((ch = getopt(argc, argv, "Rf")) != EOF) X { X switch (ch) X { X case 'R': X rflag++; X break; X case 'f': X fflag++; X break; X case '?': X default: X usage(); X } X } X argv += optind; X argc += optind; X if (argc < 2) X usage(); X X flags = *argv++; X if (*flags >= '0' && *flags <= '7') X { X tmp = strtol(flags, &ep, 8); X if (tmp < 0 || tmp >= 64L*1024*1024 || *ep) X die("invalid flags: %s", flags); X oct = 1; X set = tmp; X } X else X { X if (string_to_flags(&flags, &set, &clear)) X die("invalid flag: %s", flags); X clear = ~clear; X oct = 0; X } X X if (rflag) X { X fcurdir = open(".", O_RDONLY); X if (fcurdir < 0) X die("Can't open ."); X } X X while (p = *argv++) X { X if (lstat(p, &st) < 0) X { X status |= warning(p); X continue; X } X if (rflag && (st.st_mode&S_IFMT) == S_IFDIR) X { X status |= recurse(p, fcurdir); X continue; X } X if ((st.st_mode&S_IFMT) == S_IFLNK && stat(p, &st) < 0) X { X status |= warning(p); X continue; X } X if (chflags(p, newflags(st.st_flags)) < 0) X { X status |= warning(p); X continue; X } X } X close(fcurdir); X exit(status); X } X Xrecurse(dir, savedir) X char *dir; X int savedir; X { X register DIR *dirp; X register struct direct *dp; X int ecode; X X if (chdir(dir) < 0) X { X warning(dir); X return(1); X } X if ((dirp = opendir(".")) == NULL) X { X warning(dir); X return(1); X } X dp = readdir(dirp); X dp = readdir(dirp); /* read "." and ".." */ X ecode = 0; X for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) X { X if (lstat(dp->d_name, &st) < 0) X { X ecode = warning(dp->d_name); X if (ecode) X break; X continue; X } X if ((st.st_mode&S_IFMT) == S_IFDIR) X { X ecode = recurse(dp->d_name, dirfd(dirp)); X if (ecode) X break; X continue; X } X if ((st.st_mode&S_IFMT) == S_IFLNK) X continue; X if (chflags(dp->d_name, newflags(st.st_flags)) < 0 && X (ecode = warning(dp->d_name))) X break; X } X/* X * Lastly change the flags on the directory we are in before returning to X * the previous level. X*/ X if (fstat(dirfd(dirp), &st) < 0) X die("can't fstat ."); X if (fchflags(dirfd(dirp), newflags(st.st_flags)) < 0) X ecode = warning(dir); X if (fchdir(savedir) < 0) X die(fmsg); X closedir(dirp); X return(ecode); X } X X/* VARARGS1 */ Xdie(fmt, va_alist) X char *fmt; X va_dcl X { X va_list ap; X X va_start(ap); X vfprintf(stderr, fmt, ap); X fputc('\n', stderr); X va_end(ap); X exit(1); X } X Xwarning(msg) X char *msg; X { X X if (!fflag) X fprintf(stderr, "chflags: %s: %s\n", msg, strerror(errno)); X return(!fflag); X } X Xnewflags(flags) X u_short flags; X { X X if (oct) X flags = set; X else X { X flags |= set; X flags &= clear; X } X return(flags); X } X Xstatic void Xusage() X { X fputs("usage: chflags [-Rf] flags file ...\n", stderr); X exit(1); X } SHAR_EOF chmod 644 'chflags.c' fi if test -f 'Makefile' then echo shar: "will not over-write existing file 'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' X# X# Public Domain. 12/3/1994 - Steven Schultz X# X# @(#)Makefile 1.0 (2.11BSD GTE) 12/3/94 X# XCFLAGS= -O XSEPFLAG= -i XVPATH= ../ls XSRCS= chflags.c stat_flags.c strsep.c XOBJS= chflags.o stat_flags.o strsep.o XMAN= chflags.0 XMANSRC= chflags.1 X Xchflags.0: ${MANSRC} X /usr/man/manroff ${MANSRC} > ${MAN} X Xall: chflags X Xchflags: ${MAN} ${OBJS} X ${CC} ${CFLAGS} ${SEPFLAG} -o $@ ${OBJS} X Xclean: X rm -f ${OBJS} ${MAN} chflags tags X Xdepend: ${SRCS} X mkdep ${CFLAGS} ${SRCS} X Xinstall: chflags X install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat1 X install -s -o root -g bin -m 755 chflags ${DESTDIR}/bin/chflags X Xlint: ${SRCS} X lint -hax ${SRCS} X Xtags: ${SRCS} X ctags ${SRCS} X# DO NOT DELETE THIS LINE -- mkdep uses it. X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. SHAR_EOF chmod 644 'Makefile' fi if test -f 'chflags.1' then echo shar: "will not over-write existing file 'chflags.1'" else sed 's/^X//' << \SHAR_EOF > 'chflags.1' X.\" Copyright (c) 1989, 1990, 1993, 1994 X.\" The Regents of the University of California. All rights reserved. X.\" X.\" This code is derived from software contributed to Berkeley by X.\" the Institute of Electrical and Electronics Engineers, Inc. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by the University of X.\" California, Berkeley and its contributors. X.\" 4. Neither the name of the University nor the names of its contributors X.\" may be used to endorse or promote products derived from this software X.\" without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" @(#)chflags.1 8.2.1 (2.11BSD GTE) 11/28/94 X.\" X.TH CHFLAGS 1 "November 28, 1994" X.UC 4 X.SH NAME Xchflags \- change file flags X.SH SYNOPSIS Xchflags [-R] [-f]\fBflags\fP \fBfile\fP ... X.SH DESCRIPTION XThe X.B chflags Xutility modifies the file flags of the listed files Xas specified by the X.B flags Xoperand. X.PP XThe options are as follows: X.TP 15 X-R XChange the file flags for the file hierarchies rooted Xin the files instead of just the files themselves. X.PP X-f X\fBchflags\fP will not complain if it fails to change the flags on a Xfile. X.PP XFlags are a comma separated list of keywords. XThe following keywords are currently defined: X.TP 20 Xarch XNo effect. This bit is defined and will be set/cleared as requested but Xnothing in the system makes use of it yet. X.TP 20 Xdump XSet the dump flag X.TP 20 Xsappnd XSet the system append-only flag (super-user only) X.TP 20 Xschg XSet the system immutable flag (super-user only) X.TP 20 Xuappnd XSet the user append-only flag (owner or super-user only) X.TP 20 Xuchg XSet the user immutable flag (owner or super-user only) X.PP XPutting the letters X.B no Xbefore an option causes the flag to be turned off. XFor example: X.TP 20 Xnodump Xthe file should never be dumped X.PP XSymbolic links do not have flags and are silently ignored by X.B chflags. XWhen the -R option is given and symbolic links are encountered they are Xnot traversed. This is the same behaviour as \fBchmod(1)\fP. X.PP XThe X.B chflags Xutility exits 0 on success, and >0 if an error occurs. X.SH SEE ALSO Xchflags(2), Xstat(2), Xsymlink(7) SHAR_EOF chmod 644 'chflags.1' fi chmod 755 . cd .. if test -f '/usr/src/bin/ls/Makefile' then echo shar: "will not over-write existing file '/usr/src/bin/ls/Makefile'" else sed 's/^X//' << \SHAR_EOF > '/usr/src/bin/ls/Makefile' X# X# Public Domain. 12/3/1994 - Steven Schultz X# X# @(#)Makefile 1.0 (2.11BSD GTE) 12/3/94 X# XCFLAGS= -O XSEPFLAG= -i XSRCS= ls.c stat_flags.c strsep.c XOBJS= ls.o stat_flags.o strsep.o X Xall: ls X Xls: ${OBJS} X ${CC} ${CFLAGS} ${SEPFLAG} -o $@ ${OBJS} X Xclean: X rm -f ${OBJS} ls tags X Xdepend: ${SRCS} X mkdep ${CFLAGS} ${SRCS} X Xinstall: ls X install -s -o root -g bin -m 755 ls ${DESTDIR}/bin/ls X Xlint: ${SRCS} X lint -hax ${SRCS} X Xtags: ${SRCS} X ctags ${SRCS} SHAR_EOF chmod 644 '/usr/src/bin/ls/Makefile' fi if test -f '/usr/src/bin/ls/stat_flags.c' then echo shar: "will not over-write existing file '/usr/src/bin/ls/stat_flags.c'" else sed 's/^X//' << \SHAR_EOF > '/usr/src/bin/ls/stat_flags.c' X/*- X * Copyright (c) 1993 X * The Regents of the University of California. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by the University of X * California, Berkeley and its contributors. X * 4. Neither the name of the University nor the names of its contributors X * may be used to endorse or promote products derived from this software X * without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X#if !defined(lint) && defined(DOSCCS) Xstatic char sccsid[] = "@(#)stat_flags.c 8.1.1 (2.11BSD GTE) 12/3/94"; X#endif X X/* X * Modified from the 4.4-Lite version for 2.11BSD. Main change was to X * use 'u_short' instead of 'u_long' for the flags word. X*/ X X#include X#include X#include X#include X X#define SAPPEND(s) { \ X if (prefix != NULL) \ X (void)strcat(string, prefix); \ X (void)strcat(string, s); \ X prefix = ","; \ X} X X/* X * flags_to_string -- X * Convert stat flags to a comma-separated string. If no flags X * are set, return the default string. X */ Xchar * Xflags_to_string(flags, def) X register u_short flags; X char *def; X{ X static char string[64]; X register char *prefix; X X string[0] = '\0'; X prefix = NULL; X if (flags & UF_APPEND) X SAPPEND("uappnd"); X if (flags & UF_IMMUTABLE) X SAPPEND("uchg"); X if (flags & UF_NODUMP) X SAPPEND("nodump"); X if (flags & SF_APPEND) X SAPPEND("sappnd"); X if (flags & SF_ARCHIVED) X SAPPEND("arch"); X if (flags & SF_IMMUTABLE) X SAPPEND("schg"); X return (prefix == NULL && def != NULL ? def : string); X} X X#define TEST(a, b, f) { \ X if (!memcmp(a, b, sizeof(b))) { \ X if (clear) { \ X if (clrp) \ X *clrp |= (f); \ X } else if (setp) \ X *setp |= (f); \ X break; \ X } \ X} X X/* X * string_to_flags -- X * Take string of arguments and return stat flags. Return 0 on X * success, 1 on failure. On failure, stringp is set to point X * to the offending token. X */ Xu_short Xstring_to_flags(stringp, setp, clrp) X char **stringp; X register u_short *setp, *clrp; X{ X int clear; X char *string; X register char *p; X X if (setp) X *setp = 0; X if (clrp) X *clrp = 0; X string = *stringp; X while ((p = strsep(&string, "\t ,")) != NULL) { X *stringp = p; X if (*p == '\0') X continue; X if (p[0] == 'n' && p[1] == 'o') { X clear = 1; X p += 2; X } X else X clear = 0; /* This was done only once on entry! */ X switch (p[0]) { X case 'a': X TEST(p, "arch", SF_ARCHIVED); X TEST(p, "archived", SF_ARCHIVED); X return (1); X case 'd': X clear = !clear; X TEST(p, "dump", UF_NODUMP); X return (1); X case 's': X TEST(p, "sappnd", SF_APPEND); X TEST(p, "sappend", SF_APPEND); X TEST(p, "schg", SF_IMMUTABLE); X TEST(p, "schange", SF_IMMUTABLE); X TEST(p, "simmutable", SF_IMMUTABLE); X return (1); X case 'u': X TEST(p, "uappnd", UF_APPEND); X TEST(p, "uappend", UF_APPEND); X TEST(p, "uchg", UF_IMMUTABLE); X TEST(p, "uchange", UF_IMMUTABLE); X TEST(p, "uimmutable", UF_IMMUTABLE); X /* FALLTHROUGH */ X default: X return (1); X } X } X return (0); X} SHAR_EOF chmod 444 '/usr/src/bin/ls/stat_flags.c' fi if test -f '/usr/src/bin/ls/strsep.c' then echo shar: "will not over-write existing file '/usr/src/bin/ls/strsep.c'" else sed 's/^X//' << \SHAR_EOF > '/usr/src/bin/ls/strsep.c' X/*- X * Copyright (c) 1990, 1993 X * The Regents of the University of California. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by the University of X * California, Berkeley and its contributors. X * 4. Neither the name of the University nor the names of its contributors X * may be used to endorse or promote products derived from this software X * without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X#include X#include X X#if defined(DOSCCS) && !defined(lint) Xstatic char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93"; X#endif X X/* X * Copied from 4.4-Lite and slightly modified for 2.11BSD. The version of X * strsep in 2.11's libc.a was incompatible with 'ls' and 'chflags'. Rather X * than break (or have to convert) existing programs we use this file in X * 'ls' and 'chflags'. X*/ X X/* X * Get next token from string *stringp, where tokens are possibly-empty X * strings separated by characters from delim. X * X * Writes NULs into the string at *stringp to end tokens. X * delim need not remain constant from call to call. X * On return, *stringp points past the last NUL written (if there might X * be further tokens), or is NULL (if there are definitely no more tokens). X * X * If *stringp is NULL, strsep returns NULL. X */ Xchar * Xstrsep(stringp, delim) X register char **stringp; X register char *delim; X{ X register char *s; X char *spanp; X int c, sc; X char *tok; X X if ((s = *stringp) == NULL) X return (NULL); X for (tok = s;;) { X c = *s++; X spanp = delim; X do { X if ((sc = *spanp++) == c) { X if (c == 0) X s = NULL; X else X s[-1] = 0; X *stringp = s; X return (tok); X } X } while (sc != 0); X } X /* NOTREACHED */ X} SHAR_EOF chmod 444 '/usr/src/bin/ls/strsep.c' fi if test -f '/usr/src/lib/libc/pdp/sys/chflags.s' then echo shar: "will not over-write existing file '/usr/src/lib/libc/pdp/sys/chflags.s'" else sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/pdp/sys/chflags.s' X/* X * No Copyright (c). Placed in the public domain 1994. Steven Schultz X * (sms@wlv.iipo.gtegsc.com). X */ X X#ifdef SYSLIBC_SCCS X_sccsid: <@(#)chflags.s 1.0 (GTE) 11/26/94\0> X .even X#endif SYSLIBC_SCCS X X#include "SYS.h" X XSYSCALL(chflags,norm) SHAR_EOF chmod 444 '/usr/src/lib/libc/pdp/sys/chflags.s' fi if test -f '/usr/src/lib/libc/pdp/sys/fchflags.s' then echo shar: "will not over-write existing file '/usr/src/lib/libc/pdp/sys/fchflags.s'" else sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/pdp/sys/fchflags.s' X/* X * No Copyright (c). Placed in the public domain 1994. Steven Schultz X * (sms@wlv.iipo.gtegsc.com). X */ X X#ifdef SYSLIBC_SCCS X_sccsid: <@(#)fchflags.s 1.0 (GTE) 11/26/94\0> X .even X#endif SYSLIBC_SCCS X X#include "SYS.h" X XSYSCALL(fchflags,norm) SHAR_EOF chmod 444 '/usr/src/lib/libc/pdp/sys/fchflags.s' fi if test -f '/usr/src/man/man2/chflags.2' then echo shar: "will not over-write existing file '/usr/src/man/man2/chflags.2'" else sed 's/^X//' << \SHAR_EOF > '/usr/src/man/man2/chflags.2' X.\" Copyright (c) 1989, 1993 X.\" The Regents of the University of California. All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by the University of X.\" California, Berkeley and its contributors. X.\" 4. Neither the name of the University nor the names of its contributors X.\" may be used to endorse or promote products derived from this software X.\" without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" @(#)chflags.2 8.1.1 (2.11BSD GTE) 11/28/94 X.\" X.TH CHFLAGS 2 "November 28, 1994" X.UC 4 X.SH NAME Xchflags, fchflags \- set file flags X.SH SYNOPSIS X.nf X.ft B X#include X Xint Xchflags(path, flags) Xchar *path; Xu_short flags; X Xint Xfchflags(fd, flags) Xint fd; Xu_short flags; X.ft R X.fi X.SH DESCRIPTION XThe file whose name Xis given by X.B path Xor referenced by the descriptor X.B fd Xhas its flags changed to X.B flags . X.PP XThe flags specified are formed by Xor'ing Xthe following values X.PP X.TP 15 XUF_NODUMP XDo not dump the file. X.TP 15 XUF_IMMUTABLE XThe file may not be changed. X.TP 15 XUF_APPEND XThe file may only be appended to. X.TP 15 XARCHIVED XFile is archived. X.TP 15 XSF_IMMUTABLE XThe file may not be changed. X.TP 15 XSF_APPEND XThe file may only be appended to. X.PP XThe X.B UF_IMMUTABLE Xand X.B UF_APPEND Xflags may be set or unset by either the owner of a file or the super-user. X.PP XThe X.B SF_IMMUTABLE Xand X.B SF_APPEND Xflags may only be set or unset by the super-user. XThey may be set at any time, but normally may only be unset when Xthe system is in single-user mode. X(See X.I init(8) Xfor details.) X.SH RETURN VALUES XUpon successful completion, a value of 0 is returned. XOtherwise, -1 is returned and the global variable X.B errno Xis set to indicate the error. X.SH ERRORS XChflags Xwill fail if: X.TP 15 XENOTDIR XA component of the path prefix is not a directory. X.TP 15 XEINVAL XThe pathname contains a character with the high-order bit set. X.TP 15 XENAMETOOLONG XA component of a pathname exceeded 63 characters, Xor an entire path name exceeded 255 characters. X.TP 15 XENOENT XThe named file does not exist. X.TP 15 XEACCES XSearch permission is denied for a component of the path prefix. X.TP 15 XELOOP XToo many symbolic links were encountered in translating the pathname. X.TP 15 XEPERM XThe effective user ID does not match the owner of the file and Xthe effective user ID is not the super-user. X.TP 15 XEROFS XThe named file resides on a read-only file system. X.TP 15 XEFAULT X.B path Xpoints outside the process's allocated address space. X.TP 15 XEIO XAn I/O error occurred while reading from or writing to the file system. X.PP Xfchflags Xwill fail if: X.TP 15 XEBADF XThe descriptor is not valid. X.TP 15 XEINVAL X.B fd Xrefers to a socket, not to a file. X.TP 15 XEPERM XThe effective user ID does not match the owner of the file and Xthe effective user ID is not the super-user. X.TP 15 XEROFS XThe file resides on a read-only file system. X.TP 15 XEIO XAn I/O error occurred while reading from or writing to the file system. X.SH SEE ALSO Xchflags(1), init(8) X.SH HISTORY XThe X.B chflags Xand X.B fchflags Xfunctions first appeared in 4.4BSD. SHAR_EOF chmod 644 '/usr/src/man/man2/chflags.2' fi exit 0 # End of shell archive