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)
8 * This file can be redistributed under the terms of the GNU Library General
20 #include <sys/types.h>
23 #include <sys/ioctl.h>
29 * Deal with lame glibc's that define this function without actually
30 * implementing it. Can you say "attractive nuisance", boys and girls?
37 int setflags (int fd, unsigned long flags)
41 unsigned long bsd_flags = 0;
44 if (flags & EXT2_IMMUTABLE_FL)
45 bsd_flags |= UF_IMMUTABLE;
48 if (flags & EXT2_APPEND_FL)
49 bsd_flags |= UF_APPEND;
52 if (flags & EXT2_NODUMP_FL)
53 bsd_flags |= UF_NODUMP;
56 return fchflags (fd, bsd_flags);
61 if (!fstat(fd, &buf) &&
62 !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
67 return ioctl (fd, EXT2_IOC_SETFLAGS, &f);
68 #endif /* HAVE_EXT2_IOCTLS */