blob: a8feeb53c90d1ac8e4b4cd336c3345d50393687c [file] [log] [blame]
Eric Andersen0460ff21999-10-25 23:32:44 +00001/*
2 * disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
3 * Renamed deallocvt.
4 */
5#include <stdlib.h>
6#include <fcntl.h>
7#include <sys/types.h>
8#include <sys/ioctl.h>
9#include <linux/vt.h>
10#include <stdio.h>
11
12extern int getfd(void);
13char *progname;
14
15int
16deallocvt_main(int argc, char *argv[]) {
17 int fd, num, i;
18
19 if (argc < 1) /* unlikely */
20 exit(1);
21 progname = argv[0];
22
23 fd = get_console_fd("/dev/console");
24
25 if (argc == 1) {
26 /* deallocate all unused consoles */
27 if (ioctl(fd,VT_DISALLOCATE,0)) {
28 perror("VT_DISALLOCATE");
29 exit(1);
30 }
31 } else
32 for (i = 1; i < argc; i++) {
33 num = atoi(argv[i]);
34 if (num == 0)
35 fprintf(stderr, "%s: 0: illegal VT number\n", progname);
36 else if (num == 1)
37 fprintf(stderr, "%s: VT 1 cannot be deallocated\n", progname);
38 else
39 if (ioctl(fd,VT_DISALLOCATE,num)) {
40 perror("VT_DISALLOCATE");
41 fprintf(stderr, "%s: could not deallocate console %d\n",
42 progname, num);
43 exit(1);
44 }
45 }
46 exit(0);
47}