summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2023-07-14 10:00:00 +0200
committerDmitry V. Levin <ldv@strace.io>2023-07-28 14:28:35 +0200
commit08b8e9130e7fe7bf4149a3abc86b6b12e693721f (patch)
tree069147ed263e049d154f869c2e3741194a10c5a8 /src
parentrepart: cleanup use of ERRNO_IS_NOT_SUPPORTED() (diff)
downloadsystemd-08b8e9130e7fe7bf4149a3abc86b6b12e693721f.tar.xz
systemd-08b8e9130e7fe7bf4149a3abc86b6b12e693721f.zip
btrfs-util,tmpfiles: cleanup use of ERRNO_IS_NOT_SUPPORTED()
Given that ERRNO_IS_NOT_SUPPORTED() also matches positive values, make sure this macro is not called with arguments that do not have errno semantics. In this case the arguments passed to ERRNO_IS_NOT_SUPPORTED() are the values returned by btrfs_subvol_make_fd() which is not expected to return any positive values, but let's be consistent anyway and move ERRNO_IS_NOT_SUPPORTED() invocations to the branches where the return values are known to be negative.
Diffstat (limited to 'src')
-rw-r--r--src/shared/btrfs-util.c16
-rw-r--r--src/tmpfiles/tmpfiles.c2
2 files changed, 10 insertions, 8 deletions
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c
index 5128b308ab..cd340073cf 100644
--- a/src/shared/btrfs-util.c
+++ b/src/shared/btrfs-util.c
@@ -1565,14 +1565,16 @@ int btrfs_subvol_snapshot_at_full(
return -EISDIR;
r = btrfs_subvol_make_fd(new_fd, subvolume);
- if (ERRNO_IS_NOT_SUPPORTED(r) && (flags & BTRFS_SNAPSHOT_FALLBACK_DIRECTORY)) {
- /* If the destination doesn't support subvolumes, then use a plain directory, if that's requested. */
- if (mkdirat(new_fd, subvolume, 0755) < 0)
- return -errno;
+ if (r < 0) {
+ if (ERRNO_IS_NOT_SUPPORTED(r) && (flags & BTRFS_SNAPSHOT_FALLBACK_DIRECTORY)) {
+ /* If the destination doesn't support subvolumes, then use a plain directory, if that's requested. */
+ if (mkdirat(new_fd, subvolume, 0755) < 0)
+ return -errno;
- plain_directory = true;
- } else if (r < 0)
- return r;
+ plain_directory = true;
+ } else
+ return r;
+ }
if (FLAGS_SET(flags, BTRFS_SNAPSHOT_LOCK_BSD)) {
subvolume_fd = xopenat_lock(new_fd, subvolume,
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index a7de3c87fe..978d371268 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1883,7 +1883,7 @@ static int create_directory_or_subvolume(
} else
r = 0;
- if (!subvol || ERRNO_IS_NOT_SUPPORTED(r))
+ if (!subvol || (r < 0 && ERRNO_IS_NOT_SUPPORTED(r)))
WITH_UMASK(0000)
r = mkdirat_label(pfd, bn, mode);