summaryrefslogtreecommitdiff
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2018-01-25 01:35:27 -0800
committerDavid Sterba <dsterba@suse.com>2018-03-06 11:28:37 +0100
commitec7251486ddf509ee1c73a75e6468d8a36f9a049 (patch)
treec8a9b749fc3f817d0f534a85a5a72ed8e877ab57 /cmds-subvolume.c
parent3e76e9b67610e179bac4688c76002ff1adb338d4 (diff)
btrfs-progs: use libbtrfsutil for sync ioctls
Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 8a473f7..e5dcdea 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -28,6 +28,8 @@
#include <uuid/uuid.h>
#include <linux/magic.h>
+#include <btrfsutil.h>
+
#include "kerncompat.h"
#include "ioctl.h"
#include "qgroup.h"
@@ -226,12 +228,18 @@ out:
static int wait_for_commit(int fd)
{
- int ret;
+ enum btrfs_util_error err;
+ uint64_t transid;
- ret = ioctl(fd, BTRFS_IOC_START_SYNC, NULL);
- if (ret < 0)
- return ret;
- return ioctl(fd, BTRFS_IOC_WAIT_SYNC, NULL);
+ err = btrfs_util_start_sync_fd(fd, &transid);
+ if (err)
+ return -1;
+
+ err = btrfs_util_wait_sync_fd(fd, transid);
+ if (err)
+ return -1;
+
+ return 0;
}
static const char * const cmd_subvol_delete_usage[] = {
@@ -932,6 +940,7 @@ static int cmd_subvol_find_new(int argc, char **argv)
char *subvol;
u64 last_gen;
DIR *dirstream = NULL;
+ enum btrfs_util_error err;
clean_args_no_options(argc, argv, cmd_subvol_find_new_usage);
@@ -955,9 +964,9 @@ static int cmd_subvol_find_new(int argc, char **argv)
if (fd < 0)
return 1;
- ret = ioctl(fd, BTRFS_IOC_SYNC);
- if (ret < 0) {
- error("sync ioctl failed on '%s': %m", subvol);
+ err = btrfs_util_sync_fd(fd);
+ if (err) {
+ error_btrfs_util(err);
close_file_or_dir(fd, dirstream);
return 1;
}