Update internal.h to conditionally include asm/string.h
[oweals/busybox.git] / freeramdisk.c
index 43d42d424fb8c84a2949d31d674bfe88aadbc3ca..fdac5ea46094090b6ef77aec1721676e9a1e53d9 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <sys/mount.h>
+#include <linux/fs.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include "internal.h"
 
 
+
 static const char freeramdisk_usage[] =
-       "freeramdisk DEVICE\n\n"
-       "Frees all memory used by the specified ramdisk.\n";
+       "freeramdisk DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nFrees all memory used by the specified ramdisk.\n"
+#endif
+       ;
 
 extern int
 freeramdisk_main(int argc, char **argv)
 {
-       char  rname[256] = "/dev/ram";
        int   f;
 
-       if (argc > 2 || ( argv[1] && *argv[1] == '-')) {
+       if (argc != 2 || *argv[1] == '-') {
                usage(freeramdisk_usage);
        }
 
-       if (argc >1)
-               strcpy(rname, argv[1]);
-
-       if ((f = open(rname, O_RDWR)) == -1) {
-               fatalError( "freeramdisk: cannot open %s: %s", rname, strerror(errno));
+       if ((f = open(argv[1], O_RDWR)) == -1) {
+               fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno));
        }
        if (ioctl(f, BLKFLSBUF) < 0) {
-               fatalError( "freeramdisk: failed ioctl on %s: %s", rname, strerror(errno));
+               fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno));
        }
-       close(f);
-       exit(TRUE);
+       /* Don't bother closing.  Exit does
+        * that, so we can save a few bytes */
+       /* close(f); */
+       return(TRUE);
 }
 
 /*