diff options
author | Omar Sandoval <osandov@fb.com> | 2018-01-25 01:35:27 -0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-03-06 11:28:37 +0100 |
commit | ec7251486ddf509ee1c73a75e6468d8a36f9a049 (patch) | |
tree | c8a9b749fc3f817d0f534a85a5a72ed8e877ab57 /cmds-filesystem.c | |
parent | 3e76e9b67610e179bac4688c76002ff1adb338d4 (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-filesystem.c')
-rw-r--r-- | cmds-filesystem.c | 19 |
1 files changed, 6 insertions, 13 deletions
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 <linux/limits.h> #include <getopt.h> +#include <btrfsutil.h> + #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; } |