On 2016/04/21 22:04, Matthieu Herrb wrote:
> > Very probably the switch to native WSCONS support in the X server, and
> > more precisely the fact that the X server now uses sysctl to figure
> > out what is the console device to open.
> >
> > I need to tink a bit on a good solution...
> >
>
> This diff should fix the problem by testing if the console device is a
> wsdisplay(4) device and falling back to /dev/ttyCn otherwise. I've
> changed the logic a bit in the hope to make the code more readable,
> but it's still a bit of a mess.
Thanks Matthieu, that makes sense and a bit more readable, also it fixes
things for me. OK.
> I don't know if we need to add a knob to explicitely set the path of
> the device to use for X.
As Mark mentioned, I don't think it's something I am likely to use
myself, but the use cases he suggested do make sense to me.
> Index: bsd_init.c
> ===================================================================
> RCS file: /cvs/OpenBSD/xenocara/xserver/hw/xfree86/os-support/bsd/bsd_init.c,v
> retrieving revision 1.18
> diff -u -p -u -r1.18 bsd_init.c
> --- bsd_init.c 2 Apr 2016 14:25:10 -0000 1.18
> +++ bsd_init.c 21 Apr 2016 19:55:19 -0000
> @@ -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;
>
> --
> Matthieu Herrb