Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 2 | /* |
Eric Andersen | 7f6295f | 2003-10-22 10:34:15 +0000 | [diff] [blame] | 3 | * Disallocate virtual terminal(s) |
| 4 | * |
| 5 | * Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it> |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 6 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
Eric Andersen | 7f6295f | 2003-10-22 10:34:15 +0000 | [diff] [blame] | 7 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 9 | */ |
Eric Andersen | 7f6295f | 2003-10-22 10:34:15 +0000 | [diff] [blame] | 10 | |
| 11 | /* no options, no getopt */ |
| 12 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 13 | #include "libbb.h" |
Eric Andersen | bd22ed8 | 2000-07-08 18:55:24 +0000 | [diff] [blame] | 14 | |
| 15 | /* From <linux/vt.h> */ |
Rob Landley | bc68cd1 | 2006-03-10 19:22:06 +0000 | [diff] [blame] | 16 | enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */ |
Eric Andersen | bd22ed8 | 2000-07-08 18:55:24 +0000 | [diff] [blame] | 17 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 18 | int deallocvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 19 | int deallocvt_main(int argc UNUSED_PARAM, char **argv) |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 20 | { |
Glenn L McGrath | 17b4a20 | 2004-01-15 11:50:19 +0000 | [diff] [blame] | 21 | /* num = 0 deallocate all unused consoles */ |
| 22 | int num = 0; |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 23 | |
Denis Vlasenko | 1d42665 | 2008-03-17 09:09:09 +0000 | [diff] [blame] | 24 | if (argv[1]) { |
| 25 | if (argv[2]) |
| 26 | bb_show_usage(); |
Denis Vlasenko | 6ee023c | 2007-08-23 10:52:52 +0000 | [diff] [blame] | 27 | num = xatou_range(argv[1], 1, 63); |
Mark Whitley | 6f6aa9b | 2000-12-13 23:23:30 +0000 | [diff] [blame] | 28 | } |
Glenn L McGrath | 17b4a20 | 2004-01-15 11:50:19 +0000 | [diff] [blame] | 29 | |
Denis Vlasenko | 968dbf9 | 2007-10-29 19:52:21 +0000 | [diff] [blame] | 30 | /* double cast suppresses "cast to ptr from int of different size" */ |
Denis Vlasenko | 2afd5ab | 2008-08-05 23:32:27 +0000 | [diff] [blame] | 31 | xioctl(get_console_fd_or_die(), VT_DISALLOCATE, (void *)(ptrdiff_t)num); |
Glenn L McGrath | 17b4a20 | 2004-01-15 11:50:19 +0000 | [diff] [blame] | 32 | return EXIT_SUCCESS; |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 33 | } |