[boot-splash] Add built-in plugin

There are times when plymouth is running that the filesystem isn't
accessible.  For instance, if a user has /usr as a separate partition,
then when first leaving the initrd, plymouth won't have access to its
plugins.

In those cases we really need to survive if the user hits escape.

This commit compiles details into the binary.  In this way, if the
plugins aren't available, we still have something to fall back to.
calculate-0.9.5
Ray Strode 14 years ago
parent 8f8a2c906e
commit 57108e50d1

@ -21,6 +21,7 @@ plymouthd_SOURCES = \
ply-boot-protocol.h \
ply-boot-server.h \
ply-boot-server.c \
plugins/splash/details/plugin.c \
main.c
plymouthdrundir = $(localstatedir)/run/plymouth

@ -335,6 +335,51 @@ ply_boot_splash_load (ply_boot_splash_t *splash)
return true;
}
bool
ply_boot_splash_load_built_in (ply_boot_splash_t *splash)
{
get_plugin_interface_function_t get_boot_splash_plugin_interface;
assert (splash != NULL);
splash->module_handle = ply_open_built_in_module ();
if (splash->module_handle == NULL)
return false;
get_boot_splash_plugin_interface = (get_plugin_interface_function_t)
ply_module_look_up_function (splash->module_handle,
"ply_boot_splash_plugin_get_interface");
if (get_boot_splash_plugin_interface == NULL)
{
ply_save_errno ();
ply_close_module (splash->module_handle);
splash->module_handle = NULL;
ply_restore_errno ();
return false;
}
splash->plugin_interface = get_boot_splash_plugin_interface ();
if (splash->plugin_interface == NULL)
{
ply_save_errno ();
ply_close_module (splash->module_handle);
splash->module_handle = NULL;
ply_restore_errno ();
return false;
}
splash->plugin = splash->plugin_interface->create_plugin (NULL);
assert (splash->plugin != NULL);
splash->is_loaded = true;
return true;
}
void
ply_boot_splash_unload (ply_boot_splash_t *splash)
{

@ -45,7 +45,9 @@ ply_boot_splash_t *ply_boot_splash_new (const char * theme_path,
const char * plugin_dir,
ply_buffer_t * boot_buffer,
ply_terminal_t *terminal);
bool ply_boot_splash_load (ply_boot_splash_t *splash);
bool ply_boot_splash_load_built_in (ply_boot_splash_t *splash);
void ply_boot_splash_unload (ply_boot_splash_t *splash);
void ply_boot_splash_set_keyboard (ply_boot_splash_t *splash,
ply_keyboard_t *keyboard);

@ -701,6 +701,24 @@ ply_open_module (const char *module_path)
return handle;
}
ply_module_handle_t *
ply_open_built_in_module (void)
{
ply_module_handle_t *handle;
handle = (ply_module_handle_t *) dlopen (NULL,
RTLD_NODELETE |RTLD_NOW | RTLD_LOCAL);
if (handle == NULL)
{
ply_trace("Could not load built-in module: %s\n", dlerror ());
if (errno == 0)
errno = ELIBACC;
}
return handle;
}
ply_module_function_t
ply_module_look_up_function (ply_module_handle_t *handle,
const char *function_name)

@ -90,6 +90,8 @@ bool ply_character_device_exists (const char *device);
void ply_list_directory (const char *dir);
ply_module_handle_t *ply_open_module (const char *module_path);
ply_module_handle_t *ply_open_built_in_module (void);
ply_module_function_t ply_module_look_up_function (ply_module_handle_t *handle,
const char *function_name);
void ply_close_module (ply_module_handle_t *handle);

@ -122,7 +122,8 @@ typedef struct
} state_t;
static ply_boot_splash_t *start_boot_splash (state_t *state,
const char *theme_path);
const char *theme_path,
bool fall_back_if_neccessary);
static void add_display_and_keyboard_for_terminal (state_t *state,
const char *tty_name);
@ -205,7 +206,8 @@ show_detailed_splash (state_t *state)
ply_trace ("Showing detailed splash screen");
state->boot_splash = start_boot_splash (state,
PLYMOUTH_THEME_PATH "details/details.plymouth");
PLYMOUTH_THEME_PATH "details/details.plymouth",
true);
if (state->boot_splash == NULL)
{
@ -345,7 +347,8 @@ show_default_splash (state_t *state)
{
ply_trace ("Trying override splash at '%s'", state->override_splash_path);
state->boot_splash = start_boot_splash (state,
state->override_splash_path);
state->override_splash_path,
false);
}
find_system_default_splash (state);
@ -354,7 +357,8 @@ show_default_splash (state_t *state)
{
ply_trace ("Trying system default splash");
state->boot_splash = start_boot_splash (state,
state->system_default_splash_path);
state->system_default_splash_path,
false);
}
find_distribution_default_splash (state);
@ -363,14 +367,16 @@ show_default_splash (state_t *state)
{
ply_trace ("Trying distribution default splash");
state->boot_splash = start_boot_splash (state,
state->distribution_default_splash_path);
state->distribution_default_splash_path,
false);
}
if (state->boot_splash == NULL)
{
ply_trace ("Trying old scheme for default splash");
state->boot_splash = start_boot_splash (state,
PLYMOUTH_THEME_PATH "default.plymouth");
PLYMOUTH_THEME_PATH "default.plymouth",
false);
}
if (state->boot_splash == NULL)
@ -378,7 +384,17 @@ show_default_splash (state_t *state)
ply_trace ("Could not start default splash screen,"
"showing text splash screen");
state->boot_splash = start_boot_splash (state,
PLYMOUTH_THEME_PATH "text/text.plymouth");
PLYMOUTH_THEME_PATH "text/text.plymouth",
false);
}
if (state->boot_splash == NULL)
{
ply_trace ("Could not start text splash screen,"
"showing built-in fallback");
state->boot_splash = start_boot_splash (state,
PLYMOUTH_THEME_PATH "text/text.plymouth",
true);
}
if (state->boot_splash == NULL)
@ -1470,10 +1486,12 @@ add_displays_and_keyboard_to_boot_splash (state_t *state,
static ply_boot_splash_t *
start_boot_splash (state_t *state,
const char *theme_path)
const char *theme_path,
bool fall_back_if_neccessary)
{
ply_boot_splash_t *splash;
ply_boot_splash_mode_t splash_mode;
bool is_loaded;
ply_trace ("Loading boot splash theme '%s'",
theme_path);
@ -1483,7 +1501,16 @@ start_boot_splash (state_t *state,
state->boot_buffer,
state->terminal);
if (!ply_boot_splash_load (splash))
is_loaded = ply_boot_splash_load (splash);
if (!is_loaded && fall_back_if_neccessary)
{
ply_trace ("Splash couldn't be loaded: %m");
ply_trace ("Loading built in splash");
is_loaded = ply_boot_splash_load_built_in (splash);
}
if (!is_loaded)
{
ply_save_errno ();
ply_boot_splash_free (splash);

Loading…
Cancel
Save