From: Arvin Schnell Date: Thu, 27 Aug 2015 12:27:33 +0000 (+0200) Subject: - disable functions if libbtrfs is missing X-Git-Tag: v0.3.3~62^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=refs%2Fpull%2F191%2Fhead;p=thirdparty%2Fsnapper.git - disable functions if libbtrfs is missing --- diff --git a/snapper/Btrfs.cc b/snapper/Btrfs.cc index bf5560ed..193c52ac 100644 --- a/snapper/Btrfs.cc +++ b/snapper/Btrfs.cc @@ -352,11 +352,15 @@ namespace snapper try { +#ifdef HAVE_LIBBTRFS subvolid_t subvolid = get_id(openSnapshotDir(num).fd()); +#endif delete_subvolume(info_dir.fd(), "snapshot"); +#ifdef HAVE_LIBBTRFS deleted_subvolids.push_back(subvolid); +#endif } catch (const runtime_error& e) { @@ -1404,8 +1408,10 @@ namespace snapper { for (subvolid_t subvolid : deleted_subvolids) { +#ifdef HAVE_LIBBTRFS while (!does_subvolume_exist(subvolume_dir.fd(), subvolid)) sleep(1); +#endif } deleted_subvolids.clear(); diff --git a/snapper/BtrfsUtils.cc b/snapper/BtrfsUtils.cc index b89553fb..bf737fb1 100644 --- a/snapper/BtrfsUtils.cc +++ b/snapper/BtrfsUtils.cc @@ -51,6 +51,7 @@ #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2) +#define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8) struct btrfs_ioctl_vol_args { @@ -232,6 +233,8 @@ namespace snapper #endif +#ifdef HAVE_LIBBTRFS + subvolid_t get_id(int fd) { @@ -246,6 +249,8 @@ namespace snapper return args.treeid; } +#endif + qgroup_t make_qgroup(uint64_t level, subvolid_t id) @@ -277,6 +282,8 @@ namespace snapper } +#ifdef HAVE_LIBBTRFS + bool does_subvolume_exist(int fd, subvolid_t subvolid) { @@ -300,6 +307,8 @@ namespace snapper return sk->nr_items == 0; } +#endif + void sync(int fd)