]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #15910 from poettering/tmpfiles-pstore-tweak
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 26 May 2020 19:59:13 +0000 (21:59 +0200)
committerGitHub <noreply@github.com>
Tue, 26 May 2020 19:59:13 +0000 (21:59 +0200)
tmpfiles: let's make pstore sysfs failure silent

src/tmpfiles/tmpfiles.c
tmpfiles.d/systemd-pstore.conf

index a69411f1759f26f3254c1177b565dea169aa76f5..e827de1b06159c20f717bf8d8a5c355c86cea9e2 100644 (file)
@@ -1265,7 +1265,7 @@ static int path_set_attribute(Item *item, const char *path) {
 static int write_one_file(Item *i, const char *path) {
         _cleanup_close_ int fd = -1, dir_fd = -1;
         char *bn;
-        int flags, r;
+        int r;
 
         assert(i);
         assert(path);
@@ -1280,15 +1280,19 @@ static int write_one_file(Item *i, const char *path) {
 
         bn = basename(path);
 
-        flags = O_NONBLOCK|O_CLOEXEC|O_WRONLY|O_NOCTTY;
-
         /* Follows symlinks */
-        fd = openat(dir_fd, bn, i->append_or_force ? flags|O_APPEND : flags, i->mode);
+        fd = openat(dir_fd, bn,
+                    O_NONBLOCK|O_CLOEXEC|O_WRONLY|O_NOCTTY|(i->append_or_force ? O_APPEND : 0),
+                    i->mode);
         if (fd < 0) {
                 if (errno == ENOENT) {
                         log_debug_errno(errno, "Not writing missing file \"%s\": %m", path);
                         return 0;
                 }
+
+                if (i->allow_failure)
+                        return log_debug_errno(errno, "Failed to open file \"%s\", ignoring: %m", path);
+
                 return log_error_errno(errno, "Failed to open file \"%s\": %m", path);
         }
 
index cb600ec1eea353484783f68acfe77b77e53502d2..8b6a1dafc322709b4d022e6a2f7345240010375a 100644 (file)
@@ -25,5 +25,5 @@
 # These changes are automatically applied on future re-boots.
 
 d /var/lib/systemd/pstore 0755 root root 14d
-#w /sys/module/printk/parameters/always_kmsg_dump - - - - Y
-w /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y
+#w- /sys/module/printk/parameters/always_kmsg_dump - - - - Y
+w- /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y