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-unix.c | |
parent | 54b545beb4b7e65f852f03dd5da025d5eae7ef8f (diff) |
move some of the freebsd specific stuff into sysdeps
Diffstat (limited to 'src/ck-sysdeps-unix.c')
-rw-r--r-- | src/ck-sysdeps-unix.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c index 6c9b34c..2094e48 100644 --- a/src/ck-sysdeps-unix.c +++ b/src/ck-sysdeps-unix.c @@ -33,6 +33,7 @@ #ifdef __linux__ #include <linux/kd.h> +#include <sys/vt.h> #endif #ifdef __FreeBSD__ @@ -45,6 +46,10 @@ #include "ck-sysdeps.h" +#ifndef ERROR +#define ERROR -1 +#endif + /* Adapted from dbus-sysdeps-unix.c:_dbus_read_credentials_socket() */ gboolean ck_get_socket_peer_credentials (int socket_fd, @@ -234,3 +239,67 @@ ck_is_root_user (void) #endif return FALSE; } + +gboolean +ck_wait_for_active_console_num (int console_fd, + guint num) +{ + gboolean ret; + int res; + + g_assert (console_fd != -1); + + again: + ret = FALSE; + + g_debug ("VT_WAITACTIVE for vt %d", num); + errno = 0; + res = ioctl (console_fd, VT_WAITACTIVE, num); + + g_debug ("VT_WAITACTIVE for vt %d returned %d", num, ret); + + if (res == ERROR) { + const char *errmsg; + + errmsg = g_strerror (errno); + + if (errno == EINTR) { + g_debug ("Interrupted waiting for native console %d activation: %s", + num, + errmsg); + goto again; + } else { + g_warning ("Error waiting for native console %d activation: %s", + num, + errmsg); + } + goto out; + } + + ret = TRUE; + + out: + return ret; +} + +gboolean +ck_activate_console_num (int console_fd, + guint num) +{ + gboolean ret; + int res; + + g_assert (console_fd != -1); + + ret = FALSE; + + errno = 0; + res = ioctl (console_fd, VT_ACTIVATE, num); + if (res == 0) { + ret = TRUE; + } else { + g_warning ("Unable to activate console: %s", g_strerror (errno)); + } + + return ret; +} |