diff options
author | William Jon McCann <mccann@jhu.edu> | 2007-08-27 16:34:45 -0400 |
---|---|---|
committer | William Jon McCann <mccann@jhu.edu> | 2007-08-27 16:34:45 -0400 |
commit | 5e0f4848e5bfd325840d405582bdedf3a27b98f8 (patch) | |
tree | e51bdb438578cb63c8e1cecb62cde6e718edcf26 /src/ck-sysdeps-solaris.c | |
parent | 54b545beb4b7e65f852f03dd5da025d5eae7ef8f (diff) |
move some of the freebsd specific stuff into sysdeps
Diffstat (limited to 'src/ck-sysdeps-solaris.c')
-rw-r--r-- | src/ck-sysdeps-solaris.c | 48 |
1 files changed, 48 insertions, 0 deletions
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 <errno.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/ioctl.h> #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; +} |