diff options
Diffstat (limited to 'cmds-inspect.c')
-rw-r--r-- | cmds-inspect.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/cmds-inspect.c b/cmds-inspect.c index fc3db99..40ab49b 100644 --- a/cmds-inspect.c +++ b/cmds-inspect.c @@ -116,11 +116,9 @@ static int cmd_inspect_inode_resolve(int argc, char **argv) if (check_argc_exact(argc - optind, 2)) usage(cmd_inspect_inode_resolve_usage); - fd = open_file_or_dir(argv[optind+1], &dirstream); - if (fd < 0) { - fprintf(stderr, "ERROR: can't access '%s'\n", argv[optind+1]); + fd = btrfs_open_dir(argv[optind + 1], &dirstream, 1); + if (fd < 0) return 1; - } ret = __ino_to_path_fd(arg_strtou64(argv[optind]), fd, verbose, argv[optind+1]); @@ -189,9 +187,8 @@ static int cmd_inspect_logical_resolve(int argc, char **argv) loi.size = size; loi.inodes = ptr_to_u64(inodes); - fd = open_file_or_dir(argv[optind+1], &dirstream); + fd = btrfs_open_dir(argv[optind + 1], &dirstream, 1); if (fd < 0) { - fprintf(stderr, "ERROR: can't access '%s'\n", argv[optind+1]); ret = 12; goto out; } @@ -239,10 +236,9 @@ static int cmd_inspect_logical_resolve(int argc, char **argv) name); BUG_ON(ret >= bytes_left); free(name); - path_fd = open_file_or_dir(full_path, &dirs); + path_fd = btrfs_open_dir(full_path, &dirs, 1); if (path_fd < 0) { - fprintf(stderr, "ERROR: can't access " - "'%s'\n", full_path); + ret = -ENOENT; goto out; } } @@ -278,9 +274,8 @@ static int cmd_inspect_subvolid_resolve(int argc, char **argv) if (check_argc_exact(argc, 3)) usage(cmd_inspect_subvolid_resolve_usage); - fd = open_file_or_dir(argv[2], &dirstream); + fd = btrfs_open_dir(argv[2], &dirstream, 1); if (fd < 0) { - fprintf(stderr, "ERROR: can't access '%s'\n", argv[2]); ret = -ENOENT; goto out; } @@ -319,9 +314,8 @@ static int cmd_inspect_rootid(int argc, char **argv) if (check_argc_exact(argc, 2)) usage(cmd_inspect_rootid_usage); - fd = open_file_or_dir(argv[1], &dirstream); + fd = btrfs_open_dir(argv[1], &dirstream, 1); if (fd < 0) { - fprintf(stderr, "ERROR: can't access '%s'\n", argv[1]); ret = -ENOENT; goto out; } @@ -618,17 +612,15 @@ static int cmd_inspect_min_dev_size(int argc, char **argv) if (check_argc_exact(argc - optind, 1)) usage(cmd_inspect_min_dev_size_usage); - fd = open_file_or_dir(argv[optind], &dirstream); + fd = btrfs_open_dir(argv[optind], &dirstream, 1); if (fd < 0) { - fprintf(stderr, "ERROR: can't access '%s'\n", argv[optind]); ret = -ENOENT; goto out; } ret = print_min_dev_size(fd, devid); -out: close_file_or_dir(fd, dirstream); - +out: return !!ret; } |