diff options
Diffstat (limited to 'fdflush.c')
-rw-r--r-- | fdflush.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fdflush.c b/fdflush.c new file mode 100644 index 000000000..a15e9b3f7 --- /dev/null +++ b/fdflush.c | |||
@@ -0,0 +1,36 @@ | |||
1 | #include "internal.h" | ||
2 | #include <sys/ioctl.h> | ||
3 | #include <linux/fd.h> | ||
4 | #include <sys/types.h> | ||
5 | #include <sys/stat.h> | ||
6 | #include <fcntl.h> | ||
7 | |||
8 | const char fdflush_usage[] = "fdflush device"; | ||
9 | |||
10 | int | ||
11 | fdflush(const char *filename) | ||
12 | { | ||
13 | int status; | ||
14 | int fd = open(filename, 0); | ||
15 | |||
16 | if ( fd < 0 ) { | ||
17 | name_and_error(filename); | ||
18 | return 1; | ||
19 | } | ||
20 | |||
21 | status = ioctl(fd, FDFLUSH, 0); | ||
22 | close(fd); | ||
23 | |||
24 | if ( status != 0 ) { | ||
25 | name_and_error(filename); | ||
26 | return 1; | ||
27 | } | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | |||
32 | int | ||
33 | fdflush_fn(const struct FileInfo * i) | ||
34 | { | ||
35 | return fdflush(i->source); | ||
36 | } | ||