Hi,
I hacked a small patch that fixes this problem with udev for me.
I don't really like this solution, but openvt from console-utils uses
the same way. And, as far as I can see, there aren't many other options.
hälsningar,
emanuel
==========================
diff -du ../../vlock-2.1/src/vlock.h ./vlock.h
--- ../../vlock-2.1/src/vlock.h 2007-09-08 20:04:25.000000000 +0200
+++ ./vlock.h 2007-11-13 19:54:26.000000000 +0100
@@ -14,13 +14,14 @@
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define CONSOLE "/dev/ttyv0"
#else
-#define CONSOLE "/dev/tty0"
+#define CONSOLE "/dev/console"
#endif
/* template for the device of a given virtual console */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define VTNAME "/dev/ttyv%x"
#else
#define VTNAME "/dev/tty%d"
+#define UDEVVTNAME "/dev/vc/%d"
#endif
/* hard coded paths */
diff -du ../../vlock-2.1/src/vlock-new.c ./vlock-new.c
--- ../../vlock-2.1/src/vlock-new.c 2007-09-08 20:04:25.000000000 +0200
+++ ./vlock-new.c 2007-11-13 20:52:11.000000000 +0100
@@ -14,10 +14,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/types.h>
+#include <errno.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <sys/consio.h>
@@ -53,8 +55,9 @@
/* Get the device name for the given console number.
* Returns the device name or NULL on error. */
-static char *get_console_name(int n) {
- static char name[sizeof VTNAME + 2];
+static char *get_console_name(char* vtbase, int n) {
+ /* instead of 25 the original uses "sizeof VTNAME" - would need to check
both... */
+ static char name[25];
size_t namelen;
if (n <= 0)
@@ -62,9 +65,9 @@
/* format the virtual terminal filename from the number */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- namelen = snprintf(name, sizeof name, VTNAME, n-1);
+ namelen = snprintf(name, sizeof name, vtbase, n-1);
#else
- namelen = snprintf(name, sizeof name, VTNAME, n);
+ namelen = snprintf(name, sizeof name, vtbase, n);
#endif
if (namelen > sizeof name) {
@@ -117,10 +120,18 @@
}
/* get the device name for the new virtual console */
- vtname = get_console_name(vtno);
+ vtname = get_console_name(VTNAME, vtno);
/* open the free virtual terminal */
- if ((vtfd = open(vtname, O_RDWR)) < 0) {
+ vtfd = open(vtname, O_RDWR);
+ if ((vtfd == -1) && (errno == ENOENT))
+ {
+ /* Maybe we're on a system with udev/devfs */
+ vtname = get_console_name(UDEVVTNAME, vtno);
+ vtfd = open (vtname, O_RDWR);
+ }
+
+ if (vtfd < 0) {
perror("vlock-new: cannot open new console");
exit (111);
}