#include <stdio.h>
#include <string.h>
-#include <linux/fs.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
-#include "internal.h"
+#include <stdlib.h>
+#include "busybox.h"
-
-static const char freeramdisk_usage[] =
- "freeramdisk DEVICE\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nFrees all memory used by the specified ramdisk.\n"
-#endif
- ;
+/* From linux/fs.h */
+#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
extern int
freeramdisk_main(int argc, char **argv)
int f;
if (argc != 2 || *argv[1] == '-') {
- usage(freeramdisk_usage);
+ show_usage();
}
if ((f = open(argv[1], O_RDWR)) == -1) {
- fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno));
+ perror_msg_and_die("cannot open %s", argv[1]);
}
if (ioctl(f, BLKFLSBUF) < 0) {
- fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno));
+ 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); */
- exit(TRUE);
+ return EXIT_SUCCESS;
}
/*