libbtrfsutil: fix memory leak in deleted_subvolumes()
[platform/upstream/btrfs-progs.git] / cmds-inspect.c
index 6d4e2b8..afd7fe4 100644 (file)
@@ -31,9 +31,7 @@
 #include "disk-io.h"
 #include "commands.h"
 #include "btrfs-list.h"
-#include "cmds-inspect-dump-tree.h"
-#include "cmds-inspect-dump-super.h"
-#include "cmds-inspect-tree-stats.h"
+#include "help.h"
 
 static const char * const inspect_cmd_group_usage[] = {
        "btrfs inspect-internal <command> <args>",
@@ -54,7 +52,7 @@ static int __ino_to_path_fd(u64 inum, int fd, int verbose, const char *prepend)
 
        ret = ioctl(fd, BTRFS_IOC_INO_PATHS, &ipa);
        if (ret < 0) {
-               error("ino paths ioctl: %s", strerror(errno));
+               error("ino paths ioctl: %m");
                goto out;
        }
 
@@ -173,7 +171,7 @@ static int cmd_inspect_logical_resolve(int argc, char **argv)
        if (check_argc_exact(argc - optind, 2))
                usage(cmd_inspect_logical_resolve_usage);
 
-       size = min(size, (u64)64 * 1024);
+       size = min(size, (u64)SZ_64K);
        inodes = malloc(size);
        if (!inodes)
                return 1;
@@ -191,7 +189,7 @@ static int cmd_inspect_logical_resolve(int argc, char **argv)
 
        ret = ioctl(fd, BTRFS_IOC_LOGICAL_INO, &loi);
        if (ret < 0) {
-               error("logical ino ioctl: %s", strerror(errno));
+               error("logical ino ioctl: %m");
                goto out;
        }
 
@@ -320,13 +318,13 @@ 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;
        }
 
-       ret = lookup_ino_rootid(fd, &rootid);
+       ret = lookup_path_rootid(fd, &rootid);
        if (ret) {
                error("failed to lookup root id: %s", strerror(-ret));
                goto out;
@@ -486,7 +484,7 @@ static void adjust_dev_min_size(struct list_head *extents,
                 * chunk tree, so often this can lead to the need of allocating
                 * a new system chunk too, which has a maximum size of 32Mb.
                 */
-               *min_size += 32 * 1024 * 1024;
+               *min_size += SZ_32M;
        }
 }
 
@@ -500,7 +498,7 @@ static int print_min_dev_size(int fd, u64 devid)
         * possibility of deprecating/removing it has been discussed, so we
         * ignore it here.
         */
-       u64 min_size = 1 * 1024 * 1024ull;
+       u64 min_size = SZ_1M;
        struct btrfs_ioctl_search_args args;
        struct btrfs_ioctl_search_key *sk = &args.key;
        u64 last_pos = (u64)-1;
@@ -526,7 +524,7 @@ static int print_min_dev_size(int fd, u64 devid)
 
                ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
                if (ret < 0) {
-                       error("tree search ioctl: %s", strerror(errno));
+                       error("tree search ioctl: %m");
                        ret = 1;
                        goto out;
                }