summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2008-02-07 12:22:55 +0800
committermarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2008-02-07 12:22:55 +0800
commitcd7cc8241025492f992029e7692fcfe0cacb529e (patch)
tree9f64d0313e8aa58585252f99a3462982e71f1448
parentcf365293357796236193264f1992d92ba7397f09 (diff)
downloadmarcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.tar
marcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.tar.gz
marcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.tar.bz2
marcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.tar.lz
marcuscom-ports-cd7cc8241025492f992029e7692fcfe0cacb529e.tar.xz
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
-rw-r--r--sysutils/consolekit/Makefile2
-rw-r--r--sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c104
-rw-r--r--sysutils/consolekit/files/patch-src_ck-sysdeps-unix.c18
-rw-r--r--sysutils/consolekit/files/patch-src_ck-vt-monitor.c130
-rw-r--r--sysutils/consolekit/files/patch-src_main.c22
5 files changed, 94 insertions, 182 deletions
diff --git a/sysutils/consolekit/Makefile b/sysutils/consolekit/Makefile
index bf59f80dd..f1febb962 100644
--- a/sysutils/consolekit/Makefile
+++ b/sysutils/consolekit/Makefile
@@ -7,7 +7,7 @@
PORTNAME= consolekit
PORTVERSION= 0.2.7
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= sysutils gnome
MASTER_SITES= http://people.freedesktop.org/~mccann/dist/
DISTFILES= ConsoleKit-${PORTVERSION}${EXTRACT_SUFX}
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:
diff --git a/sysutils/consolekit/files/patch-src_ck-sysdeps-unix.c b/sysutils/consolekit/files/patch-src_ck-sysdeps-unix.c
new file mode 100644
index 000000000..e256e9f36
--- /dev/null
+++ b/sysutils/consolekit/files/patch-src_ck-sysdeps-unix.c
@@ -0,0 +1,18 @@
+--- src/ck-sysdeps-unix.c.orig 2008-02-06 22:59:55.000000000 -0500
++++ src/ck-sysdeps-unix.c 2008-02-06 22:52:34.000000000 -0500
+@@ -172,6 +172,15 @@ ck_get_a_console_fd (void)
+
+ fd = -1;
+
++#ifdef __FreeBSD__
++ /* On FreeBSD, try /dev/consolectl first as this will survive
++ * /etc/ttys initialization. */
++ fd = open_a_console ("/dev/consolectl");
++ if (fd >= 0) {
++ goto done;
++ }
++#endif
++
+ #ifdef __sun
+ /* On Solaris, first try Sun VT device. */
+ fd = open_a_console ("/dev/vt/active");
diff --git a/sysutils/consolekit/files/patch-src_ck-vt-monitor.c b/sysutils/consolekit/files/patch-src_ck-vt-monitor.c
deleted file mode 100644
index 7db4a4682..000000000
--- a/sysutils/consolekit/files/patch-src_ck-vt-monitor.c
+++ /dev/null
@@ -1,130 +0,0 @@
---- src/ck-vt-monitor.c.orig 2008-01-23 09:30:44.000000000 -0500
-+++ src/ck-vt-monitor.c 2008-01-23 15:29:52.000000000 -0500
-@@ -54,6 +54,9 @@ struct CkVtMonitorPrivate
-
- GAsyncQueue *event_queue;
- guint process_queue_id;
-+
-+ GAsyncQueue *restart_queue;
-+ guint restart_queue_id;
- };
-
- enum {
-@@ -72,6 +75,7 @@ static void ck_vt_monitor_init
- static void ck_vt_monitor_finalize (GObject *object);
-
- static void vt_add_watches (CkVtMonitor *vt_monitor);
-+static void vt_add_watch_unlocked (CkVtMonitor *vt_monitor, gint32 num);
-
- G_DEFINE_TYPE (CkVtMonitor, ck_vt_monitor, G_TYPE_OBJECT)
-
-@@ -254,6 +258,56 @@ process_queue (CkVtMonitor *vt_monitor)
- return FALSE;
- }
-
-+static gboolean
-+process_restart_queue (CkVtMonitor *vt_monitor)
-+{
-+ int i;
-+ int queue_length;
-+ EventData *data;
-+ EventData *d;
-+
-+ g_async_queue_lock (vt_monitor->priv->restart_queue);
-+
-+ g_debug ("Processing VT restart queue");
-+
-+ queue_length = g_async_queue_length_unlocked (vt_monitor->priv->restart_queue);
-+ data = NULL;
-+
-+ G_LOCK (hash_lock);
-+
-+ /* compress events in the queue */
-+ for (i = 0; i < queue_length; i++) {
-+ d = g_async_queue_try_pop_unlocked (vt_monitor->priv->restart_queue);
-+ if (d == NULL) {
-+ continue;
-+
-+ }
-+
-+ if (data != NULL) {
-+ g_debug ("Compressing queue; skipping restart for VT %d", data->num);
-+ event_data_free (data);
-+ }
-+
-+ data = d;
-+ }
-+
-+ if (data != NULL) {
-+ vt_add_watch_unlocked (vt_monitor, data->num);
-+ event_data_free (data);
-+ }
-+
-+ G_UNLOCK (hash_lock);
-+
-+ G_LOCK (schedule_lock);
-+ vt_monitor->priv->restart_queue_id = 0;
-+ G_UNLOCK (schedule_lock);
-+
-+ g_async_queue_unlock (vt_monitor->priv->restart_queue);
-+
-+ return FALSE;
-+}
-+
-+
- static void
- schedule_process_queue (CkVtMonitor *vt_monitor)
- {
-@@ -264,6 +318,16 @@ schedule_process_queue (CkVtMonitor *vt_
- G_UNLOCK (schedule_lock);
- }
-
-+static void
-+schedule_process_restart_queue (CkVtMonitor *vt_monitor)
-+{
-+ G_LOCK (schedule_lock);
-+ if (vt_monitor->priv->restart_queue_id == 0) {
-+ vt_monitor->priv->restart_queue_id = g_idle_add ((GSourceFunc)process_restart_queue, vt_monitor);
-+ }
-+ G_UNLOCK (schedule_lock);
-+}
-+
- static void *
- vt_thread_start (ThreadData *data)
- {
-@@ -277,7 +341,15 @@ vt_thread_start (ThreadData *data)
-
- res = ck_wait_for_active_console_num (vt_monitor->priv->vfd, num);
- if (! res) {
-- /* FIXME: what do we do if it fails? */
-+ EventData *event;
-+
-+ event = g_new0 (EventData, 1);
-+ event->num = num;
-+ g_debug ("Failed to wait for active console %d: %s", num, g_strerror (errno));
-+
-+ g_async_queue_push (vt_monitor->priv->restart_queue, event);
-+
-+ schedule_process_restart_queue (vt_monitor);
- } else {
- EventData *event;
-
-@@ -414,6 +486,7 @@ ck_vt_monitor_init (CkVtMonitor *vt_moni
-
- vt_monitor->priv->active_num = active;
- vt_monitor->priv->event_queue = g_async_queue_new ();
-+ vt_monitor->priv->restart_queue = g_async_queue_new ();
- vt_monitor->priv->vt_thread_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
-
- vt_add_watches (vt_monitor);
-@@ -440,6 +513,10 @@ ck_vt_monitor_finalize (GObject *object)
- g_async_queue_unref (vt_monitor->priv->event_queue);
- }
-
-+ if (vt_monitor->priv->restart_queue != NULL) {
-+ g_async_queue_unref (vt_monitor->priv->restart_queue);
-+ }
-+
- if (vt_monitor->priv->vt_thread_hash != NULL) {
- g_hash_table_destroy (vt_monitor->priv->vt_thread_hash);
- }
diff --git a/sysutils/consolekit/files/patch-src_main.c b/sysutils/consolekit/files/patch-src_main.c
index b1a661aa3..a791db0f9 100644
--- a/sysutils/consolekit/files/patch-src_main.c
+++ b/sysutils/consolekit/files/patch-src_main.c
@@ -1,21 +1,21 @@
---- src/main.c.orig 2007-11-08 15:05:55.000000000 -0500
-+++ src/main.c 2007-11-08 15:07:39.000000000 -0500
+--- src/main.c.orig 2007-11-08 15:05:55.000000000 -0500
++++ src/main.c 2007-11-08 15:07:39.000000000 -0500
@@ -226,6 +226,21 @@ sigusr1_handler (int sig)
}
static void
+setup_termination_signals (void)
+{
-+ struct sigaction sa;
++ struct sigaction sa;
+
-+ sa.sa_handler = SIG_DFL;
-+ sigemptyset (&sa.sa_mask);
-+ sa.sa_flags = 0;
++ sa.sa_handler = SIG_DFL;
++ sigemptyset (&sa.sa_mask);
++ sa.sa_flags = 0;
+
-+ sigaction (SIGTERM, &sa, NULL);
-+ sigaction (SIGQUIT, &sa, NULL);
-+ sigaction (SIGINT, &sa, NULL);
-+ sigaction (SIGHUP, &sa, NULL);
++ sigaction (SIGTERM, &sa, NULL);
++ sigaction (SIGQUIT, &sa, NULL);
++ sigaction (SIGINT, &sa, NULL);
++ sigaction (SIGHUP, &sa, NULL);
+}
+
+static void
@@ -26,7 +26,7 @@
setup_debug_log (debug);
-+ setup_termination_signals ();
++ setup_termination_signals ();
+
connection = get_system_bus ();
if (connection == NULL) {