summaryrefslogtreecommitdiff
path: root/console-tools
diff options
context:
space:
mode:
authorEric Andersen2003-04-27 10:42:31 +0000
committerEric Andersen2003-04-27 10:42:31 +0000
commita860bec167faa960231b7f3c1ca55a49cda5a9d2 (patch)
tree134a61e4bc83baa7dcd554e58cb1b4ad6199a5c0 /console-tools
parent7a54360cd4130f5891e178b6d33eb5b15398c721 (diff)
downloadbusybox-a860bec167faa960231b7f3c1ca55a49cda5a9d2.zip
busybox-a860bec167faa960231b7f3c1ca55a49cda5a9d2.tar.gz
A couple of patches from Tito <farmatito@tiscali.it>
Diffstat (limited to 'console-tools')
-rw-r--r--console-tools/deallocvt.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index a4ba851..f641be8 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -15,29 +15,32 @@ static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
- int fd, num, i;
+ int fd, num=0;
- //if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
if (argc > 2)
bb_show_usage();
fd = get_console_fd();
+
+ /* num=0 deallocate all unused consoles */
+ if (argc == 1)
+ goto disallocate_all;
- if (argc == 1) {
- /* deallocate all unused consoles */
- if (ioctl(fd, VT_DISALLOCATE, 0))
- bb_perror_msg_and_die("VT_DISALLOCATE");
- } else {
- for (i = 1; i < argc; i++) {
- num = atoi(argv[i]);
- if (num == 0)
- bb_error_msg("0: illegal VT number");
- else if (num == 1)
- bb_error_msg("VT 1 cannot be deallocated");
- else if (ioctl(fd, VT_DISALLOCATE, num))
+ num=bb_xgetlarg(argv[1], 10, 0, INT_MAX);
+
+ switch(num)
+ {
+ case 0:
+ bb_error_msg("0: illegal VT number");
+ break;
+ case 1:
+ bb_error_msg("VT 1 cannot be deallocated");
+ break;
+ default:
+disallocate_all:
+ if (ioctl(fd, VT_DISALLOCATE, num))
bb_perror_msg_and_die("VT_DISALLOCATE");
- }
+ return EXIT_SUCCESS;
}
-
- return EXIT_SUCCESS;
+ return EXIT_FAILURE;
}