[psplash,2/3] use /run for communication FIFO

Submitted by Stefan Agner on Feb. 25, 2019, 3:16 p.m. | Patch ID: 159062

Details

Message ID 20190225151619.2754-2-stefan@agner.ch
State New
Headers show

Commit Message

Stefan Agner Feb. 25, 2019, 3:16 p.m.
From: Stefan Agner <stefan.agner@toradex.com>

Use /run for communication FIFO which is typically preserved
between initramfs and regular root file system. Introduce a
new environment variable PSPLASH_FIFO_DIR which allows to
pass /tmp for the old behavior or another directory.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
---
 psplash-write.c | 10 +++++-----
 psplash.c       | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/psplash-write.c b/psplash-write.c
index 3fdba95..f0aeda1 100644
--- a/psplash-write.c
+++ b/psplash-write.c
@@ -29,13 +29,13 @@ 
 
 int main(int argc, char **argv) 
 {
-  char *tmpdir;
+  char *rundir;
   int   pipe_fd;
 
-  tmpdir = getenv("TMPDIR");
+  rundir = getenv("PSPLASH_FIFO_DIR");
 
-  if (!tmpdir)
-    tmpdir = "/tmp";
+  if (!rundir)
+    rundir = "/run";
 
   if (argc!=2) 
     {
@@ -43,7 +43,7 @@  int main(int argc, char **argv)
       exit(-1);
     }
   
-  chdir(tmpdir);
+  chdir(rundir);
   
   if ((pipe_fd = open (PSPLASH_FIFO,O_WRONLY|O_NONBLOCK)) == -1)
     {
diff --git a/psplash.c b/psplash.c
index 992e199..169f9c1 100644
--- a/psplash.c
+++ b/psplash.c
@@ -204,7 +204,7 @@  psplash_main (PSplashFB *fb, int pipe_fd, int timeout)
 int 
 main (int argc, char** argv) 
 {
-  char      *tmpdir;
+  char      *rundir;
   int        pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0;
   PSplashFB *fb;
   bool       disable_console_switch = FALSE;
@@ -241,12 +241,12 @@  main (int argc, char** argv)
       exit(-1);
   }
 
-  tmpdir = getenv("TMPDIR");
+  rundir = getenv("PSPLASH_FIFO_DIR");
 
-  if (!tmpdir)
-    tmpdir = "/tmp";
+  if (!rundir)
+    rundir = "/run";
 
-  chdir(tmpdir);
+  chdir(rundir);
 
   if (mkfifo(PSPLASH_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
     {