[PATCH 2/9] allow the progress cache file to be configurable

william.jon.mccann at gmail.com william.jon.mccann at gmail.com
Mon Feb 23 12:35:50 PST 2009


From: William Jon McCann <jmccann at redhat.com>

This will enable using separate cache files for different plymouth modes.
---
 src/Makefile.am           |    1 +
 src/libply/ply-progress.c |   20 ++++++++++----------
 src/libply/ply-progress.h |    4 ++--
 src/main.c                |   10 ++++++----
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 57c5a36..a905317 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,7 @@ INCLUDES = -I$(top_srcdir)                                                    \
            -I$(srcdir)                                                        \
            -DPLYMOUTH_LOG_DIRECTORY=\"$(localstatedir)/log\"                  \
            -DPLYMOUTH_SPOOL_DIRECTORY=\"$(localstatedir)/spool/plymouth\"     \
+           -DPLYMOUTH_TIME_DIRECTORY=\"$(localstatedir)/lib/plymouth/\"       \
            -DPLYMOUTH_LOGO_FILE=\"$(logofile)\"
 
 plymouthdbindir = $(plymouthdaemondir)
diff --git a/src/libply/ply-progress.c b/src/libply/ply-progress.c
index 9dca766..8dd1f10 100644
--- a/src/libply/ply-progress.c
+++ b/src/libply/ply-progress.c
@@ -46,8 +46,6 @@
 #define DEFAULT_BOOT_DURATION 60.0
 #endif
 
-#define BOOT_DURATION_FILE PLYMOUTH_TIME_DIRECTORY "/boot-duration"
-
 
 struct _ply_progress
 {
@@ -131,11 +129,12 @@ ply_progress_message_search_next (ply_list_t *message_list, double time)
 }
 
 void
-ply_progress_load_cache (ply_progress_t* progress)
+ply_progress_load_cache (ply_progress_t* progress,
+                         const char *filename)
 {
   FILE *fp;
-  
-  fp = fopen (BOOT_DURATION_FILE,"r"); 
+
+  fp = fopen (filename,"r");
   if (fp == NULL)
     return;
 
@@ -178,13 +177,14 @@ ply_progress_load_cache (ply_progress_t* progress)
 }
 
 void
-ply_progress_save_cache (ply_progress_t* progress)
+ply_progress_save_cache (ply_progress_t* progress,
+                         const char *filename)
 {
   FILE *fp;
   ply_list_node_t *node;
   double cur_time = ply_progress_get_time(progress);
-  
-  fp = fopen (BOOT_DURATION_FILE,"w");
+
+  fp = fopen (filename,"w");
   if (fp == NULL)
     return;
 
@@ -325,7 +325,7 @@ main (int    argc,
       printf("Time:%f   \t Percentage: %f%%\n", time, percent*100);
     }
   printf("Load cache\n");
-  ply_progress_load_cache (progress);
+  ply_progress_load_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
 
   for (i=0; i<10; i++)
     {
@@ -336,7 +336,7 @@ main (int    argc,
       printf("Time:%f   \t Percentage: %f%% \tScalar:%f\n", time, percent*100, progress->scalar);
     }
   printf("Save and free cache\n");
-  ply_progress_save_cache (progress);
+  ply_progress_save_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
   ply_progress_free(progress);
   return 0;
 }
diff --git a/src/libply/ply-progress.h b/src/libply/ply-progress.h
index 5e896db..f18c9b6 100644
--- a/src/libply/ply-progress.h
+++ b/src/libply/ply-progress.h
@@ -30,10 +30,10 @@ typedef struct _ply_progress ply_progress_t;
 ply_progress_t *ply_progress_new (void);
 ply_progress_t* ply_progress_new (void);
 void ply_progress_free (ply_progress_t* progress);
-void ply_progress_load_cache (ply_progress_t* progress);
+void ply_progress_load_cache (ply_progress_t* progress, const char *filename);
 double ply_progress_get_percentage (ply_progress_t* progress);
 double ply_progress_get_time (ply_progress_t* progress);
-void ply_progress_save_cache (ply_progress_t* progress);
+void ply_progress_save_cache (ply_progress_t* progress, const char *filename);
 void ply_progress_status_update (ply_progress_t* progress, const char  *status);
 
 #endif /* PLY_PROGRESS_H */
diff --git a/src/main.c b/src/main.c
index fa612ed..d08b268 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,6 +49,8 @@
 #define PLY_MAX_COMMAND_LINE_SIZE 512
 #endif
 
+#define BOOT_DURATION_FILE PLYMOUTH_TIME_DIRECTORY "/boot-duration"
+
 typedef struct 
 {
   const char    *keys;
@@ -243,7 +245,7 @@ on_newroot (state_t    *state,
   chdir(root_dir);
   chroot(".");
   chdir("/");
-  ply_progress_load_cache (state->progress);
+  ply_progress_load_cache (state->progress, BOOT_DURATION_FILE);
   if (state->boot_splash != NULL)
     ply_boot_splash_root_mounted (state->boot_splash);
 }
@@ -1130,13 +1132,13 @@ main (int    argc,
     }
 
   state.progress = ply_progress_new ();
-  ply_progress_load_cache (state.progress);
+  ply_progress_load_cache (state.progress, BOOT_DURATION_FILE);
   ply_trace ("entering event loop");
   exit_code = ply_event_loop_run (state.loop);
   ply_trace ("exited event loop");
 
-  ply_progress_save_cache (state.progress);
-  
+  ply_progress_save_cache (state.progress, BOOT_DURATION_FILE);
+
   ply_boot_splash_free (state.boot_splash);
   state.boot_splash = NULL;
 
-- 
1.6.1.3



More information about the plymouth mailing list