diff options
author | Karel Zak | 2006-12-07 00:25:48 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:48 +0100 |
commit | 364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed (patch) | |
tree | c60dfad813ca42bf619fe2ac8ce893d2331e508f /hwclock/kd.c | |
parent | Imported from util-linux-2.11b tarball. (diff) | |
download | kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.tar.gz kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.tar.xz kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.zip |
Imported from util-linux-2.11f tarball.
Diffstat (limited to 'hwclock/kd.c')
-rw-r--r-- | hwclock/kd.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/hwclock/kd.c b/hwclock/kd.c index a2f313f6d..f3327e1cc 100644 --- a/hwclock/kd.c +++ b/hwclock/kd.c @@ -9,6 +9,7 @@ static int con_fd = -1; /* opened by probe_for_kd_clock() */ /* never closed */ +static char *con_fd_filename; /* usually "/dev/tty1" */ /* Get defines for KDGHWCLK and KDSHWCLK (m68k) */ #include <linux/kd.h> @@ -88,7 +89,7 @@ read_hardware_clock_kd(struct tm *tm) { struct hwclk_time t; if (ioctl(con_fd, KDGHWCLK, &t) == -1) { - outsyserr(_("ioctl() failed to read time from /dev/tty1")); + outsyserr(_("ioctl() failed to read time from %s"), con_fd_filename); exit(5); } @@ -146,22 +147,29 @@ static struct clock_ops kd = { /* return &kd if KDGHWCLK works, NULL otherwise */ struct clock_ops * probe_for_kd_clock() { - struct clock_ops *ret = NULL; - struct hwclk_time t; - - if (con_fd < 0) - con_fd = open("/dev/tty1", O_RDONLY); - if (con_fd >= 0) { - if (ioctl( con_fd, KDGHWCLK, &t ) == -1) { - if (errno != EINVAL) - outsyserr(_("KDGHWCLK ioctl failed")); - } else - ret = &kd; - } else { - /* probably KDGHWCLK exists on m68k only */ + struct clock_ops *ret = NULL; + struct hwclk_time t; + + if (con_fd < 0) { /* first time here */ + con_fd_filename = "/dev/tty1"; + con_fd = open(con_fd_filename, O_RDONLY); + } + if (con_fd < 0) { + /* perhaps they are using devfs? */ + con_fd_filename = "/dev/vc/1"; + con_fd = open(con_fd_filename, O_RDONLY); + } + if (con_fd < 0) { + /* probably KDGHWCLK exists on m68k only */ #ifdef __m68k__ - outsyserr(_("Can't open /dev/tty1")); + outsyserr(_("Can't open /dev/tty1 or /dev/vc/1")); #endif - } - return ret; + } else { + if (ioctl(con_fd, KDGHWCLK, &t) == -1) { + if (errno != EINVAL) + outsyserr(_("KDGHWCLK ioctl failed")); + } else + ret = &kd; + } + return ret; } |