From 88ef0b8397fa13f6114dc3ba5c8e88a7b7c992f9 Mon Sep 17 00:00:00 2001 From: "Misono, Tomohiro" Date: Mon, 4 Sep 2017 14:05:34 +0900 Subject: btrfs-progs: inspect rootid: Allow a file to be specified Since cmd_inspect_rootid() calls btrfs_open_dir(), it rejects a file to be specified. But as the document says, a file should be supported. This patch introduces btrfs_open_file_or_dir(), which is a counterpart of btrfs_open_dir(), to safely check and open btrfs file or directory. The original btrfs_open_dir() content is moved to btrfs_open() and shared by both function. Signed-off-by: Tomohiro Misono Signed-off-by: David Sterba --- cmds-inspect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmds-inspect.c') diff --git a/cmds-inspect.c b/cmds-inspect.c index d1a3a0e0..885f3abe 100644 --- a/cmds-inspect.c +++ b/cmds-inspect.c @@ -318,7 +318,7 @@ static int cmd_inspect_rootid(int argc, char **argv) if (check_argc_exact(argc - optind, 1)) usage(cmd_inspect_rootid_usage); - fd = btrfs_open_dir(argv[optind], &dirstream, 1); + fd = btrfs_open_file_or_dir(argv[optind], &dirstream, 1); if (fd < 0) { ret = -ENOENT; goto out; -- cgit v1.2.3