diff options
Diffstat (limited to 'e2fsprogs/e2p/fsetflags.c')
-rw-r--r-- | e2fsprogs/e2p/fsetflags.c | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/e2fsprogs/e2p/fsetflags.c b/e2fsprogs/e2p/fsetflags.c deleted file mode 100644 index 40e7292dd..000000000 --- a/e2fsprogs/e2p/fsetflags.c +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | /* | ||
2 | * fsetflags.c - Set a file flags on an ext2 file system | ||
3 | * | ||
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) | ||
7 | * | ||
8 | * This file can be redistributed under the terms of the GNU Library General | ||
9 | * Public License | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * History: | ||
14 | * 93/10/30 - Creation | ||
15 | */ | ||
16 | |||
17 | #if HAVE_ERRNO_H | ||
18 | #include <errno.h> | ||
19 | #endif | ||
20 | #if HAVE_UNISTD_H | ||
21 | #include <unistd.h> | ||
22 | #endif | ||
23 | #include <sys/types.h> | ||
24 | #include <sys/stat.h> | ||
25 | #if HAVE_EXT2_IOCTLS | ||
26 | #include <fcntl.h> | ||
27 | #include <sys/ioctl.h> | ||
28 | #endif | ||
29 | |||
30 | #include "e2p.h" | ||
31 | |||
32 | /* | ||
33 | * Deal with lame glibc's that define this function without actually | ||
34 | * implementing it. Can you say "attractive nuisance", boys and girls? | ||
35 | * I knew you could! | ||
36 | */ | ||
37 | #ifdef __linux__ | ||
38 | #undef HAVE_CHFLAGS | ||
39 | #endif | ||
40 | |||
41 | #ifdef O_LARGEFILE | ||
42 | #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE) | ||
43 | #else | ||
44 | #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK) | ||
45 | #endif | ||
46 | |||
47 | int fsetflags (const char * name, unsigned long flags) | ||
48 | { | ||
49 | struct stat buf; | ||
50 | #if HAVE_CHFLAGS && !(APPLE_DARWIN && HAVE_EXT2_IOCTLS) | ||
51 | unsigned long bsd_flags = 0; | ||
52 | |||
53 | #ifdef UF_IMMUTABLE | ||
54 | if (flags & EXT2_IMMUTABLE_FL) | ||
55 | bsd_flags |= UF_IMMUTABLE; | ||
56 | #endif | ||
57 | #ifdef UF_APPEND | ||
58 | if (flags & EXT2_APPEND_FL) | ||
59 | bsd_flags |= UF_APPEND; | ||
60 | #endif | ||
61 | #ifdef UF_NODUMP | ||
62 | if (flags & EXT2_NODUMP_FL) | ||
63 | bsd_flags |= UF_NODUMP; | ||
64 | #endif | ||
65 | |||
66 | return chflags (name, bsd_flags); | ||
67 | #else | ||
68 | #if HAVE_EXT2_IOCTLS | ||
69 | int fd, r, f, save_errno = 0; | ||
70 | |||
71 | if (!stat(name, &buf) && | ||
72 | !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) { | ||
73 | goto notsupp; | ||
74 | } | ||
75 | #if !APPLE_DARWIN | ||
76 | fd = open (name, OPEN_FLAGS); | ||
77 | if (fd == -1) | ||
78 | return -1; | ||
79 | f = (int) flags; | ||
80 | r = ioctl (fd, EXT2_IOC_SETFLAGS, &f); | ||
81 | if (r == -1) | ||
82 | save_errno = errno; | ||
83 | close (fd); | ||
84 | if (save_errno) | ||
85 | errno = save_errno; | ||
86 | #else | ||
87 | f = (int) flags; | ||
88 | return syscall(SYS_fsctl, name, EXT2_IOC_SETFLAGS, &f, 0); | ||
89 | #endif | ||
90 | return r; | ||
91 | #endif /* HAVE_EXT2_IOCTLS */ | ||
92 | #endif | ||
93 | notsupp: | ||
94 | errno = EOPNOTSUPP; | ||
95 | return -1; | ||
96 | } | ||