X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=console-tools%2Fdeallocvt.c;h=15cd0c9b9a76b3087f795887f0f869485b2a6b6e;hb=6069441bd20b24f7102ebd66f9373a4de0d7e92c;hp=0cad7717b644ce7cb7aa432d21ab6152f9fada24;hpb=bd22ed806782eec76929bcd2ec556717e79d24c7;p=oweals%2Fbusybox.git diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index 0cad7717b..15cd0c9b9 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c @@ -3,56 +3,41 @@ * disalloc.c - aeb - 940501 - Disallocate virtual terminal(s) * Renamed deallocvt. */ -#include "internal.h" #include #include #include #include #include +#include "busybox.h" /* From */ -#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ - - -char *progname; +static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */ int deallocvt_main(int argc, char *argv[]) { int fd, num, i; - if ((argc != 2) || (**(argv + 1) == '-')) { - usage - ("deallocvt N\n" -#ifndef BB_FEATURE_TRIVIAL_HELP - "\nDeallocate unused virtual terminal /dev/ttyN\n" -#endif - ); - } - - progname = argv[0]; + //if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-'))) + if (argc > 2) + show_usage(); fd = get_console_fd("/dev/console"); if (argc == 1) { /* deallocate all unused consoles */ - if (ioctl(fd, VT_DISALLOCATE, 0)) { - perror("VT_DISALLOCATE"); - exit( FALSE); - } - } else + if (ioctl(fd, VT_DISALLOCATE, 0)) + perror_msg_and_die("VT_DISALLOCATE"); + } else { for (i = 1; i < argc; i++) { num = atoi(argv[i]); if (num == 0) - fprintf(stderr, "%s: 0: illegal VT number\n", progname); + error_msg("0: illegal VT number"); else if (num == 1) - fprintf(stderr, "%s: VT 1 cannot be deallocated\n", - progname); - else if (ioctl(fd, VT_DISALLOCATE, num)) { - perror("VT_DISALLOCATE"); - fprintf(stderr, "%s: could not deallocate console %d\n", - progname, num); - exit( FALSE); - } + error_msg("VT 1 cannot be deallocated"); + else if (ioctl(fd, VT_DISALLOCATE, num)) + perror_msg_and_die("VT_DISALLOCATE"); } - return( TRUE); + } + + return EXIT_SUCCESS; }