Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

There is no /dev/ttyv10 on FreeBSD #1854

Closed
lantw44 opened this issue Oct 14, 2019 · 7 comments · Fixed by #1945
Closed

There is no /dev/ttyv10 on FreeBSD #1854

lantw44 opened this issue Oct 14, 2019 · 7 comments · Fixed by #1945
Labels

Comments

@lantw44
Copy link
Contributor

lantw44 commented Oct 14, 2019

In file backend/session/direct-freebsd.c, function setup_tty, it constructs the path to vty with:

snprintf(tty_path, sizeof(tty_path), "/dev/ttyv%d", tty - 1);

It fails when tty - 1 is 10 or greater because there is no /dev/ttyv10 on the system. FreeBSD uses /dev/ttyva and /dev/ttyvb instead.

$ ls -1 /dev/ttyv*
/dev/ttyv0
/dev/ttyv1
/dev/ttyv2
/dev/ttyv3
/dev/ttyv4
/dev/ttyv5
/dev/ttyv6
/dev/ttyv7
/dev/ttyv8
/dev/ttyv9
/dev/ttyva
/dev/ttyvb

This causes sway to fail with 'Cannot open tty: No such file or directory.'

@ascent12
Copy link
Member

Patches are welcome. We don't really have a prominent FreeBSD user/maintainer to test things like this.

@valpackett
Copy link
Contributor

Did you launch a bunch of direct sessions simultaneously? :) I've never really used more than one display server, and I use consolekit anyway so my wayfire is on /dev/ttyv0 all the time.

This seems trivial, try changing that line to use %x instead of %d.

@lantw44
Copy link
Contributor Author

lantw44 commented Oct 18, 2019

Did you launch a bunch of direct sessions simultaneously? :)

Yes!

/dev/ttyv8 ran GDM (installed from FreeBSD ports) on Xorg.
/dev/ttyv9 ran GNOME (installed from upstream git) on Xorg.

The next vty available for use was /dev/ttyva, but wlroots chose /dev/ttyv10 and failed.

I've never really used more than one display server, and I use consolekit anyway so my wayfire is on /dev/ttyv0 all the time.

I know there is an option called CONSOLEKIT in x11-toolkits/wlroots port, but I don't know how to use it. I was just finding an easy way to run Wayland natively on FreeBSD. I used to run mutter in nested mode (mutter --wayland --nested --no-x11), but I guess applications and toolkits may behave differently if I run them natively.

This bug was found during testing a GTK4 bug: https://gitlab.gnome.org/GNOME/gtk/issues/2201.

This seems trivial, try changing that line to use %x instead of %d.

I already did it on my local installation, but I haven't checked how the kernel will pick the name if the number of consoles is greater than 16.

@emersion emersion added the bug label Oct 22, 2019
@lantw44
Copy link
Contributor Author

lantw44 commented Oct 27, 2019

This seems trivial, try changing that line to use %x instead of %d.

I already did it on my local installation, but I haven't checked how the kernel will pick the name if the number of consoles is greater than 16.

I increased the number of consoles to 1600 in a VM in order to understand how the kernel chooses names. It seems that it is a number of base 32 with digits 0 ~ 9 and a ~ v. When the number goes up to /dev/ttyvv, the next device is /dev/ttyv10. The same thing happens when the number goes up to /dev/ttyvvv. The next device is /dev/ttyv100.

lantw44 added a commit to lantw44/wlroots that referenced this issue Dec 7, 2019
Previously, the path of TTY is generated using snprintf with %d format.
It works with TTY 1 to 10, but fails with TTY with greater number
because the number used in the name is in base 32 instead of base 10.
Since there is no standard function to convert a number to a string with
a custom base, this commit adds a function to do it.

Fixes: swaywm#1854
@lantw44
Copy link
Contributor Author

lantw44 commented Dec 7, 2019

I opened #1945 to fix this issue.

lantw44 added a commit to lantw44/wlroots that referenced this issue Dec 22, 2019
Previously, the path of TTY is generated using snprintf with %d format.
It works with TTY 1 to 10, but fails with TTY with greater number
because the number used in the name is in base 32 instead of base 10.
Since there is no standard function to convert a number to a string with
a custom base, this commit adds a function to do it.

Fixes: swaywm#1854
emersion pushed a commit that referenced this issue Dec 22, 2019
Previously, the path of TTY is generated using snprintf with %d format.
It works with TTY 1 to 10, but fails with TTY with greater number
because the number used in the name is in base 32 instead of base 10.
Since there is no standard function to convert a number to a string with
a custom base, this commit adds a function to do it.

Fixes: #1854
@shamazmazum
Copy link

shamazmazum commented Dec 28, 2019

Please forgive me for a little offtopic.

@lantw44 With consolekit2 you do not have to mess with permissions of /dev/input/event* devices (like granting RW access for all users) or even set setuid flag on wayland compositor to get input devices working.

More info here, you may find this interesting: https://lists.freebsd.org/pipermail/freebsd-x11/2019-September/024038.html

@lantw44
Copy link
Contributor Author

lantw44 commented Jan 5, 2020

@shamazmazum Thanks for the link. It seems that I can't use CONSOLEKIT option without applying patches to ports.

filips pushed a commit to filips/wlroots that referenced this issue Mar 15, 2020
Previously, the path of TTY is generated using snprintf with %d format.
It works with TTY 1 to 10, but fails with TTY with greater number
because the number used in the name is in base 32 instead of base 10.
Since there is no standard function to convert a number to a string with
a custom base, this commit adds a function to do it.

Fixes: swaywm#1854
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

5 participants