diff options
author | Florent Thoumie <flz@FreeBSD.org> | 2007-08-25 19:50:54 +0100 |
---|---|---|
committer | Florent Thoumie <flz@FreeBSD.org> | 2007-08-25 19:50:54 +0100 |
commit | 59d8b48dc3358057859c22588580e926aa68a3ee (patch) | |
tree | 7bc337b7a5537f9931f055b427237337e388d2b3 /src | |
parent | 1a16c740e0eab279eeca443c1a1c276e5e125852 (diff) |
Some more fixes, Now test-vt-monitor works correctly.
Submitted by: marcus
Signed-off-by: Florent Thoumie <flz@FreeBSD.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/ck-sysdeps-unix.c | 14 | ||||
-rw-r--r-- | src/ck-vt-monitor.c | 35 |
2 files changed, 33 insertions, 16 deletions
diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c index fa18dac..6c9b34c 100644 --- a/src/ck-sysdeps-unix.c +++ b/src/ck-sysdeps-unix.c @@ -35,6 +35,10 @@ #include <linux/kd.h> #endif +#ifdef __FreeBSD__ +#include <sys/consio.h> +#endif + #ifdef HAVE_GETPEERUCRED #include <ucred.h> #endif @@ -114,14 +118,18 @@ ck_get_socket_peer_credentials (int socket_fd, gboolean ck_fd_is_a_console (int fd) { - char arg; +#ifdef __linux__ + char arg = 0; +#elif defined(__FreeBSD__) + int vers; +#endif int kb_ok; - arg = 0; - #ifdef __linux__ kb_ok = (ioctl (fd, KDGKBTYPE, &arg) == 0 && ((arg == KB_101) || (arg == KB_84))); +#elif defined(__FreeBSD__) + kb_ok = (ioctl (fd, CONS_GETVERS, &vers) == 0); #else kb_ok = 1; #endif diff --git a/src/ck-vt-monitor.c b/src/ck-vt-monitor.c index f71b7b5..58ca2fa 100644 --- a/src/ck-vt-monitor.c +++ b/src/ck-vt-monitor.c @@ -27,10 +27,10 @@ #include <string.h> #include <errno.h> #include <sys/ioctl.h> -#if defined(__linux__) -#include <sys/vt.h> -#elif defined(__FreeBSD__) +#if defined(__FreeBSD__) #include <sys/consio.h> +#else +#include <sys/vt.h> #endif #include <glib.h> @@ -368,7 +368,7 @@ vt_add_watches (CkVtMonitor *vt_monitor) max_consoles = 1; if (! ck_get_max_num_consoles (&max_consoles)) { - /* FIXME: this can fail on solaris */ + /* FIXME: this can fail on solaris and freebsd */ } for (i = 1; i < max_consoles; i++) { @@ -394,25 +394,34 @@ static guint get_active_native (CkVtMonitor *vt_monitor) { int ret; - int active; -#if defined(__linux__) +#if defined(__FreeBSD__) + int active; +#else struct vt_stat stat; +#endif +#if defined(__FreeBSD__) + ret = ioctl (vt_monitor->priv->vfd, VT_GETACTIVE, &active); +#else ret = ioctl (vt_monitor->priv->vfd, VT_GETSTATE, &stat); -#elif defined(__FreeBSD__) - ret = ioctl (vt_monitor->priv->vfd, VT_GETACTIVE, &active); #endif if (ret == ERROR) { +#if defined(__FreeBSD__) + perror ("ioctl VT_GETACTIVE"); +#else perror ("ioctl VT_GETSTATE"); +#endif return -1; } - g_debug ("Current VT: tty%d", active); - -#if defined(__linux__) +#if defined(__FreeBSD__) + g_debug ("Active VT is: ttyv%d", active); + return active; +#else { int i; + g_debug ("Current VT: tty%d", stat.v_active); for (i = 1; i <= 16; i++) { gboolean is_on; is_on = stat.v_state & (1 << i); @@ -420,9 +429,9 @@ get_active_native (CkVtMonitor *vt_monitor) g_debug ("VT %d:%s", i, is_on ? "on" : "off"); } } -#endif - return active; + return stat.v_active; +#endif } static void |