From 14ac9851462c29f3f97355df5b4c3c9f1953c043 Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Mon, 12 Oct 2015 21:23:04 +0800 Subject: [PATCH] btrfs-progs: fragments: use btrfs_open_dir for btrfs-fragments command We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in deeper code, and return fuzzy error message. Before patch: ./btrfs-fragments -o 123 /mnt/tmp1 ERROR: can't perform the search After patch: # ./btrfs-fragments -o 123 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei Signed-off-by: David Sterba --- btrfs-fragments.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/btrfs-fragments.c b/btrfs-fragments.c index d742f605..17768c3f 100644 --- a/btrfs-fragments.c +++ b/btrfs-fragments.c @@ -436,11 +436,9 @@ int main(int argc, char **argv) path = argv[optind++]; - fd = open_file_or_dir(path, &dirstream); - if (fd < 0) { - fprintf(stderr, "ERROR: can't access '%s'\n", path); + fd = btrfs_open_dir(path, &dirstream, 1); + if (fd < 0) exit(1); - } if (flags == 0) flags = BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA;