Static-ify a variable. make du work with all the human-readable variants
[oweals/busybox.git] / fdflush.c
index a244e8def4e94f9d53986729504a60e466b42d40..28f5cb68a02244da47ab04a0073e9d6aff2c317b 100644 (file)
--- a/fdflush.c
+++ b/fdflush.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
 /*
  * Mini fdflush implementation for busybox
  *
  *
  */
 
-#include "internal.h"
 #include <stdio.h>
 #include <sys/ioctl.h>
-#include <linux/fd.h>
 #include <fcntl.h>
+#include <stdlib.h>
+#include "busybox.h"
 
+/* From <linux/fd.h> */
+#define FDFLUSH  _IO(2,0x4b)
 
 extern int fdflush_main(int argc, char **argv)
 {
-    int        value;
-    int        fd;
-    if ( argc <= 1 || **(argv++) == '-' ) {
-       usage( "fdflush device\n");
-    }
+       int fd;
 
-    fd = open(*argv, 0);
-    if ( fd < 0 ) {
-       perror(*argv);
-       exit(FALSE);
-    }
+       if (argc <= 1 || **(++argv) == '-')
+               show_usage();
 
-    value = ioctl(fd, FDFLUSH, 0);
-    close(fd);
+       if ((fd = open(*argv, 0)) < 0)
+               perror_msg_and_die("%s", *argv);
 
-    if ( value ) {
-       perror(*argv);
-       exit(FALSE);
-    }
-    exit (TRUE);
+       if (ioctl(fd, FDFLUSH, 0))
+               perror_msg_and_die("%s", *argv);
+
+       return EXIT_SUCCESS;
 }