From ec7251486ddf509ee1c73a75e6468d8a36f9a049 Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Thu, 25 Jan 2018 01:35:27 -0800 Subject: btrfs-progs: use libbtrfsutil for sync ioctls Signed-off-by: Omar Sandoval Signed-off-by: David Sterba --- cmds-filesystem.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'cmds-filesystem.c') diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 467aff11..225df421 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -28,6 +28,8 @@ #include #include +#include + #include "kerncompat.h" #include "ctree.h" #include "utils.h" @@ -813,25 +815,16 @@ static const char * const cmd_filesystem_sync_usage[] = { static int cmd_filesystem_sync(int argc, char **argv) { - int fd, res; - char *path; - DIR *dirstream = NULL; + enum btrfs_util_error err; clean_args_no_options(argc, argv, cmd_filesystem_sync_usage); if (check_argc_exact(argc - optind, 1)) usage(cmd_filesystem_sync_usage); - path = argv[optind]; - - fd = btrfs_open_dir(path, &dirstream, 1); - if (fd < 0) - return 1; - - res = ioctl(fd, BTRFS_IOC_SYNC); - close_file_or_dir(fd, dirstream); - if( res < 0 ){ - error("sync ioctl failed on '%s': %m", path); + err = btrfs_util_sync(argv[optind]); + if (err) { + error_btrfs_util(err); return 1; } -- cgit v1.2.3