]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: don't second guess openat_report_new() return values
authorLennart Poettering <lennart@poettering.net>
Mon, 21 Oct 2024 20:40:52 +0000 (22:40 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Oct 2024 15:51:26 +0000 (17:51 +0200)
If openat_report_new() fails, then 'made_file' will be false, as no file
was created, hence there's no need to skip the unlinkat() explicitly
early, given that we check for 'made_file' anyway in the error path. The
extra error code checks are hence entirely redundant.

src/basic/fs-util.c

index 7ccd3f6750aebca256ff3e107336dde287116597..53206c3b374e206748aedead24e14d90483cfdf1 100644 (file)
@@ -1195,17 +1195,6 @@ int xopenat_full(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_
 
         fd = openat_report_new(dir_fd, path, open_flags, mode, &made_file);
         if (fd < 0) {
-                if (IN_SET(fd,
-                           /* We got ENOENT? then someone else immediately removed it after we
-                           * created it. In that case let's return immediately without unlinking
-                           * anything, because there simply isn't anything to unlink anymore. */
-                           -ENOENT,
-                           /* is a symlink? exists already → created by someone else, don't unlink */
-                           -ELOOP,
-                           /* not a directory? exists already → created by someone else, don't unlink */
-                           -ENOTDIR))
-                        return fd;
-
                 r = fd;
                 goto error;
         }