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>
28 int setflags (int fd, unsigned long flags)
32 unsigned long bsd_flags = 0;
35 if (flags & EXT2_IMMUTABLE_FL)
36 bsd_flags |= UF_IMMUTABLE;
39 if (flags & EXT2_APPEND_FL)
40 bsd_flags |= UF_APPEND;
43 if (flags & EXT2_NODUMP_FL)
44 bsd_flags |= UF_NODUMP;
47 return fchflags (fd, bsd_flags);
52 if (!fstat(fd, &buf) &&
53 !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
58 return ioctl (fd, EXT2_IOC_SETFLAGS, &f);
59 #endif /* HAVE_EXT2_IOCTLS */