1
Index: trunk/src/fgconsole.c
2
===================================================================
3
--- trunk.orig/src/fgconsole.c
4
+++ trunk/src/fgconsole.c
11
+#include <linux/serial.h>
16
+static void usage(void)
18
+ fprintf(stderr, _("%s version %s\n"
20
+"Usage: %s [options]\n"
22
+"Valid options are:\n"
24
+" -h --help display this help text\n"
25
+" -V --version display this help text\n"
26
+" -n --next-available display next unallocated VT\n"),
27
+ progname, VERSION, progname);
32
main(int argc, char **argv){
34
struct vt_stat vtstat;
35
+ int fd, vtno = -1, c, show_vt = 0;
36
+ struct serial_struct sr;
37
+ const struct option long_opts[] = {
38
+ { "help", no_argument, NULL, 'h' },
39
+ { "version", no_argument, NULL, 'V' },
40
+ { "next-available", no_argument, NULL, 'n' },
41
+ { NULL, 0, NULL, 0 } };
43
setlocale(LC_ALL, "");
44
bindtextdomain(PACKAGE, LOCALEDIR);
47
+ set_progname(argv[0]);
48
+ while (( c = getopt_long (argc, argv, "Vhn", long_opts, NULL)) != EOF) {
57
+ print_version_and_exit();
66
- if (ioctl(fd, VT_GETSTATE, &vtstat)) {
67
- perror("fgconsole: VT_GETSTATE");
70
+ if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || vtno == -1) {
71
+ perror (_("Couldn't read VTNO: "));
74
+ printf ("%d\n", vtno);
78
+ if (ioctl(fd, TIOCGSERIAL, &sr) == 0) {
79
+ printf ("serial\n");
83
+ if (ioctl(fd, VT_GETSTATE, &vtstat))
85
+ perror("fgconsole: VT_GETSTATE");
88
printf("%d\n", vtstat.v_active);
91
Index: trunk/man/man1/fgconsole.1
92
===================================================================
93
--- trunk.orig/man/man1/fgconsole.1
94
+++ trunk/man/man1/fgconsole.1
100
+.BI [ "--help" | "--version" | "--next-available" ]
102
If the active Virtual Terminal is
108
+If the console is a serial console, then
112
+.I \-\-next\-available
113
+Will show the next unallocated virtual terminal. Normally 6 virtual
114
+terminals are allocated, with number 7 used for X; this will return