#include "transaction.h"
#include "list.h"
#include "utils.h"
+#include "help.h"
-#define BUFFER_SIZE (64 * 1024)
+#define BUFFER_SIZE SZ_64K
/* we write the mirror info to stdout unless they are dumping the data
* to stdout
multi->stripes[0].physical,
device->name);
}
- kfree(multi);
+ free(multi);
multi = NULL;
cur_offset += cur_len;
}
static void print_usage(void) __attribute__((noreturn));
static void print_usage(void)
{
- 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");
- fprintf(stderr, "\t-b Number of bytes to read\n");
+ printf("usage: btrfs-map-logical [options] device\n");
+ printf("\t-l Logical extent to map\n");
+ printf("\t-c Copy of the extent to read (usually 1 or 2)\n");
+ printf("\t-o Output file to hold the extent\n");
+ printf("\t-b Number of bytes to read\n");
exit(1);
}
goto out_close_fd;
if (ret > 0)
break;
+ /* check again if there is overlap. */
+ if (cur_logical + cur_len < logical ||
+ cur_logical >= logical + bytes)
+ break;
+
real_logical = max(logical, cur_logical);
real_len = min(logical + bytes, cur_logical + cur_len) -
real_logical;