int bmv_iflags = 0; /* flags for XFS_IOC_GETBMAPX */
int i = 0;
int c;
+ int egcnt;
while ((c = getopt(argc, argv, "adln:pv")) != EOF) {
switch (c) {
}
}
- map_size = nflag ? nflag+1 : 32; /* initial guess - 256 */
+ map_size = nflag ? nflag+2 : 32; /* initial guess - 256 */
map = malloc(map_size*sizeof(*map));
if (map == NULL) {
fprintf(stderr, _("%s: malloc of %d bytes failed.\n"),
return 0;
}
}
+ egcnt = nflag ? min(nflag, map->bmv_entries) : map->bmv_entries;
printf("%s:\n", file->name);
if (!vflag) {
- for (i = 0; i < map->bmv_entries; i++) {
+ for (i = 0; i < egcnt; i++) {
printf("\t%d: [%lld..%lld]: ", i,
(long long) map[i + 1].bmv_offset,
(long long)(map[i + 1].bmv_offset +
* Go through the extents and figure out the width
* needed for all columns.
*/
- for (i = 0; i < map->bmv_entries; i++) {
+ for (i = 0; i < egcnt; i++) {
snprintf(rbuf, sizeof(rbuf), "[%lld..%lld]:",
(long long) map[i + 1].bmv_offset,
(long long)(map[i + 1].bmv_offset +
aoff_w, _("AG-OFFSET"),
tot_w, _("TOTAL"),
flg ? _(" FLAGS") : "");
- for (i = 0; i < map->bmv_entries; i++) {
+ for (i = 0; i < egcnt; i++) {
flg = FLG_NULL;
if (map[i + 1].bmv_oflags & BMV_OF_PREALLOC) {
flg |= FLG_PRE;