The XFS_IOC_FSGETXATTRA ioctl only returns the number of allocated
extents, so when we reallocate the extent array in the bmap command
we have to account for the worst case where there is a whole between
each two allocated extents. Also add some slack to that case to
allow for a file growing while we are racing with it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
exitcode = 1;
return 0;
}
- if (fsx.fsx_nextents >= map_size-1) {
- map_size = 2*(fsx.fsx_nextents+1);
+ if (2 * fsx.fsx_nextents > map_size) {
+ map_size = 2 * fsx.fsx_nextents + 1;
map = realloc(map, map_size*sizeof(*map));
if (map == NULL) {
fprintf(stderr,