2 * setflags.c - Set a file flags on an ext2 file system
4 * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr>
5 * Laboratoire MASI, Institut Blaise Pascal
6 * Universite Pierre et Marie Curie (Paris VI)
9 * This file may be redistributed under the terms of the GNU Library
10 * General Public License, version 2.
22 #include <sys/types.h>
25 #include <sys/ioctl.h>
31 * Deal with lame glibc's that define this function without actually
32 * implementing it. Can you say "attractive nuisance", boys and girls?
39 int setflags (int fd, unsigned long flags)
42 unsigned long bsd_flags = 0;
45 if (flags & EXT2_IMMUTABLE_FL)
46 bsd_flags |= UF_IMMUTABLE;
49 if (flags & EXT2_APPEND_FL)
50 bsd_flags |= UF_APPEND;
53 if (flags & EXT2_NODUMP_FL)
54 bsd_flags |= UF_NODUMP;
57 return fchflags (fd, bsd_flags);
58 #else /* ! HAVE_CHFLAGS */
63 if (!fstat(fd, &buf) &&
64 !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
70 return ioctl(fd, EXT2_IOC_SETFLAGS, &f);
74 #endif /* HAVE_EXT2_IOCTLS */
75 #endif /* HAVE_CHFLAGS */