diff options
author | Peter Jones <pjones@redhat.com> | 2008-06-09 15:40:35 -0400 |
---|---|---|
committer | Peter Jones <pjones@vroomfondel.internal.datastacks.com> | 2008-06-09 15:41:45 -0400 |
commit | 620e9477114c88ca4ac76a0ef76824164bb70ec1 (patch) | |
tree | 44ccc43ae6127ac5529f8f6db6f75dedfe8633d3 /src | |
parent | 7e85eafab617fef5478c6d9f551f044d67462466 (diff) | |
download | plymouth-620e9477114c88ca4ac76a0ef76824164bb70ec1.tar.gz plymouth-620e9477114c88ca4ac76a0ef76824164bb70ec1.tar.xz plymouth-620e9477114c88ca4ac76a0ef76824164bb70ec1.zip |
Add "plymouth --newroot=/sysroot" support, and make --sysinit open the log.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/ply-boot-client.c | 20 | ||||
-rw-r--r-- | src/client/ply-boot-client.h | 5 | ||||
-rw-r--r-- | src/client/plymouth.c | 12 | ||||
-rw-r--r-- | src/main.c | 21 | ||||
-rw-r--r-- | src/ply-boot-protocol.h | 1 | ||||
-rw-r--r-- | src/ply-boot-server.c | 14 | ||||
-rw-r--r-- | src/ply-boot-server.h | 5 |
7 files changed, 69 insertions, 9 deletions
diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c index fc998f1..e75309d 100644 --- a/src/client/ply-boot-client.c +++ b/src/client/ply-boot-client.c @@ -445,6 +445,20 @@ ply_boot_client_update_daemon (ply_boot_client_t *client, } void +ply_boot_client_tell_daemon_to_change_root (ply_boot_client_t *client, + const char *root_dir, + ply_boot_client_response_handler_t handler, + ply_boot_client_response_handler_t failed_handler, + void *user_data) +{ + assert (client != NULL); + assert (root_dir != NULL); + + ply_boot_client_queue_request(client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_NEWROOT, + root_dir, handler, failed_handler, user_data); +} + +void ply_boot_client_tell_daemon_system_is_initialized (ply_boot_client_t *client, ply_boot_client_response_handler_t handler, ply_boot_client_response_handler_t failed_handler, @@ -579,6 +593,12 @@ on_update_failed (ply_event_loop_t *loop) } static void +on_newroot (ply_event_loop_t *loop) +{ + printf ("NEWROOT!\n"); +} + +static void on_system_initialized (ply_event_loop_t *loop) { printf ("SYSTEM INITIALIZED!\n"); diff --git a/src/client/ply-boot-client.h b/src/client/ply-boot-client.h index c3240cd..8ee6718 100644 --- a/src/client/ply-boot-client.h +++ b/src/client/ply-boot-client.h @@ -54,6 +54,11 @@ void ply_boot_client_update_daemon (ply_boot_client_t *client, ply_boot_client_response_handler_t handler, ply_boot_client_response_handler_t failed_handler, void *user_data); +void ply_boot_client_tell_daemon_to_change_root (ply_boot_client_t *client, + const char *chroot_dir, + ply_boot_client_response_handler_t handler, + ply_boot_client_response_handler_t failed_handler, + void *user_data); void ply_boot_client_ask_daemon_for_password (ply_boot_client_t *client, ply_boot_client_answer_handler_t handler, ply_boot_client_response_handler_t failed_handler, diff --git a/src/client/plymouth.c b/src/client/plymouth.c index d4d04b2..9d40e14 100644 --- a/src/client/plymouth.c +++ b/src/client/plymouth.c @@ -60,7 +60,7 @@ on_disconnect (ply_event_loop_t *loop) void print_usage (void) { - ply_log ("plymouth [--ping] [--update=STATUS] [--show-splash] [--details] [--sysinit] [--quit]"); + ply_log ("plymouth [--ping] [--update=STATUS] [--show-splash] [--details] [--newroot=<directory>] [--sysinit] [--quit]"); ply_flush_log (); } @@ -72,7 +72,7 @@ main (int argc, ply_boot_client_t *client; ply_command_parser_t *command_parser; bool should_help, should_quit, should_ping, should_sysinit, should_ask_for_password, should_show_splash; - char *status; + char *status, *chroot_dir; int exit_code; int i; @@ -90,6 +90,7 @@ main (int argc, ply_command_parser_add_options (command_parser, "help", "This help message", PLY_COMMAND_OPTION_TYPE_FLAG, + "newroot", "Tell boot daemon that new root filesystem is mounted", PLY_COMMAND_OPTION_TYPE_STRING, "quit", "Tell boot daemon to quit", PLY_COMMAND_OPTION_TYPE_BOOLEAN, "sysinit", "Tell boot daemon root filesystem is mounted read-write", PLY_COMMAND_OPTION_TYPE_BOOLEAN, "show-splash", "Show splash screen", PLY_COMMAND_OPTION_TYPE_BOOLEAN, @@ -111,6 +112,7 @@ main (int argc, ply_command_parser_get_options (command_parser, "help", &should_help, + "newroot", &chroot_dir, "quit", &should_quit, "sysinit", &should_sysinit, "show-splash", &should_show_splash, @@ -188,6 +190,12 @@ main (int argc, on_success, (ply_boot_client_response_handler_t) on_failure, loop); + else if (chroot_dir) + ply_boot_client_tell_daemon_to_change_root (client, chroot_dir, + (ply_boot_client_response_handler_t) + on_success, + (ply_boot_client_response_handler_t) + on_failure, loop); else return 1; @@ -103,15 +103,23 @@ on_ask_for_password (state_t *state, } static void -on_system_initialized (state_t *state) +on_newroot (state_t *state, + const char *root_dir) { - - ply_trace ("system now initialized, preparing for root filesystem switch"); - chdir("/sysroot"); + ply_trace ("new root mounted, switching to it"); + chdir(root_dir); chroot("."); } static void +on_system_initialized (state_t *state) +{ + ply_trace ("system now initialized, opening boot.log"); + ply_terminal_session_open_log (state->session, + "/var/log/boot.log"); +} + +static void on_show_splash (state_t *state) { ply_trace ("Showing splash screen"); @@ -133,9 +141,7 @@ on_show_splash (state_t *state) static void on_quit (state_t *state) { - ply_trace ("time to quit, writing boot.log"); - ply_terminal_session_open_log (state->session, - "/var/log/boot.log"); + ply_trace ("time to quit, closing boot.log"); ply_terminal_session_close_log (state->session); ply_trace ("hiding splash"); if (state->boot_splash != NULL) @@ -152,6 +158,7 @@ start_boot_server (state_t *state) server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update, (ply_boot_server_ask_for_password_handler_t) on_ask_for_password, (ply_boot_server_show_splash_handler_t) on_show_splash, + (ply_boot_server_newroot_handler_t) on_newroot, (ply_boot_server_system_initialized_handler_t) on_system_initialized, (ply_boot_server_quit_handler_t) on_quit, state); diff --git a/src/ply-boot-protocol.h b/src/ply-boot-protocol.h index 5814a47..de31699 100644 --- a/src/ply-boot-protocol.h +++ b/src/ply-boot-protocol.h @@ -29,6 +29,7 @@ #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT "Q" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD "*" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_SHOW_SPLASH "$" +#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_NEWROOT "R" #define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK "\x6" #define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK "\x15" #define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER "\x2" diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c index ec0f0ce..7b4cce1 100644 --- a/src/ply-boot-server.c +++ b/src/ply-boot-server.c @@ -50,6 +50,7 @@ struct _ply_boot_server int socket_fd; ply_boot_server_update_handler_t update_handler; + ply_boot_server_newroot_handler_t newroot_handler; ply_boot_server_system_initialized_handler_t system_initialized_handler; ply_boot_server_show_splash_handler_t show_splash_handler; ply_boot_server_ask_for_password_handler_t ask_for_password_handler; @@ -63,6 +64,7 @@ ply_boot_server_t * ply_boot_server_new (ply_boot_server_update_handler_t update_handler, ply_boot_server_ask_for_password_handler_t ask_for_password_handler, ply_boot_server_show_splash_handler_t show_splash_handler, + ply_boot_server_newroot_handler_t newroot_handler, ply_boot_server_system_initialized_handler_t initialized_handler, ply_boot_server_quit_handler_t quit_handler, void *user_data) @@ -272,6 +274,11 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) */ return; } + else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_NEWROOT) != 0) + { + if (server->newroot_handler != NULL) + server->newroot_handler(server->user_data, argument, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PING) != 0) { ply_error ("received unknown command '%s' from client", command); @@ -389,6 +396,12 @@ on_update (ply_event_loop_t *loop, } static void +on_newroot (ply_event_loop_t *loop) +{ + printf ("got newroot request\n"); +} + +static void on_system_initialized (ply_event_loop_t *loop) { printf ("got sysinit done request\n"); @@ -430,6 +443,7 @@ main (int argc, server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update, (ply_boot_server_ask_for_password_handler_t) on_ask_for_password, (ply_boot_server_show_splash_handler_t) on_show_splash, + (ply_boot_server_newroot_handler_t) on_newroot, (ply_boot_server_system_initialized_handler_t) on_system_initialized, (ply_boot_server_quit_handler_t) on_quit, loop); diff --git a/src/ply-boot-server.h b/src/ply-boot-server.h index a8eb7b2..d2e2418 100644 --- a/src/ply-boot-server.h +++ b/src/ply-boot-server.h @@ -36,6 +36,10 @@ typedef void (* ply_boot_server_update_handler_t) (void *user_data, const char *status, ply_boot_server_t *server); +typedef void (* ply_boot_server_newroot_handler_t) (void *user_data, + const char *root_dir, + ply_boot_server_t *server); + typedef void (* ply_boot_server_show_splash_handler_t) (void *user_data, ply_boot_server_t *server); @@ -56,6 +60,7 @@ typedef void (* ply_boot_server_quit_handler_t) (void *user_data, ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t update_handler, ply_boot_server_ask_for_password_handler_t ask_for_password_handler, ply_boot_server_show_splash_handler_t show_splash_handler, + ply_boot_server_newroot_handler_t newroot_handler, ply_boot_server_system_initialized_handler_t initialized_handler, ply_boot_server_quit_handler_t quit_handler, void *user_data); |