diff toys/pending/freeramdisk.c @ 1214:a31d747b0017 draft

Please find the patches attached herewith for adding 3 new commands - 1. freeramdisk - If we unmount or detach the RAM disk based file system the Linux Kernel will not free the allocated memory associated with the RAM device. This can be useful if one wants to mount this device again: All data will be preserved. If we need to free the memory back to the Kernel, one can use the command: "toybox freeramdisk <RAM device>". 2. openvt - Successfully opens a new virtual terminal as mentioned with -c option otherwise search and open next available VT. with -s option it switches to new VT with -s -w option, it switch back successfully to originating VT. 3. deallocvt - Deallocate specified virtual teminal. if no virtual terminal is specified, it deallocates all unused VT.
author Vivek Bhagat <vivek.bhagat89@gmail.com>
date Sun, 09 Mar 2014 14:27:11 -0500
parents
children 4eaac3e63fa7
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toys/pending/freeramdisk.c	Sun Mar 09 14:27:11 2014 -0500
@@ -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 n
+  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]);
+	xclose(fd);
+}