annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1214
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
1 /* deallocvt.c - Deallocate virtual terminal(s)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
2 *
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
3 * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com>
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
4 *
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
5 * No Standard.
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
6
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
7 USE_DEALLOCVT(NEWTOY(deallocvt, ">1", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NEEDROOT))
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
8
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
9 config DEALLOCVT
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
10 bool "deallocvt"
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
11 depends on OPENVT
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
12 default n
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
13 help
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
14 usage: deallocvt [N]
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
15
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
16 Deallocate unused virtual terminal /dev/ttyN
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
17 default value of N is 0, deallocate all unused consoles
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
18 */
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
19
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
20 #include "toys.h"
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
21 #include <linux/vt.h>
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
22
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
23 void deallocvt_main(void)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
24 {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
25 int fd;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
26
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
27 // 0 : deallocate all unused consoles
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
28 int vt_num = 0;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
29
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
30 if (toys.optargs[0])
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
31 vt_num = atolx_range(toys.optargs[0], 1, 63);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
32
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
33 fd = find_console_fd();
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
34 if (fd < 0) error_exit("can't open console");
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
35
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
36 xioctl(fd, VT_DISALLOCATE, (void *)(ptrdiff_t)vt_num);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
37 }