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 | * |
"Robert P. J. Day" | 801ab14 | 2006-07-12 07:56:04 +0000 | [diff] [blame] | 8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
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 | |||||
Eric Andersen | cbe31da | 2001-02-20 06:14:08 +0000 | [diff] [blame] | 13 | #include "busybox.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 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 18 | int deallocvt_main(int argc, char *argv[]) |
19 | { | ||||
Glenn L McGrath | 17b4a20 | 2004-01-15 11:50:19 +0000 | [diff] [blame] | 20 | /* num = 0 deallocate all unused consoles */ |
21 | int num = 0; | ||||
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 22 | |
Rob Landley | ead1930 | 2006-03-10 23:16:25 +0000 | [diff] [blame] | 23 | switch (argc) { |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 24 | case 2: |
25 | num = xatoul_range(argv[1], 1, 63); | ||||
Rob Landley | 9f0e00f | 2005-09-08 03:27:06 +0000 | [diff] [blame] | 26 | /* Fallthrough */ |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 27 | case 1: |
28 | break; | ||||
29 | default: | ||||
30 | bb_show_usage(); | ||||
Mark Whitley | 6f6aa9b | 2000-12-13 23:23:30 +0000 | [diff] [blame] | 31 | } |
Glenn L McGrath | 17b4a20 | 2004-01-15 11:50:19 +0000 | [diff] [blame] | 32 | |
Rob Landley | ead1930 | 2006-03-10 23:16:25 +0000 | [diff] [blame] | 33 | if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) { |
Glenn L McGrath | 17b4a20 | 2004-01-15 11:50:19 +0000 | [diff] [blame] | 34 | bb_perror_msg_and_die("VT_DISALLOCATE"); |
35 | } | ||||
36 | return EXIT_SUCCESS; | ||||
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 37 | } |