summaryrefslogtreecommitdiff
path: root/xserver/hw
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2016-04-24 17:20:05 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2016-04-24 17:20:05 +0000
commit2410283b72702ada9ff1f1c028d4ff9fc40d607b (patch)
tree52ced9019104de2d700b560faf5ffbd090fa10e5 /xserver/hw
parent4a9b9ee12660082a9505e1219fdc95818f342572 (diff)
Fall back to /dev/ttyC0 when the console device is not a wsdisplay(4)
Problem noticed by sthen@.
Diffstat (limited to 'xserver/hw')
-rw-r--r--xserver/hw/xfree86/os-support/bsd/bsd_init.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_init.c b/xserver/hw/xfree86/os-support/bsd/bsd_init.c
index bc3c53aca..21c003393 100644
--- a/xserver/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/xserver/hw/xfree86/os-support/bsd/bsd_init.c
@@ -611,17 +611,27 @@ xf86OpenWScons(void)
if (xf86Info.ShareVTs)
FatalError("-sharevt is not supported with wscons\n");
+ /* default value if probing the console device fails */
+ snprintf(vtprefix, sizeof(vtprefix), "/dev/ttyC");
+
+ /* probe console device - it my be /dev/ttyD0 on some multi-heads setups */
mib[0] = CTL_KERN;
mib[1] = KERN_CONSDEV;
len = sizeof(dev);
if (sysctl(mib, 2, &dev, &len, NULL, 0) != -1) {
- snprintf(vtprefix, sizeof(vtprefix), "/dev/%s", devname(dev, S_IFCHR));
- /* strip number, assuming 0 */
- p = strchr(vtprefix, '0');
- *p = '\0';
- } else
- snprintf(vtprefix, sizeof(vtprefix), "/dev/ttyC");
-
+ snprintf(vtname, sizeof(vtname), "/dev/%s", devname(dev, S_IFCHR));
+ if ((fd = open(vtname, O_RDWR)) != -1) {
+ if (ioctl(fd, WSDISPLAYIO_GTYPE, &i) == 0) {
+ /* console is a wsdisplay(4) device */
+ strlcpy(vtprefix, vtname, sizeof(vtprefix));
+ /* strip number, assuming 0 */
+ p = strchr(vtprefix, '0');
+ *p = '\0';
+ close(fd);
+ fd = -1;
+ }
+ }
+ }
if (VTnum != -1) {
snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix, VTnum - 1);
xf86Info.vtno = VTnum;