Skip to content

Commit

Permalink
utils: rm_offset_get_from_fd: Break early if not contiguous
Browse files Browse the repository at this point in the history
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
  • Loading branch information
cebtenzzre authored and intelfx committed Mar 9, 2023
1 parent 9492870 commit 0e5a675
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,15 +1229,11 @@ RmOff rm_offset_get_from_fd(int fd, RmOff file_offset, RmOff *file_offset_next,
/* check if subsequent extents are contiguous */
if(fm_ext.fe_physical != expected) {
/* current extent is not contiguous with previous, so we can stop */
done = TRUE;
g_free(fm);
break;
}
}

if(!done && file_offset_next != NULL) {
/* update logical offset of next fragment */
*file_offset_next = fm_ext.fe_logical + fm_ext.fe_length;
}

if(fm_ext.fe_flags & FIEMAP_EXTENT_DATA_INLINE) {
rm_util_set_nullable_bool(is_inline, TRUE);
}
Expand Down

0 comments on commit 0e5a675

Please sign in to comment.