From 5e0f4848e5bfd325840d405582bdedf3a27b98f8 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Mon, 27 Aug 2007 16:34:45 -0400 Subject: move some of the freebsd specific stuff into sysdeps --- src/ck-sysdeps-solaris.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/ck-sysdeps-solaris.c') diff --git a/src/ck-sysdeps-solaris.c b/src/ck-sysdeps-solaris.c index 83a28f8..ac41ece 100644 --- a/src/ck-sysdeps-solaris.c +++ b/src/ck-sysdeps-solaris.c @@ -28,6 +28,7 @@ #include #include #include +#include #define DEV_ENCODE(M,m) ( \ ( (M&0xfff) << 8) | ( (m&0xfff00) << 12) | (m&0xff) \ @@ -41,6 +42,10 @@ #include "ck-sysdeps.h" +#ifndef ERROR +#define ERROR -1 +#endif + /* adapted from procps */ struct _CkProcessStat { @@ -419,3 +424,46 @@ ck_get_console_num_from_device (const char *device, return ret; } + +gboolean +ck_get_active_console_num (int console_fd, + guint *num) +{ + gboolean ret; + int res; + guint active; + struct vt_stat stat; + + g_assert (console_fd != -1); + + active = 0; + ret = FALSE; + + res = ioctl (console_fd, VT_GETSTATE, &stat); + if (res == ERROR) { + perror ("ioctl VT_GETSTATE"); + goto out; + } + + { + 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); + + g_debug ("VT %d:%s", i, is_on ? "on" : "off"); + } + } + + active = stat.v_active; + ret = TRUE; + + out: + if (num != NULL) { + *num = active; + } + + return ret; +} -- cgit