Btrfs-progs: fix closing of opendir()
[platform/upstream/btrfs-progs.git] / btrfs-map-logical.c
index 6d3ef7a..b9635f7 100644 (file)
@@ -55,7 +55,8 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
        length = blocksize;
        while (1) {
                ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
-                                     eb->start, &length, &multi, mirror_num);
+                                     eb->start, &length, &multi,
+                                     mirror_num, NULL);
                BUG_ON(ret);
                device = multi->stripes[0].dev;
                eb->fd = device->fd;
@@ -68,7 +69,7 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
                kfree(multi);
 
                if (!copy || mirror_num == copy)
-                       ret = read_extent_from_disk(eb);
+                       ret = read_extent_from_disk(eb, 0, eb->len);
 
                num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
                                              eb->start, eb->len);
@@ -84,7 +85,7 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
 
 static void print_usage(void)
 {
-       fprintf(stderr, "usage: btrfs-map-logical [options] mount_point\n");
+       fprintf(stderr, "usage: btrfs-map-logical [options] device\n");
        fprintf(stderr, "\t-l Logical extent to map\n");
        fprintf(stderr, "\t-c Copy of the extent to read (usually 1 or 2)\n");
        fprintf(stderr, "\t-o Output file to hold the extent\n");
@@ -96,7 +97,7 @@ static struct option long_options[] = {
        /* { "byte-count", 1, NULL, 'b' }, */
        { "logical", 1, NULL, 'l' },
        { "copy", 1, NULL, 'c' },
-       { "output", 1, NULL, 'c' },
+       { "output", 1, NULL, 'o' },
        { "bytes", 1, NULL, 'b' },
        { 0, 0, 0, 0}
 };
@@ -173,6 +174,7 @@ int main(int ac, char **av)
                exit(1);
        }
 
+       info_file = stdout;
        if (output_file) {
                if (strcmp(output_file, "-") == 0) {
                        out_fd = 1;