Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 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 | } |