X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=util-linux%2Ffreeramdisk.c;h=aabb5f98827641ed79ef3c6fa890f6a338c4158b;hb=ace02dc9cd3ca0c95db5b5ebe87b9d6cd6ca1733;hp=927c16946b62eaf434705abdb4921b0a7c3a7f42;hpb=be84cd4ef66f8956eb4c7ff0542fd1ba823a70e7;p=oweals%2Fbusybox.git diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c index 927c16946..aabb5f988 100644 --- a/util-linux/freeramdisk.c +++ b/util-linux/freeramdisk.c @@ -24,43 +24,34 @@ #include #include #include -#include #include #include #include -#include "internal.h" +#include +#include "busybox.h" /* From linux/fs.h */ #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */ - -static const char freeramdisk_usage[] = - "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) { - int f; + FILE *f; if (argc != 2 || *argv[1] == '-') { - usage(freeramdisk_usage); + 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)); + f = xfopen(argv[1], "r+"); + + if (ioctl(fileno(f), BLKFLSBUF) < 0) { + 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(TRUE); + return EXIT_SUCCESS; } /*