]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: try to set file attributes one by one 17693/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 23 Nov 2020 06:49:51 +0000 (15:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 18 Dec 2020 03:35:57 +0000 (12:35 +0900)
Closes #17690.

src/tmpfiles/tmpfiles.c

index 9906c70eefb70ce2c241c645ab861f6ec486b49c..2bbacf0ccf22ce00761ffb410ffb74af9b870a26 100644 (file)
@@ -1308,11 +1308,15 @@ static int fd_set_attribute(Item *item, int fd, const char *path, const struct s
         if (procfs_fd < 0)
                 return log_error_errno(procfs_fd, "Failed to re-open '%s': %m", path);
 
-        r = chattr_fd(procfs_fd, f, item->attribute_mask, NULL);
-        if (r < 0)
-                log_full_errno(IN_SET(r, -ENOTTY, -EOPNOTSUPP) ? LOG_DEBUG : LOG_WARNING,
-                               r,
-                               "Cannot set file attribute for '%s', value=0x%08x, mask=0x%08x, ignoring: %m",
+        unsigned previous, current;
+        r = chattr_full(NULL, procfs_fd, f, item->attribute_mask, &previous, &current, true);
+        if (r == -ENOANO)
+                log_warning("Cannot set file attributes for '%s', maybe due to incompatiblity in specified attributes, "
+                            "previous=0x%08x, current=0x%08x, expected=0x%08x, ignoring.",
+                            path, previous, current, (previous & ~item->attribute_mask) | (f & item->attribute_mask));
+        else if (r < 0)
+                log_full_errno(ERRNO_IS_NOT_SUPPORTED(r) ? LOG_DEBUG : LOG_WARNING, r,
+                               "Cannot set file attributes for '%s', value=0x%08x, mask=0x%08x, ignoring: %m",
                                path, item->attribute_value, item->attribute_mask);
 
         return 0;