]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[boot-splash] Add built-in plugin
authorRay Strode <rstrode@redhat.com>
Tue, 27 Jul 2010 22:30:13 +0000 (18:30 -0400)
committerRay Strode <rstrode@redhat.com>
Tue, 27 Jul 2010 22:46:03 +0000 (18:46 -0400)
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.

src/Makefile.am
src/libply-splash-core/ply-boot-splash.c
src/libply-splash-core/ply-boot-splash.h
src/libply/ply-utils.c
src/libply/ply-utils.h
src/main.c

index f0631ddd84c51462602fe91934faf6172b85c60f..67b71dacf4bbc3cdc17f99280fadba62614a5107 100644 (file)
@@ -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
index 0c77ef8fd7f1f377fc92674847737a5bee5e894a..3ebee98472a78f2911dd455e4f4077d1225e3009 100644 (file)
@@ -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)
 {
index d2c61a003727bfde1c4045b552257b7ea5697355..ee8cde49103c56d5afa8ae79824731fc625e1033 100644 (file)
@@ -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);
index 95e59181c00b587ecb74f33e26f3a47a9256401b..0d7bdd669808aecca82aebf3e7212292f70a8f4b 100644 (file)
@@ -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)
index 5d6e66d1f29512575a9aca253d036c0d1ee15dbb..2c4b3c73fa537aba32e650ba5697fc09ef1290f6 100644 (file)
@@ -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);
index 8cb81fd4f285680dadfd32530b7c69f087aab814..7840cfd7563ab20a34ae802c1bc0b6028581e3c6 100644 (file)
@@ -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);