btrfs-progs: filesystem: use btrfs_open_dir for btrfs filesystem command
authorZhao Lei <zhaolei@cn.fujitsu.com>
Mon, 12 Oct 2015 13:22:55 +0000 (21:22 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 Nov 2015 08:35:00 +0000 (09:35 +0100)
commitd0c0f90b3885125c2c6e55eed097617a5f1baa15
tree8ab0c6357a1c4e7b248e0472b66c8a1830075562
parent2dfb710803e0ba9f02cb4950c3195b0f88f110ef
btrfs-progs: filesystem: use btrfs_open_dir for btrfs filesystem 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
kernel space of ioctl, and return fuzzy error message.

Before patch:
  # (/mnt/tmp is not btrfs mountpoint)
  #
  # btrfs filesystem df /mnt/tmp
  ERROR: couldn't get space info - Inappropriate ioctl for device
  ERROR: get_df failed Inappropriate ioctl for device
  #

After patch:
  # ./btrfs filesystem df /mnt/tmp
  ERROR: not btrfs filesystem: /mnt/tmp
  #

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-fi-usage.c
cmds-filesystem.c