diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
commit | cc8ed39b240180b58810784f844e253263594ac3 (patch) | |
tree | 15feebbb4be9a9168209609f48f0b100f9364420 /util-linux/fdflush.c | |
download | busybox-w32-0_29alpha2.tar.gz busybox-w32-0_29alpha2.tar.bz2 busybox-w32-0_29alpha2.zip |
Initial revision0_29alpha2
Diffstat (limited to 'util-linux/fdflush.c')
-rw-r--r-- | util-linux/fdflush.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c new file mode 100644 index 000000000..a15e9b3f7 --- /dev/null +++ b/util-linux/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 | } | ||