From 5b7e47952f7a3351eab18a9847122f54c3d00b85 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Fri, 13 Jan 2023 09:16:48 +0100 Subject: [PATCH] - fixed fallback to BTRFS_IOC_SNAP_CREATE --- snapper/BtrfsUtils.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/snapper/BtrfsUtils.cc b/snapper/BtrfsUtils.cc index 5bcd940a..4a1a28da 100644 --- a/snapper/BtrfsUtils.cc +++ b/snapper/BtrfsUtils.cc @@ -37,6 +37,9 @@ #else #include #endif +#ifdef HAVE_LIBBTRFSUTIL +#include +#endif #include #include @@ -44,9 +47,6 @@ #include "snapper/AppUtil.h" #include "snapper/BtrfsUtils.h" -#ifdef HAVE_LIBBTRFSUTIL -#include -#endif namespace snapper { @@ -114,7 +114,6 @@ namespace snapper create_snapshot(int fd, int fddst, const string& name, bool read_only, qgroup_t qgroup) { #ifdef HAVE_LIBBTRFSUTIL - enum btrfs_util_error err; struct btrfs_util_qgroup_inherit *util_inherit = NULL; int flags = 0; @@ -137,8 +136,11 @@ namespace snapper util_inherit = (struct btrfs_util_qgroup_inherit *)inherit; } #endif - err = btrfs_util_create_snapshot_fd2(fd, fddst, name.c_str(), flags, NULL, util_inherit); - if (err && errno != ENOTTY && errno != EINVAL) + enum btrfs_util_error err = btrfs_util_create_snapshot_fd2(fd, fddst, name.c_str(), flags, NULL, + util_inherit); + if (!err) + return; + else if (errno != ENOTTY && errno != EINVAL) throw runtime_error_with_errno("btrfs_util_create_snapshot_fd2() failed", errno); /* No BTRFS_IOC_SNAP_CREATE fallback */ @@ -176,6 +178,8 @@ namespace snapper else if (errno != ENOTTY && errno != EINVAL) throw runtime_error_with_errno("ioctl(BTRFS_IOC_SNAP_CREATE_V2) failed", errno); +#endif + struct btrfs_ioctl_vol_args args; memset(&args, 0, sizeof(args)); @@ -184,7 +188,6 @@ namespace snapper if (ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args) < 0) throw runtime_error_with_errno("ioctl(BTRFS_IOC_SNAP_CREATE) failed", errno); -#endif } -- 2.47.3