aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-03-09 14:42:28 -0500
committerRob Landley <rob@landley.net>2014-03-09 14:42:28 -0500
commit69664c24a11e8bba39890ec52aefa5654aab60bd (patch)
tree9fc8a12d2c355e4b2cd9ee7a776889a0ddc3ae70 /toys/other
parentd96e0ba7926941910d99ecc87c7a76ed6c480622 (diff)
downloadtoybox-69664c24a11e8bba39890ec52aefa5654aab60bd.tar.gz
Promote freeramdisk from pending to other, default y.
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/freeramdisk.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/toys/other/freeramdisk.c b/toys/other/freeramdisk.c
new file mode 100644
index 00000000..cb0b7f8f
--- /dev/null
+++ b/toys/other/freeramdisk.c
@@ -0,0 +1,27 @@
+/* freeramdisk.c - Free all memory allocated to ramdisk
+ *
+ * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com>
+ *
+ * No Standard
+
+USE_FREERAMDISK(NEWTOY(freeramdisk, "<1>1", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
+
+config FREERAMDISK
+ bool "freeramdisk"
+ default y
+ help
+ usage: freeramdisk [RAM device]
+
+ Free all memory allocated to specified ramdisk
+*/
+
+#include "toys.h"
+
+void freeramdisk_main(void)
+{
+ int fd;
+
+ fd = xopen(toys.optargs[0], O_RDWR);
+ xioctl(fd, BLKFLSBUF, toys.optargs[0]);
+ if (CFG_TOYBOX_FREE) xclose(fd);
+}