anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0206-tmpfiles-don-t-fail-if-we-cannot-create-a-subvolume-.patch

923a60
From e2550d725cf94c01dee40f5f02ad242ee8e02072 Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Fri, 15 May 2015 21:47:22 +0200
923a60
Subject: [PATCH] tmpfiles: don't fail if we cannot create a subvolume because
923a60
 a file system is read-only but a dir already exists anyway
923a60
923a60
https://bugs.freedesktop.org/show_bug.cgi?id=90281
923a60
(cherry picked from commit 7b135a73999b6911ebb85c053b6f7701fdac1883)
923a60
923a60
Cherry-picked from: 7b135a7
923a60
Resolves: #1222517
923a60
---
923a60
 src/tmpfiles/tmpfiles.c | 17 +++++++++++------
923a60
 1 file changed, 11 insertions(+), 6 deletions(-)
923a60
923a60
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
923a60
index 73a9c9d5b6..d0e6567d8a 100644
923a60
--- a/src/tmpfiles/tmpfiles.c
923a60
+++ b/src/tmpfiles/tmpfiles.c
923a60
@@ -1002,20 +1002,25 @@ static int create_item(Item *i) {
923a60
                                 r = mkdir_label(i->path, i->mode);
923a60
 
923a60
                 if (r < 0) {
923a60
-                        if (r != -EEXIST)
923a60
-                                return log_error_errno(r, "Failed to create directory or subvolume \"%s\": %m", i->path);
923a60
+                        int k;
923a60
 
923a60
-                        if (stat(i->path, &st) < 0)
923a60
-                                return log_error_errno(errno, "stat(%s) failed: %m", i->path);
923a60
+                        if (r != -EEXIST && r != -EROFS)
923a60
+                                return log_error_errno(r, "Failed to create directory or subvolume \"%s\": %m", i->path);
923a60
 
923a60
-                        if (!S_ISDIR(st.st_mode)) {
923a60
-                                log_debug("\"%s\" already exists and is not a directory.", i->path);
923a60
+                        k = is_dir(i->path, false);
923a60
+                        if (k == -ENOENT && r == -EROFS)
923a60
+                                return log_error_errno(r, "%s does not exist and cannot be created as the file system is read-only.", i->path);
923a60
+                        if (k < 0)
923a60
+                                return log_error_errno(k, "Failed to check if %s exists: %m", i->path);
923a60
+                        if (!k) {
923a60
+                                log_warning("\"%s\" already exists and is not a directory.", i->path);
923a60
                                 return 0;
923a60
                         }
923a60
 
923a60
                         creation = CREATION_EXISTING;
923a60
                 } else
923a60
                         creation = CREATION_NORMAL;
923a60
+
923a60
                 log_debug("%s directory \"%s\".", creation_mode_verb_to_string(creation), i->path);
923a60
 
923a60
                 r = path_set_perms(i, i->path);