Mercurial > hg > toybox
comparison toys/pending/deallocvt.c @ 1241:3c855d5a75be draft
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.
author | Isaac Dunham <ibid.ag@gmail.com> |
---|---|
date | Thu, 03 Apr 2014 22:43:28 -0500 |
parents | a31d747b0017 |
children |
comparison
equal
deleted
inserted
replaced
1240:0d295a46f853 | 1241:3c855d5a75be |
---|---|
6 | 6 |
7 USE_DEALLOCVT(NEWTOY(deallocvt, ">1", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NEEDROOT)) | 7 USE_DEALLOCVT(NEWTOY(deallocvt, ">1", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NEEDROOT)) |
8 | 8 |
9 config DEALLOCVT | 9 config DEALLOCVT |
10 bool "deallocvt" | 10 bool "deallocvt" |
11 depends on OPENVT | 11 depends on OPENVT |
12 default n | 12 default n |
13 help | 13 help |
14 usage: deallocvt [N] | 14 usage: deallocvt [N] |
15 | 15 |
16 Deallocate unused virtual terminal /dev/ttyN | 16 Deallocate unused virtual terminal /dev/ttyN |
17 default value of N is 0, deallocate all unused consoles | 17 default value of N is 0, deallocate all unused consoles |
18 */ | 18 */ |
19 | 19 |
20 #include "toys.h" | 20 #include "toys.h" |
21 #include <linux/vt.h> | 21 #include <linux/vt.h> |
22 | 22 |
23 void deallocvt_main(void) | 23 void deallocvt_main(void) |
24 { | 24 { |
25 int fd; | 25 int fd; |
26 | 26 |
27 // 0 : deallocate all unused consoles | 27 // 0 : deallocate all unused consoles |
28 int vt_num = 0; | 28 int vt_num = 0; |
29 | 29 |
30 if (toys.optargs[0]) | 30 if (toys.optargs[0]) |
31 vt_num = atolx_range(toys.optargs[0], 1, 63); | 31 vt_num = atolx_range(toys.optargs[0], 1, 63); |
32 | 32 |
33 fd = find_console_fd(); | 33 fd = find_console_fd(); |
34 if (fd < 0) error_exit("can't open console"); | 34 if (fd < 0) error_exit("can't open console"); |
35 | 35 |
36 xioctl(fd, VT_DISALLOCATE, (void *)(ptrdiff_t)vt_num); | 36 xioctl(fd, VT_DISALLOCATE, (void *)(ptrdiff_t)vt_num); |
37 } | 37 } |