Simplified version checking.
[oweals/busybox.git] / fdflush.c
index 6633e12128a922b8d488b5c71c13371fc813226b..28f5cb68a02244da47ab04a0073e9d6aff2c317b 100644 (file)
--- a/fdflush.c
+++ b/fdflush.c
  *
  */
 
-#include "busybox.h"
 #include <stdio.h>
 #include <sys/ioctl.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_usage);
+               show_usage();
 
-       fd = open(*argv, 0);
-       if (fd < 0) {
-               perror(*argv);
-               exit(FALSE);
-       }
+       if ((fd = open(*argv, 0)) < 0)
+               perror_msg_and_die("%s", *argv);
 
-       value = ioctl(fd, FDFLUSH, 0);
-       /* Don't bother closing.  Exit does
-        * that, so we can save a few bytes */
-       /* close(fd); */
+       if (ioctl(fd, FDFLUSH, 0))
+               perror_msg_and_die("%s", *argv);
 
-       if (value) {
-               perror(*argv);
-               exit(FALSE);
-       }
-       return(TRUE);
+       return EXIT_SUCCESS;
 }