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