+ grep -v # yay!
[oweals/busybox.git] / util-linux / fdflush.c
index ce6870cd1128178698d77513de9996b772972638..56ea2244d7444189fb2b13c16325c608268a695e 100644 (file)
@@ -1,8 +1,9 @@
-
+/* vi: set sw=4 ts=4: */
 /*
  * Mini fdflush implementation for busybox
  *
- * Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
+ *
+ * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 extern int fdflush_main(int argc, char **argv)
 {
-    int        value;
-    int        fd;
-    if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: fdflush device\n");
-       exit(FALSE);
-    }
+       int value;
+       int fd;
+
+       if (argc <= 1 || **(++argv) == '-') {
+               usage("fdflush device\n\nForce floppy disk drive to detect disk change\n");
+       }
 
-    fd = open(*argv, 0);
-    if ( fd < 0 ) {
-       perror(*argv);
-       exit(FALSE);
-    }
+       fd = open(*argv, 0);
+       if (fd < 0) {
+               perror(*argv);
+               exit(FALSE);
+       }
 
-    value = ioctl(fd, FDFLUSH, 0);
-    close(fd);
+       value = ioctl(fd, FDFLUSH, 0);
+       /* Don't bother closing.  Exit does
+        * that, so we can save a few bytes */
+       /* close(fd); */
 
-    if ( value ) {
-       perror(*argv);
-       exit(FALSE);
-    }
-    exit (TRUE);
+       if (value) {
+               perror(*argv);
+               exit(FALSE);
+       }
+       exit(TRUE);
 }