FreeBSD Bugzilla – Attachment 210135 Details for
Bug 242801
x11-toolkits/wlroots: Fix usage on TTY 11 or higher
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch from https://github.com/swaywm/wlroots/pull/1945
wlroots.patch (text/plain), 3.19 KB, created by
Ting-Wei Lan
on 2019-12-22 12:32:05 UTC
(
hide
)
Description:
Patch from https://github.com/swaywm/wlroots/pull/1945
Filename:
MIME Type:
Creator:
Ting-Wei Lan
Created:
2019-12-22 12:32:05 UTC
Size:
3.19 KB
patch
obsolete
>Index: x11-toolkits/wlroots/files/patch-backend_session_direct-freebsd.c >=================================================================== >--- x11-toolkits/wlroots/files/patch-backend_session_direct-freebsd.c (nonexistent) >+++ x11-toolkits/wlroots/files/patch-backend_session_direct-freebsd.c (working copy) >@@ -0,0 +1,78 @@ >+From fc6c0ca12e941d5d7d567834bff3ab7df9447001 Mon Sep 17 00:00:00 2001 >+From: Ting-Wei Lan <lantw44@gmail.com> >+Date: Sat, 7 Dec 2019 22:29:20 +0800 >+Subject: [PATCH] backend/session/freebsd: Fix the way to get TTY path >+ >+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: https://github.com/swaywm/wlroots/issues/1854 >+--- backend/session/direct-freebsd.c.orig 2019-10-07 19:28:20 UTC >++++ backend/session/direct-freebsd.c >+@@ -139,6 +139,51 @@ static int vt_handler(int signo, void *data) { >+ return 1; >+ } >+ >++static bool get_tty_path(int tty, char path[static 11], size_t len) { >++ assert(tty > 0); >++ >++ const char prefix[] = "/dev/ttyv"; >++ static_assert(sizeof(prefix) + 1 <= 11, "TTY path prefix is too long"); >++ >++ const size_t prefix_len = sizeof(prefix) - 1; >++ strcpy(path, prefix); >++ >++ size_t offset = prefix_len; >++ const int num = tty - 1; >++ if (num == 0) { >++ path[offset++] = '0'; >++ path[offset++] = '\0'; >++ return true; >++ } >++ >++ const int base = 32; >++ for (int remaning = num; remaning > 0; remaning /= base, offset++) { >++ // Return early if the buffer is too small. >++ if (offset + 1 >= len) { >++ return false; >++ } >++ >++ const int value = remaning % base; >++ if (value >= 10) { >++ path[offset] = 'a' + value - 10; >++ } else { >++ path[offset] = '0' + value; >++ } >++ } >++ >++ const size_t num_len = offset - prefix_len; >++ for (size_t i = 0; i < num_len / 2; i++) { >++ const size_t p1 = prefix_len + i; >++ const size_t p2 = offset - 1 - i; >++ const char tmp = path[p1]; >++ path[p1] = path[p2]; >++ path[p2] = tmp; >++ } >++ >++ path[offset++] = '\0'; >++ return true; >++} >++ >+ static bool setup_tty(struct direct_session *session, struct wl_display *display) { >+ int fd = -1, tty = -1, tty0_fd = -1, old_tty = 1; >+ if ((tty0_fd = open("/dev/ttyv0", O_RDWR | O_CLOEXEC)) < 0) { >+@@ -155,7 +200,10 @@ static bool setup_tty(struct direct_session *session, >+ } >+ close(tty0_fd); >+ char tty_path[64]; >+- snprintf(tty_path, sizeof(tty_path), "/dev/ttyv%d", tty - 1); >++ if (!get_tty_path(tty, tty_path, sizeof(tty_path))) { >++ wlr_log(WLR_ERROR, "Could not get tty %d path", tty); >++ goto error; >++ } >+ wlr_log(WLR_INFO, "Using tty %s", tty_path); >+ fd = open(tty_path, O_RDWR | O_NOCTTY | O_CLOEXEC); >+ > >Property changes on: x11-toolkits/wlroots/files/patch-backend_session_direct-freebsd.c >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 242801
: 210135