Mercurial > hg > toybox
annotate toys/pending/deallocvt.c @ 1349:bf2e5591bdf0 draft
Cleanup strings.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 11 Jun 2014 08:02:55 -0500 |
parents | 3c855d5a75be |
children |
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" |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
11 depends on OPENVT |
1214
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 |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
14 usage: deallocvt [N] |
1214
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
15 |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
16 Deallocate unused virtual terminal /dev/ttyN |
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
17 default value of N is 0, deallocate all unused consoles |
1214
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 { |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
25 int fd; |
1214
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
26 |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
27 // 0 : deallocate all unused consoles |
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
28 int vt_num = 0; |
1214
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
29 |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
30 if (toys.optargs[0]) |
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
31 vt_num = atolx_range(toys.optargs[0], 1, 63); |
1214
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
32 |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
33 fd = find_console_fd(); |
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
34 if (fd < 0) error_exit("can't open console"); |
1214
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
35 |
1241
3c855d5a75be
openvt tries opening several devices to get an fd that points to the current console, without a need for read or write permissions. O_RDWR implies that both O_RDONLY and O_WRONLY would work, so skip it. Reindent.
Isaac Dunham <ibid.ag@gmail.com>
parents:
1214
diff
changeset
|
36 xioctl(fd, VT_DISALLOCATE, (void *)(ptrdiff_t)vt_num); |
1214
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
37 } |