Skip to content

Commit

Permalink
Merge pull request openSUSE#832 from kdave/libbttrfs-util-get-id
Browse files Browse the repository at this point in the history
Implement BtrfsUtils::get_id using libbtrfsutil
  • Loading branch information
aschnell authored Sep 5, 2023
2 parents 6ff34d5 + 3095304 commit b3d7b19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions snapper/Btrfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,13 @@ namespace snapper

try
{
#ifdef HAVE_LIBBTRFS
#if defined(HAVE_LIBBTRFS) || defined(HAVE_LIBBTRFSUTIL)
subvolid_t subvolid = get_id(openSnapshotDir(num).fd());
#endif

delete_subvolume(info_dir.fd(), "snapshot");

#ifdef HAVE_LIBBTRFS
#if defined(HAVE_LIBBTRFS) || defined(HAVE_LIBBTRFSUTIL)
deleted_subvolids.push_back(subvolid);
#endif

Expand Down
15 changes: 14 additions & 1 deletion snapper/BtrfsUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,20 @@ namespace snapper

#endif

#ifdef HAVE_LIBBTRFSUTIL
subvolid_t
get_id(int fd)
{
enum btrfs_util_error err;
subvolid_t id;

#ifdef HAVE_LIBBTRFS
err = btrfs_util_subvolume_id_fd(fd, &id);
if (err)
throw runtime_error_with_errno("btrfs_util_subvolume_id_fd() failed", errno);

return id;
}
#elif defined(HAVE_LIBBTRFS)
subvolid_t
get_id(int fd)
{
Expand All @@ -378,8 +389,10 @@ namespace snapper

return args.treeid;
}
#endif


#ifdef HAVE_LIBBTRFS
bool
does_subvolume_exist(int fd, subvolid_t subvolid)
{
Expand Down

0 comments on commit b3d7b19

Please sign in to comment.