btrfs-progs: use btrfs_open_dir in open_path_or_dev_mnt
authorZhao Lei <zhaolei@cn.fujitsu.com>
Mon, 12 Oct 2015 13:23:02 +0000 (21:23 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 Nov 2015 08:35:01 +0000 (09:35 +0100)
commit078618d82220e84609cffd074655faafbada4c24
treebfc17db74656dd73489265f35104e5ea40a946da
parent5e1a77c45c8447974fe8a315afc0659ce3f64f4c
btrfs-progs: use btrfs_open_dir in open_path_or_dev_mnt

Use btrfs_open_dir() in open_path_or_dev_mnt() to make the function
return error when target is neither block device nor btrfs mount point.

Also add "verbose" argument to let function output common error
message instead of putting duplicated lines in caller.

Before patch:
  # ./btrfs device stats /mnt/tmp1
  ERROR: getting dev info for devstats failed: Inappropriate ioctl for device
  # ./btrfs replace start /dev/vdd /dev/vde /mnt/tmp1
  ERROR: ioctl(DEV_REPLACE_STATUS) failed on "/mnt/tmp1": Inappropriate ioctl for device

After patch:
  # ./btrfs device stats /mnt/tmp1
  ERROR: not a btrfs filesystem: /mnt/tmp1
  # ./btrfs replace start /dev/vdd /dev/vde /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-device.c
cmds-replace.c
cmds-scrub.c
utils.c
utils.h