]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: Don't log about harmless errors when trying to lock file
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 6 Jun 2023 15:23:10 +0000 (17:23 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 20 Jun 2023 13:22:47 +0000 (15:22 +0200)
Let's make sure we don't log if the file is a symlink or does not
exist.

src/tmpfiles/tmpfiles.c

index 9469bbb4a3bfbf6c9ac5c6fe38fdc4760c71176e..eabac5632076fab460a51c7749528eb501526b21 100644 (file)
@@ -510,7 +510,9 @@ static DIR* xopendirat_nomod(int dirfd, const char *path) {
         if (dir)
                 return dir;
 
-        log_debug_errno(errno, "Cannot open %sdirectory \"%s\": %m", dirfd == AT_FDCWD ? "" : "sub", path);
+        if (!IN_SET(errno, ENOENT, ELOOP))
+                log_debug_errno(errno, "Cannot open %sdirectory \"%s\": %m", dirfd == AT_FDCWD ? "" : "sub", path);
+
         if (errno != EPERM)
                 return NULL;
 
@@ -805,7 +807,7 @@ static int dir_cleanup(
                                      O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME,
                                      /* xopen_flags = */ 0,
                                      /* mode = */ 0);
-                        if (fd < 0 && fd != -ENOENT)
+                        if (fd < 0 && !IN_SET(fd, -ENOENT, -ELOOP))
                                 log_warning_errno(fd, "Opening file \"%s\" failed, ignoring: %m", sub_path);
                         if (fd >= 0 && flock(fd, LOCK_EX|LOCK_NB) < 0 && errno == EAGAIN) {
                                 log_debug_errno(errno, "Couldn't acquire shared BSD lock on file \"%s\", skipping: %m", sub_path);