]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
rm-rf: use faccessat instead of fstatat
authorLuca Boccassi <luca.boccassi@gmail.com>
Thu, 16 Jul 2026 18:20:57 +0000 (19:20 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 16 Jul 2026 18:20:57 +0000 (19:20 +0100)
Follow-up for 9dd2dab37e91ab4b000802d98aa7c4713836d53a

src/shared/rm-rf.c

index 56a56ed9ab5ec4a4c545e5743429cc51a38cf273..203e075b9a928a2f6601e2c1cc1a16fcee665650 100644 (file)
@@ -444,14 +444,8 @@ int rm_rf_at(int dir_fd, const char *path, RemoveFlags flags) {
         /* We refuse to clean the root file system with this call. This is extra paranoia to never cause a
          * really seriously broken system. */
         r = path_is_root_at(dir_fd, path);
-        if (r == -ENOENT) {
-                struct stat st;
-
-                if (fstatat(dir_fd, path, &st, AT_SYMLINK_NOFOLLOW) < 0)
-                        r = -errno;
-                else
-                        r = 0; /* The entry exists, but is most likely a dangling symlink. */
-        }
+        if (r == -ENOENT)
+                r = RET_NERRNO(faccessat(dir_fd, path, F_OK, AT_SYMLINK_NOFOLLOW));
         if (FLAGS_SET(flags, REMOVE_MISSING_OK) && r == -ENOENT)
                 return 0;
         if (r < 0)