Use tab not space
[oweals/busybox.git] / util-linux / freeramdisk.c
index 567151455470e00ee6e49f7dcbfe2c2d9d930b1e..e5061dc34bba6bff32b064ec4ff86616632285f3 100644 (file)
@@ -3,7 +3,7 @@
  * freeramdisk implementation for busybox
  *
  * Copyright (C) 2000 and written by Emanuele Caratti <wiz@iol.it>
- * Adjusted a bit by Erik Andersen <andersee@debian.org>
+ * Adjusted a bit by Erik Andersen <andersen@codepoet.org>
  *
  * 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
@@ -26,7 +26,8 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
-#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
 #include "busybox.h"
 
 
 extern int
 freeramdisk_main(int argc, char **argv)
 {
-       int   f;
+       int result;
+       int fd;
 
-       if (argc != 2 || *argv[1] == '-') {
-               usage(freeramdisk_usage);
+       if (argc != 2) {
+               bb_show_usage();
        }
 
-       if ((f = open(argv[1], O_RDWR)) == -1) {
-               fatalError( "cannot open %s: %s\n", argv[1], strerror(errno));
-       }
-       if (ioctl(f, BLKFLSBUF) < 0) {
-               fatalError( "failed ioctl on %s: %s\n", argv[1], strerror(errno));
+       fd = bb_xopen(argv[1], O_RDWR);
+
+       result = ioctl(fd, BLKFLSBUF);
+#ifdef CONFIG_FEATURE_CLEAN_UP
+       close(fd);
+#endif
+       if (result < 0) {
+               bb_perror_msg_and_die("failed ioctl on %s", argv[1]);
        }
+
        /* Don't bother closing.  Exit does
         * that, so we can save a few bytes */
-       /* close(f); */
        return EXIT_SUCCESS;
 }