2 * fgetflags.c - Get a file flags on an ext2 file system
3 * fsetflags.c - Set a file flags on an ext2 file system
5 * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr>
6 * Laboratoire MASI, Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
9 * This file can be redistributed under the terms of the GNU Library General
24 #include <sys/types.h>
28 #include <sys/ioctl.h>
34 #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE)
36 #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK)
39 int fgetsetflags (const char * name, unsigned long * get_flags, unsigned long set_flags)
43 int fd, r, f, save_errno = 0;
45 if (!stat(name, &buf) &&
46 !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
49 fd = open (name, OPEN_FLAGS);
54 r = ioctl (fd, EXT2_IOC_SETFLAGS, &f);
56 r = ioctl (fd, EXT2_IOC_GETFLAGS, &f);
65 #endif /* HAVE_EXT2_IOCTLS */