Submitted By: Richard Lightman Date: 2003-08-18 Initial Package Version: 1.08 Origin: Richard Lightman Description: Makes openvt work with devfs diff -Naur kbd-1.08/openvt/openvt.c kbd-1.08-openvtdevfs-1/openvt/openvt.c --- kbd-1.08/openvt/openvt.c 2002-10-11 11:08:59.000000000 +0000 +++ kbd-1.08-openvtdevfs-1/openvt/openvt.c 2003-08-18 17:00:24.000000000 +0000 @@ -29,10 +29,10 @@ const char *version = "openvt 1.4b - (c) Jon Tombs 1994"; -#ifndef VTNAME +#ifndef VTNAME2 #error vt device name must be defined in openvt.h #endif - +#define MAXVT 63 int main(int argc, char *argv[]) @@ -50,7 +50,7 @@ char verbose = FALSE; char do_wait = FALSE; char as_user = FALSE; - char vtname[sizeof VTNAME + 2]; /* allow 999 possible VTs */ + char vtname[sizeof VTNAME2 + 2]; /* allow 999 possible VTs */ char *cmd = NULL, *def_cmd = NULL, *username = NULL; /* @@ -63,7 +63,7 @@ case 'c': optc = 1; /* vtno was specified by the user */ vtno = (int) atol(optarg); - if (vtno <= 0 || vtno > 63) { + if (vtno <= 0 || vtno > MAXVT) { fprintf(stderr, _("openvt: %s: illegal vt number\n"), optarg); return 5; } @@ -118,7 +118,7 @@ return(3); } } else if (!force) { - if (vtno >= 16) { + if (vtno > MAXVT) { fprintf(stderr, _("openvt: cannot check whether vt %d is free\n"), vtno); fprintf(stderr, _(" use `openvt -f' to force.\n")); return(7); @@ -130,7 +130,7 @@ } } - sprintf(vtname, VTNAME, vtno); + sprintf(vtname, VTNAME2, vtno); /* Can we open the vt we want? */ if ((fd = open(vtname, O_RDWR)) == -1) { @@ -139,18 +139,18 @@ /* We found vtno ourselves - it is free according to the kernel, but we cannot open it. Maybe X used it and did a chown. Try a few vt's more - before giving up. Note: the 16 is a kernel limitation. */ + before giving up. Note: the MAXVT is a kernel limitation. */ int i; - for (i=vtno+1; i<16; i++) { + for (i=vtno+1; i<=MAXVT; i++) { if((vtstat.v_state & (1<= 0) { vtno = i; goto got_vtno; } } } - sprintf(vtname, VTNAME, vtno); + sprintf(vtname, VTNAME2, vtno); } fprintf(stderr, _("openvt: Unable to open %s: %s\n"), vtname, strerror(errsv)); @@ -339,13 +339,13 @@ /* get the current tty */ /* try /dev/ttyN, then /dev/vc/N */ - sprintf(filename, VTNAME, curvt); + sprintf(filename, VTNAME2, curvt); if (stat(filename,&buf)) { int errsv = errno; - sprintf(filename, VTNAME2, curvt); + sprintf(filename, VTNAME, curvt); if (stat(filename,&buf)) { /* give error message for first attempt */ - sprintf(filename, VTNAME, curvt); + sprintf(filename, VTNAME2, curvt); errno = errsv; perror(filename); exit(1);