From 728b8ff0a01f5adb01c5a44886cba644f8415837 Mon Sep 17 00:00:00 2001 From: Vivek Bhagat Date: Sun, 9 Mar 2014 14:27:11 -0500 Subject: 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 ". 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. --- toys/pending/freeramdisk.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 toys/pending/freeramdisk.c (limited to 'toys/pending/freeramdisk.c') diff --git a/toys/pending/freeramdisk.c b/toys/pending/freeramdisk.c new file mode 100644 index 00000000..8ff4e75c --- /dev/null +++ b/toys/pending/freeramdisk.c @@ -0,0 +1,27 @@ +/* freeramdisk.c - Free all memory allocated to ramdisk + * + * Copyright 2014 Vivek Kumar Bhagat + * + * No Standard + +USE_FREERAMDISK(NEWTOY(freeramdisk, "<1>1", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) + +config FREERAMDISK + bool "freeramdisk" + default n + help + usage: freeramdisk + + 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); +} -- cgit v1.2.3