ff6046
From 81df5f597257bd2579246de6182c4949b27396eb Mon Sep 17 00:00:00 2001
ff6046
From: Michal Sekletar <msekleta@redhat.com>
ff6046
Date: Tue, 4 Sep 2018 19:51:14 +0200
ff6046
Subject: [PATCH] cryptsetup-generator: don't return error if target directory
ff6046
 already exists
ff6046
ff6046
(cherry-picked from commit 579875bc4a59b917fa32519e3d96d56dc591ad1e)
ff6046
ff6046
Related: #1656869
ff6046
---
ff6046
 src/cryptsetup/cryptsetup-generator.c | 8 ++++----
ff6046
 1 file changed, 4 insertions(+), 4 deletions(-)
ff6046
ff6046
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
ff6046
index 52391bd185..03c513c26e 100644
ff6046
--- a/src/cryptsetup/cryptsetup-generator.c
ff6046
+++ b/src/cryptsetup/cryptsetup-generator.c
ff6046
@@ -53,16 +53,16 @@ static int generate_keydev_mount(const char *name, const char *keydev, char **un
ff6046
                 return r;
ff6046
 
ff6046
         r = mkdir("/run/systemd/cryptsetup", 0700);
ff6046
-        if (r < 0)
ff6046
-                return r;
ff6046
+        if (r < 0 && errno != EEXIST)
ff6046
+                return -errno;
ff6046
 
ff6046
         where = strjoin("/run/systemd/cryptsetup/keydev-", name);
ff6046
         if (!where)
ff6046
                 return -ENOMEM;
ff6046
 
ff6046
         r = mkdir(where, 0700);
ff6046
-        if (r < 0)
ff6046
-                return r;
ff6046
+        if (r < 0 && errno != EEXIST)
ff6046
+                return -errno;
ff6046
 
ff6046
         r = unit_name_from_path(where, ".mount", &u);
ff6046
         if (r < 0)