btrfs-progs: qgroup: use btrfs_open_dir for btrfs qgroup command
authorZhao Lei <zhaolei@cn.fujitsu.com>
Mon, 12 Oct 2015 13:23:00 +0000 (21:23 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 Nov 2015 08:35:01 +0000 (09:35 +0100)
commitbbbe7fd7d0f2f104c4c1c54e38524a6496cc9ab6
treedb8fad0541f354f5891d8efdc8febb845fa61cef
parent7c2bad665e4f4229a40a4ec234b7a1c6383ee5c3
btrfs-progs: qgroup: use btrfs_open_dir for btrfs qgroup 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:
  # ./btrfs qgroup create 1/5  /mnt/tmp1
  ERROR: unable to create quota group: Inappropriate ioctl for device
  #
  # ./btrfs qgroup assign 1/5 2/5 /mnt/tmp1
  ERROR: unable to assign quota group: Inappropriate ioctl for device
  #
  # ./btrfs qgroup show /mnt/tmp1
  ERROR: can't perform the search - Inappropriate ioctl for device
  ERROR: can't list qgroups: Inappropriate ioctl for device
  #
  # ./btrfs qgroup limit 1G 1/5  /mnt/tmp1
  ERROR: unable to limit requested quota group: Inappropriate ioctl for device

After patch:
  # ./btrfs qgroup create 1/5 /mnt/tmp1
  ERROR: not a btrfs filesystem: /mnt/tmp1
  # ./btrfs qgroup assign 1/5 2/5 /mnt/tmp1
  ERROR: not a btrfs filesystem: /mnt/tmp1
  # ./btrfs qgroup show /mnt/tmp1
  ERROR: not a btrfs filesystem: /mnt/tmp1
  # ./btrfs qgroup limit 1G 1/5 /mnt/tmp1
  ERROR: not a btrfs filesystem: /mnt/tmp1

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