]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: use ERRNO_IS_NOT_SUPPORTED() at two more places where we can't be sure of...
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Feb 2021 16:45:01 +0000 (17:45 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Mar 2021 04:16:22 +0000 (13:16 +0900)
src/basic/fs-util.c

index f46287d272859c30f82dde9cdaa4a19be2454b10..3a3daa9a05d8288c829807b27c039b2d4643b65a 100644 (file)
@@ -100,7 +100,7 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char
 
         /* renameat2() exists since Linux 3.15, btrfs and FAT added support for it later. If it is not implemented,
          * fall back to a different method. */
-        if (!IN_SET(errno, EINVAL, ENOSYS, ENOTTY))
+        if (!ERRNO_IS_NOT_SUPPORTED(errno) && errno != EINVAL)
                 return -errno;
 
         /* Let's try to use linkat()+unlinkat() as fallback. This doesn't work on directories and on some file systems
@@ -117,7 +117,7 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char
                 return 0;
         }
 
-        if (!IN_SET(errno, EINVAL, ENOSYS, ENOTTY, EPERM)) /* FAT returns EPERM on link()… */
+        if (!ERRNO_IS_NOT_SUPPORTED(errno) && !IN_SET(errno, EINVAL, EPERM)) /* FAT returns EPERM on link()… */
                 return -errno;
 
         /* OK, neither RENAME_NOREPLACE nor linkat()+unlinkat() worked. Let's then fall back to the racy TOCTOU