From: Frederic Crozat Date: Fri, 4 Sep 2009 14:19:38 +0000 (+0200) Subject: move switch_to_vt to ply-utils and rename it ply_switch_to_vt X-Git-Tag: 0.7.2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba0c9f50f92eb12c22530286f152e6c08911b672;p=thirdparty%2Fplymouth.git move switch_to_vt to ply-utils and rename it ply_switch_to_vt --- diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index eb334666..37b986be 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -893,4 +894,25 @@ ply_utf8_string_get_length (const char *string, return count; } +void +ply_switch_to_vt (int vt_number) +{ + int fd; + + fd = open ("/dev/tty0", O_RDWR | O_NOCTTY); + + if (fd < 0) + return; + + if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) + { + close (fd); + return; + } + + ioctl (fd, VT_WAITACTIVE, vt_number); + close (fd); +} + + /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ diff --git a/src/libply/ply-utils.h b/src/libply/ply-utils.h index 592a8e4e..62149ba3 100644 --- a/src/libply/ply-utils.h +++ b/src/libply/ply-utils.h @@ -104,6 +104,8 @@ int ply_utf8_character_get_size (const char *string, int ply_utf8_string_get_length (const char *string, size_t n); +void ply_switch_to_vt (int vt_number); + #endif #endif /* PLY_UTILS_H */ diff --git a/src/main.c b/src/main.c index a92e11f2..3bf15688 100644 --- a/src/main.c +++ b/src/main.c @@ -125,26 +125,6 @@ static void on_error_message (ply_buffer_t *debug_buffer, static ply_buffer_t *debug_buffer; static char *debug_buffer_path = NULL; -static void -switch_to_vt (int vt_number) -{ - int fd; - - fd = open ("/dev/tty0", O_RDWR | O_NOCTTY); - - if (fd < 0) - return; - - if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) - { - close (fd); - return; - } - - ioctl (fd, VT_WAITACTIVE, vt_number); - close (fd); -} - static void on_session_output (state_t *state, const char *output, @@ -1277,7 +1257,7 @@ initialize_environment (state_t *state) if (state->mode == PLY_MODE_SHUTDOWN) { default_tty = "tty63"; - switch_to_vt (63); + ply_switch_to_vt (63); } else default_tty = "tty1";