187
on_change_mode (state_t *state,
190
if (state->boot_splash == NULL)
192
ply_trace ("no splash set");
196
ply_trace ("updating mode to '%s'", mode);
197
if (strcmp (mode, "boot-up") == 0)
198
state->mode = PLY_BOOT_SPLASH_MODE_BOOT_UP;
199
else if (strcmp (mode, "shutdown") == 0)
200
state->mode = PLY_BOOT_SPLASH_MODE_SHUTDOWN;
201
else if (strcmp (mode, "updates") == 0)
202
state->mode = PLY_BOOT_SPLASH_MODE_UPDATES;
206
if (!ply_boot_splash_show (state->boot_splash, state->mode))
208
ply_trace ("failed to update splash");
214
on_system_update (state_t *state,
217
if (state->boot_splash == NULL)
219
ply_trace ("no splash set");
223
ply_trace ("setting system update to '%i'", progress);
224
if (!ply_boot_splash_system_update (state->boot_splash, progress))
226
ply_trace ("failed to update splash");
186
232
flush_pending_messages (state_t *state)
188
234
ply_list_node_t *node = ply_list_get_first_node (state->pending_messages);
475
521
on_display_message (state_t *state,
476
522
const char *message)
478
ply_trace ("displaying message %s", message);
479
524
if (state->boot_splash != NULL)
480
ply_boot_splash_display_message (state->boot_splash, message);
526
ply_trace ("displaying message %s", message);
527
ply_boot_splash_display_message (state->boot_splash, message);
482
ply_list_append_data (state->messages, strdup(message));
531
ply_trace ("not displaying message %s as no splash", message);
532
ply_list_append_data (state->messages, strdup(message));
1244
1300
ply_boot_server_t *server;
1246
1302
server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update,
1303
(ply_boot_server_change_mode_handler_t) on_change_mode,
1304
(ply_boot_server_system_update_handler_t) on_system_update,
1247
1305
(ply_boot_server_ask_for_password_handler_t) on_ask_for_password,
1248
1306
(ply_boot_server_ask_question_handler_t) on_ask_question,
1249
1307
(ply_boot_server_display_message_handler_t) on_display_message,
1529
1587
state->local_console_terminal = ply_terminal_new (state->default_tty);
1531
/* force frame-buffer plugin for shutdown so it sticks around after getting killed */
1532
if (state->mode == PLY_MODE_SHUTDOWN)
1533
renderer = ply_renderer_new (PLYMOUTH_PLUGIN_PATH "renderers/frame-buffer.so", NULL, state->local_console_terminal);
1535
renderer = ply_renderer_new (NULL, NULL, state->local_console_terminal);
1589
renderer = ply_renderer_new (NULL, NULL, state->local_console_terminal);
1537
1591
if (!ply_renderer_open (renderer))
1834
1888
if (stream != NULL)
1838
stream = strdup (stream);
1839
end = stream + strcspn (stream, " \n");
1893
stream_copy = strdup (stream);
1894
end = stream_copy + strcspn (stream_copy, " \n");
1842
ply_trace ("streaming debug output to %s instead of screen", stream);
1843
fd = open (stream, O_RDWR | O_NOCTTY | O_CREAT, 0600);
1897
ply_trace ("streaming debug output to %s instead of screen", stream_copy);
1898
fd = open (stream_copy, O_RDWR | O_NOCTTY | O_CREAT, 0600);
1847
ply_trace ("could not stream output to %s: %m", stream);
1902
ply_trace ("could not stream output to %s: %m", stream_copy);
1851
1906
ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
1902
1957
add_display_and_keyboard_for_terminal (state, terminal);
1906
1961
add_consoles_from_file (state_t *state,
1907
1962
ply_hashtable_t *consoles,
1908
1963
const char *path)
1911
1966
char contents[512] = "";
1912
const char *remaining_command_line;
1967
ssize_t contents_length;
1969
const char *remaining_file_contents;
1915
1971
ply_trace ("opening %s", path);
1916
1972
fd = open (path, O_RDONLY);
1920
1976
ply_trace ("couldn't open it: %m");
1924
1980
ply_trace ("reading file");
1925
if (read (fd, contents, sizeof (contents)))
1981
contents_length = read (fd, contents, sizeof (contents));
1983
if (contents_length <= 0)
1927
1985
ply_trace ("couldn't read it: %m");
1933
remaining_command_line = contents;
1991
remaining_file_contents = contents;
1936
while (remaining_command_line != '\0')
1994
while (remaining_file_contents < contents + contents_length)
1939
1997
size_t console_length;
1940
1998
char *console_device;
1942
state->should_force_details = true;
1944
console = strdup (remaining_command_line);
1946
end = strpbrk (console, " \n\t\v");
1951
console_length = strlen (console);
2000
/* Advance past any leading whitespace */
2001
remaining_file_contents += strspn (remaining_file_contents, " \n\t\v");
2003
if (*remaining_file_contents == '\0')
2005
/* There's nothing left after the whitespace, we're done */
2009
/* Find trailing whitespace and NUL terminate. If strcspn
2010
* doesn't find whitespace, it gives us the length of the string
2011
* until the next NUL byte, which we'll just overwrite with
2012
* another NUL byte anyway. */
2013
console_length = strcspn (remaining_file_contents, " \n\t\v");
2014
console = strndup (remaining_file_contents, console_length);
2016
/* If this console is anything besides tty0, then the user is sort
2017
* of a weird case (uses a serial console or whatever) and they
2018
* most likely don't want a graphical splash, so force details.
2020
if (strcmp (console, "tty0") != 0)
2021
state->should_force_details = true;
1953
2023
asprintf (&console_device, "/dev/%s", console);
1954
2025
free (console);
1957
2027
ply_trace ("console %s found!", console_device);
1958
2028
ply_hashtable_insert (consoles, console_device, console_device);
1959
remaining_command_line += console_length;
2031
/* Move past the parsed console string, and the whitespace we
2032
* may have found above. If we found a NUL above and not whitespace,
2033
* then we're going to jump past the end of the buffer and the loop
2036
remaining_file_contents += console_length + 1;
2039
return num_consoles;
1966
2043
add_consoles_from_kernel_command_line (state_t *state,
1967
2044
ply_hashtable_t *consoles)
1969
2046
const char *console_string;
1970
2047
const char *remaining_command_line;
1973
2051
remaining_command_line = state->kernel_command_line;
1975
2054
console = NULL;
1976
2055
while ((console_string = command_line_get_string_after_prefix (remaining_command_line,
1977
2056
"console=")) != NULL)
2020
2102
ply_hashtable_t *consoles;
2104
bool ignore_serial_consoles;
2022
2106
ply_trace ("checking for consoles%s",
2023
2107
should_add_displays? " and adding displays": "");
2025
2109
consoles = ply_hashtable_new (ply_hashtable_string_hash,
2026
2110
ply_hashtable_string_compare);
2028
if (!add_consoles_from_file (state,
2030
"/sys/class/tty/console/active"))
2032
ply_trace ("falling back to kernel command line");
2033
add_consoles_from_kernel_command_line (state, consoles);
2111
ignore_serial_consoles = command_line_has_argument (state->kernel_command_line, "plymouth.ignore-serial-consoles");
2115
if (!ignore_serial_consoles)
2117
num_consoles = add_consoles_from_file (state, consoles, "/sys/class/tty/console/active");
2119
if (num_consoles == 0)
2121
ply_trace ("falling back to kernel command line");
2122
num_consoles = add_consoles_from_kernel_command_line (state, consoles);
2127
ply_trace ("ignoring all consoles but default console because of plymouth.ignore-serial-consoles");
2036
2130
console = ply_hashtable_remove (consoles, (void *) "/dev/tty0");
2037
2131
if (console != NULL)
2039
2133
free (console);
2040
ply_hashtable_insert (consoles, (void *) default_tty, (char *) default_tty);
2134
console = strdup (default_tty);
2135
ply_hashtable_insert (consoles, console, console);
2043
2138
console = ply_hashtable_remove (consoles, (void *) "/dev/tty");
2044
2139
if (console != NULL)
2046
2141
free (console);
2047
ply_hashtable_insert (consoles, (void *) default_tty, (void *) default_tty);
2142
console = strdup (default_tty);
2143
ply_hashtable_insert (consoles, console, console);
2050
2146
free (state->kernel_console_tty);
2056
2152
if (should_add_displays)
2058
ply_hashtable_foreach (consoles,
2059
(ply_hashtable_foreach_func_t *)
2060
add_display_and_keyboard_for_console,
2154
/* Do a full graphical splash if there's no weird serial console
2155
* stuff going on, otherwise just prepare text splashes
2157
if ((num_consoles == 0) ||
2158
((num_consoles == 1) &&
2159
(ply_hashtable_lookup (consoles, (void *) default_tty) != NULL)))
2160
add_default_displays_and_keyboard (state);
2162
ply_hashtable_foreach (consoles,
2163
(ply_hashtable_foreach_func_t *)
2164
add_display_and_keyboard_for_console,
2064
2168
ply_hashtable_foreach (consoles, (ply_hashtable_foreach_func_t *) free, NULL);
2400
2504
return EX_OSERR;
2507
/* Make the first byte in argv be '@' so that we can survive systemd's killing
2508
* spree when going from initrd to /, and so we stay alive all the way until
2509
* the power is killed at shutdown.
2510
* http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
2514
state.boot_server = start_boot_server (&state);
2516
if (state.boot_server == NULL)
2518
ply_trace ("plymouthd is already running");
2520
if (daemon_handle != NULL)
2521
ply_detach_daemon (daemon_handle, EX_OK);
2403
2525
state.boot_buffer = ply_buffer_new ();
2405
2527
if (attach_to_session)
2417
state.boot_server = start_boot_server (&state);
2419
if (state.boot_server == NULL)
2421
ply_trace ("could not log bootup: %m");
2423
detach_from_running_session (&state);
2425
if (daemon_handle != NULL)
2426
ply_detach_daemon (daemon_handle, EX_UNAVAILABLE);
2427
return EX_UNAVAILABLE;
2430
2539
state.progress = ply_progress_new ();
2432
2541
ply_progress_load_cache (state.progress,