aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/deallocvt.c
diff options
context:
space:
mode:
authorVivek Bhagat <vivek.bhagat89@gmail.com>2014-03-09 14:27:11 -0500
committerVivek Bhagat <vivek.bhagat89@gmail.com>2014-03-09 14:27:11 -0500
commit728b8ff0a01f5adb01c5a44886cba644f8415837 (patch)
tree847d42d91c3e01b89efba8afcee6b744a110b6e9 /toys/pending/deallocvt.c
parent4d886d69511e3d3a7b3c3ead914f638b01ff7433 (diff)
downloadtoybox-728b8ff0a01f5adb01c5a44886cba644f8415837.tar.gz
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.
Diffstat (limited to 'toys/pending/deallocvt.c')
-rw-r--r--toys/pending/deallocvt.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/toys/pending/deallocvt.c b/toys/pending/deallocvt.c
new file mode 100644
index 00000000..8ac67016
--- /dev/null
+++ b/toys/pending/deallocvt.c
@@ -0,0 +1,37 @@
+/* deallocvt.c - Deallocate virtual terminal(s)
+ *
+ * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com>
+ *
+ * No Standard.
+
+USE_DEALLOCVT(NEWTOY(deallocvt, ">1", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NEEDROOT))
+
+config DEALLOCVT
+ bool "deallocvt"
+ depends on OPENVT
+ default n
+ help
+ usage: deallocvt [N]
+
+ Deallocate unused virtual terminal /dev/ttyN
+ default value of N is 0, deallocate all unused consoles
+*/
+
+#include "toys.h"
+#include <linux/vt.h>
+
+void deallocvt_main(void)
+{
+ int fd;
+
+ // 0 : deallocate all unused consoles
+ int vt_num = 0;
+
+ if (toys.optargs[0])
+ vt_num = atolx_range(toys.optargs[0], 1, 63);
+
+ fd = find_console_fd();
+ if (fd < 0) error_exit("can't open console");
+
+ xioctl(fd, VT_DISALLOCATE, (void *)(ptrdiff_t)vt_num);
+}