From 28ba7e36d0b6b3f5b9dc4922d689fd8c27303b61 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 26 Feb 2021 15:00:29 +0100 Subject: [PATCH] btrfs-util: expose COPY_SIGTERM for btrfs_snapshot() too --- src/shared/btrfs-util.c | 13 ++++++++++--- src/shared/btrfs-util.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index f4e291385be..00a6a37ff70 100644 --- a/src/shared/btrfs-util.c +++ b/src/shared/btrfs-util.c @@ -1613,7 +1613,7 @@ int btrfs_subvol_snapshot_fd_full( return -EISDIR; r = btrfs_subvol_make(new_path); - if (r == -ENOTTY && (flags & BTRFS_SNAPSHOT_FALLBACK_DIRECTORY)) { + 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 (mkdir(new_path, 0755) < 0) return -errno; @@ -1624,8 +1624,15 @@ int btrfs_subvol_snapshot_fd_full( r = copy_directory_fd_full( old_fd, new_path, - COPY_MERGE|COPY_REFLINK|COPY_SAME_MOUNT|COPY_HARDLINKS|(FLAGS_SET(flags, BTRFS_SNAPSHOT_SIGINT) ? COPY_SIGINT : 0), - progress_path, progress_bytes, userdata); + COPY_MERGE_EMPTY| + COPY_REFLINK| + COPY_SAME_MOUNT| + COPY_HARDLINKS| + (FLAGS_SET(flags, BTRFS_SNAPSHOT_SIGINT) ? COPY_SIGINT : 0)| + (FLAGS_SET(flags, BTRFS_SNAPSHOT_SIGTERM) ? COPY_SIGTERM : 0), + progress_path, + progress_bytes, + userdata); if (r < 0) goto fallback_fail; diff --git a/src/shared/btrfs-util.h b/src/shared/btrfs-util.h index 7b18f57719a..b67a4c10fe8 100644 --- a/src/shared/btrfs-util.h +++ b/src/shared/btrfs-util.h @@ -35,6 +35,7 @@ typedef enum BtrfsSnapshotFlags { BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 1 << 4, /* If the destination doesn't support subvolumes, reflink/copy instead */ BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 1 << 5, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */ BTRFS_SNAPSHOT_SIGINT = 1 << 6, /* Check for SIGINT regularly, and return EINTR if seen */ + BTRFS_SNAPSHOT_SIGTERM = 1 << 7, /* Ditto, but for SIGTERM */ } BtrfsSnapshotFlags; typedef enum BtrfsRemoveFlags { -- 2.47.3