2 * getflags.c - Get 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.
23 #include <sys/types.h>
26 #include <sys/ioctl.h>
31 int getflags (int fd, unsigned long * flags)
36 if (fstat (fd, &buf) == -1)
41 if (buf.st_flags & UF_IMMUTABLE)
42 *flags |= EXT2_IMMUTABLE_FL;
45 if (buf.st_flags & UF_APPEND)
46 *flags |= EXT2_APPEND_FL;
49 if (buf.st_flags & UF_NODUMP)
50 *flags |= EXT2_NODUMP_FL;
58 if (!fstat(fd, &buf) &&
59 !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode))
61 r = ioctl(fd, EXT2_IOC_GETFLAGS, &f);
66 #endif /* HAVE_EXT2_IOCTLS */