[psplash,2/2] Add config option to disable fifo

Submitted by Philipp Schrader on May 14, 2019, 12:23 a.m. | Patch ID: 161275

Details

Message ID 1557793380-10881-2-git-send-email-philipp@peloton-tech.com
State New
Headers show

Commit Message

Philipp Schrader May 14, 2019, 12:23 a.m.
I have a use case where I want psplash to write its image to the frame
buffer without supporting a progress bar. That means a single write
into the framebuffer. Then it's done.

This patch adds a PSPLASH_ENABLE_CLIENT config option which defaults
to 1 (i.e. true). This keeps the default behaviour the same before and
after this patch. If a user decides to toggle the option then psplash
will not create a fifo in /tmp to listen for messages from
psplash-write. Since psplash won't ever get messages from the client
there is no point in displaying a progress bar either.  The effect is
that psplash will write the image to the framebuffer without a
progress bar and then exit.

Signed-off-by: Philipp Schrader <philipp@peloton-tech.com>
---
 psplash-config.h | 5 +++++
 psplash.c        | 8 ++++++++
 2 files changed, 13 insertions(+)

Patch hide | download patch | download mbox

diff --git a/psplash-config.h b/psplash-config.h
index 82bb76d..ce8645f 100644
--- a/psplash-config.h
+++ b/psplash-config.h
@@ -31,4 +31,9 @@ 
 /* Position of the image split from top edge, denominator of fraction */
 #define PSPLASH_IMG_SPLIT_DENOMINATOR 6
 
+/* A flag to determine whether psplash listens to psplash-write client.
+ * If disabled, psplash will exit when it's done writing the image into the
+ * framebuffer. The progress bar is also disabled. */
+#define PSPLASH_ENABLE_CLIENT 1
+
 #endif
diff --git a/psplash.c b/psplash.c
index 166db73..64121eb 100644
--- a/psplash.c
+++ b/psplash.c
@@ -256,6 +256,7 @@  main (int argc, char** argv)
 
   chdir(tmpdir);
 
+#if PSPLASH_ENABLE_CLIENT
   if (mkfifo(PSPLASH_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
     {
       if (errno!=EEXIST) 
@@ -272,6 +273,7 @@  main (int argc, char** argv)
       perror("pipe open");
       exit(-2);
     }
+#endif
 
   if (!disable_console_switch)
     psplash_console_switch ();
@@ -301,6 +303,7 @@  main (int argc, char** argv)
 			 POKY_IMG_ROWSTRIDE,
 			 POKY_IMG_RLE_PIXEL_DATA);
 
+#if PSPLASH_ENABLE_CLIENT
   /* Draw progress bar border */
   psplash_fb_draw_image (fb, 
 			 (fb->width  - BAR_IMG_WIDTH)/2, 
@@ -312,18 +315,23 @@  main (int argc, char** argv)
 			 BAR_IMG_RLE_PIXEL_DATA);
 
   psplash_draw_progress (fb, 0);
+#endif
 
 #ifdef PSPLASH_STARTUP_MSG
   psplash_draw_msg (fb, PSPLASH_STARTUP_MSG);
 #endif
 
+#if PSPLASH_ENABLE_CLIENT
   psplash_main (fb, pipe_fd, 0);
 
 
   psplash_fb_destroy (fb);
+#endif
 
  fb_fail:
+#if PSPLASH_ENABLE_CLIENT
   unlink(PSPLASH_FIFO);
+#endif
 
   if (!disable_console_switch)
     psplash_console_reset ();