diff toys/pending/deallocvt.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 3c855d5a75be
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toys/pending/deallocvt.c	Sun Mar 09 14:27:11 2014 -0500
@@ -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);
+}