diff options
Diffstat (limited to 'console-tools/deallocvt.c')
-rw-r--r-- | console-tools/deallocvt.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index b89249b87..363ecdf12 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c | |||
@@ -34,33 +34,23 @@ static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */ | |||
34 | 34 | ||
35 | int deallocvt_main(int argc, char *argv[]) | 35 | int deallocvt_main(int argc, char *argv[]) |
36 | { | 36 | { |
37 | int fd, num = 0; | 37 | /* num = 0 deallocate all unused consoles */ |
38 | int num = 0; | ||
38 | 39 | ||
39 | if (argc > 2) { | 40 | switch(argc) |
40 | bb_show_usage(); | 41 | { |
41 | } | 42 | case 2: |
42 | 43 | if((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) | |
43 | fd = get_console_fd(); | 44 | bb_error_msg_and_die("0: illegal VT number"); |
44 | 45 | /* Falltrough */ | |
45 | /* num=0 deallocate all unused consoles */ | ||
46 | if (argc == 1) { | ||
47 | goto disallocate_all; | ||
48 | } | ||
49 | |||
50 | num = bb_xgetlarg(argv[1], 10, 0, INT_MAX); | ||
51 | switch (num) { | ||
52 | case 0: | ||
53 | bb_error_msg("0: illegal VT number"); | ||
54 | break; | ||
55 | case 1: | 46 | case 1: |
56 | bb_error_msg("VT 1 cannot be deallocated"); | ||
57 | break; | 47 | break; |
58 | default: | 48 | default: |
59 | disallocate_all: | 49 | bb_show_usage(); |
60 | if (ioctl(fd, VT_DISALLOCATE, num)) { | 50 | } |
61 | bb_perror_msg_and_die("VT_DISALLOCATE"); | 51 | |
62 | } | 52 | if (ioctl( get_console_fd(), VT_DISALLOCATE, num )) { |
63 | return EXIT_SUCCESS; | 53 | bb_perror_msg_and_die("VT_DISALLOCATE"); |
64 | } | 54 | } |
65 | return EXIT_FAILURE; | 55 | return EXIT_SUCCESS; |
66 | } | 56 | } |