diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-02-07 12:22:55 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-02-07 12:22:55 +0800 |
commit | cd7cc8241025492f992029e7692fcfe0cacb529e (patch) | |
tree | 9f64d0313e8aa58585252f99a3462982e71f1448 /sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c | |
parent | cf365293357796236193264f1992d92ba7397f09 (diff) | |
download | marcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.tar.gz marcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.tar.zst marcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.zip |
* Fix the tty/VT mapping code to be more inline with the way the kernel
works [1]
* Switch from using /dev/console to /dev/consolectl [1]
* Remove hack to check if ttyv* devices are available. We have other code
to do this now
Reviewed by: bland [1]
Requested by: bland [1]
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@10367 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c')
-rw-r--r-- | sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c | 104 |
1 files changed, 64 insertions, 40 deletions
diff --git a/sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c b/sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c index 35e000cc5..5a0e1248b 100644 --- a/sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c +++ b/sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c @@ -1,17 +1,14 @@ --- src/ck-sysdeps-freebsd.c.orig 2008-01-23 09:30:44.000000000 -0500 -+++ src/ck-sysdeps-freebsd.c 2008-02-04 20:56:57.000000000 -0500 -@@ -43,6 +43,10 @@ - ( (M&0xfff) << 8) | ( (m&0xfff00) << 12) | (m&0xff) \ - ) - -+#ifndef MAXCONS -+#define MAXCONS 16 -+#endif -+ - #include "ck-sysdeps.h" - - #ifndef ERROR -@@ -202,7 +206,6 @@ ck_process_stat_new_for_unix_pid (pid_t ++++ src/ck-sysdeps-freebsd.c 2008-02-06 22:50:57.000000000 -0500 +@@ -27,6 +27,7 @@ + #include <unistd.h> + #include <string.h> + #include <errno.h> ++#include <glob.h> + #include <paths.h> + #include <ttyent.h> + #include <kvm.h> +@@ -202,7 +203,6 @@ ck_process_stat_new_for_unix_pid (pid_t GError **error) { gboolean res; @@ -19,7 +16,7 @@ CkProcessStat *proc; g_return_val_if_fail (pid > 1, FALSE); -@@ -217,7 +220,6 @@ ck_process_stat_new_for_unix_pid (pid_t +@@ -217,7 +217,6 @@ ck_process_stat_new_for_unix_pid (pid_t if (res) { *stat = proc; } else { @@ -27,7 +24,7 @@ *stat = NULL; } -@@ -318,38 +320,36 @@ gboolean +@@ -318,38 +317,40 @@ gboolean ck_get_max_num_consoles (guint *num) { int max_consoles; @@ -35,46 +32,43 @@ - gboolean ret; - struct ttyent *t; + int i; ++ glob_t g; - ret = FALSE; -- max_consoles = 0; -- + max_consoles = 0; + - res = setttyent (); - if (res == 0) { - goto done; - } -+ max_consoles = 0; - +- - while ((t = getttyent ()) != NULL) { - if (t->ty_status & TTY_ON && strncmp (t->ty_name, "ttyv", 4) == 0) -- max_consoles++; -- } -+ for (i = 0; i < MAXCONS; i++) { ++ g.gl_offs = 0; ++ glob ("/dev/ttyv*", GLOB_DOOFFS, NULL, &g); ++ for (i = 0; i < g.gl_pathc && g.gl_pathv[i] != NULL; i++) { + int fd; + char *cdev; + -+ cdev = g_strdup_printf ("/dev/ttyv%x", i); ++ cdev = g.gl_pathv[i]; + fd = open (cdev, O_RDONLY | O_NOCTTY); -+ g_free (cdev); + if (fd > -1) { + close (fd); -+ max_consoles++; + max_consoles++; + } else { + break; + } -+ } + } + +- /* Increment one more so that all consoles are properly counted ++ globfree (&g); + + /* + * Increment one more so that all consoles are properly counted -+ * this is arguable a bug in vt_add_watches(). -+ */ -+ max_consoles++; + * this is arguable a bug in vt_add_watches(). + */ + max_consoles++; -- /* Increment one more so that all consoles are properly counted -- * this is arguable a bug in vt_add_watches(). -- */ -- max_consoles++; -- - ret = TRUE; - - endttyent (); @@ -89,30 +83,60 @@ } char * -@@ -360,7 +360,7 @@ ck_get_console_device_for_num (guint num +@@ -360,7 +361,12 @@ ck_get_console_device_for_num (guint num /* The device number is always one less than the VT number. */ num--; - device = g_strdup_printf ("/dev/ttyv%u", num); -+ device = g_strdup_printf ("/dev/ttyv%x", num); ++ if (num < 10) ++ device = g_strdup_printf ("/dev/ttyv%i", num); ++ else if (num < 32) ++ device = g_strdup_printf ("/dev/ttyv%c", num - 10 + 'a'); ++ else ++ device = NULL; return device; } -@@ -379,7 +379,7 @@ ck_get_console_num_from_device (const ch +@@ -370,6 +376,7 @@ ck_get_console_num_from_device (const ch + guint *num) + { + guint n; ++ char c; + gboolean ret; + + n = 0; +@@ -379,7 +386,11 @@ ck_get_console_num_from_device (const ch return FALSE; } - if (sscanf (device, "/dev/ttyv%u", &n) == 1) { -+ if (sscanf (device, "/dev/ttyv%x", &n) == 1) { ++ if (sscanf (device, "/dev/ttyv%c", &c) == 1) { ++ if (c < 58) ++ n = c - 48; ++ else ++ n = c - 'a' + 10; /* The VT number is always one more than the device number. */ n++; ret = TRUE; -@@ -411,7 +411,7 @@ ck_get_active_console_num (int consol +@@ -399,6 +410,7 @@ ck_get_active_console_num (int consol + gboolean ret; + int res; + int active; ++ char ttyn; + + g_assert (console_fd != -1); + +@@ -411,7 +423,12 @@ ck_get_active_console_num (int consol goto out; } - g_debug ("Active VT is: %d (ttyv%d)", active, active - 1); -+ g_debug ("Active VT is: %d (ttyv%x)", active, active - 1); ++ if (active - 1 < 10) ++ ttyn = active - 1 + '0'; ++ else ++ ttyn = active - 11 + 'a'; ++ ++ g_debug ("Active VT is: %d (ttyv%c)", active, ttyn); ret = TRUE; out: |