[systemd-devel] [PATCH] create parents of RANDOM_SEED if they do not exist.

Gustavo Sverzut Barbieri barbieri at profusion.mobi
Mon Sep 20 06:04:10 PDT 2010


it may happen that parent directories of RANDOM_SEED do not exist, in
that case we must create it otherwise save will not work.
---
 src/random-seed.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/random-seed.c b/src/random-seed.c
index 936ed47..2b3a61f 100644
--- a/src/random-seed.c
+++ b/src/random-seed.c
@@ -61,6 +61,13 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
+        if (access(RANDOM_SEED, R_OK | W_OK) != 0) {
+                if (mkdir_parents(RANDOM_SEED, 0755) != 0) {
+                        log_error("Failed to create directories parents of %s: %m", RANDOM_SEED);
+                        goto finish;
+                }
+        }
+
         /* When we load the seed we read it and write it to the device
          * and then immediately update the saved seed with new data,
          * to make sure the next boot gets seeded differently. */
-- 
1.7.2.2



More information about the systemd-devel mailing list