diff --git a/include/runlist.h b/include/runlist.h index e6e1a3ed..61069bce 100644 --- a/include/runlist.h +++ b/include/runlist.h @@ -71,7 +71,7 @@ extern int ntfs_write_significant_bytes(s8 *dst, const s8 *dst_max, extern int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst, const int dst_len, const runlist_element *rl); -extern int ntfs_rl_truncate(runlist_element *rl, const VCN start_vcn); +extern int ntfs_rl_truncate(runlist **rl, const VCN start_vcn); #endif /* defined _NTFS_RUNLIST_H */ diff --git a/libntfs/attrib.c b/libntfs/attrib.c index 63b5d864..250efa18 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -2110,7 +2110,7 @@ static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize) } /* Truncate the runlist itself. */ - if (ntfs_rl_truncate(na->rl, first_free_vcn)) { + if (ntfs_rl_truncate(&na->rl, first_free_vcn)) { // FIXME: Eeek! We need rollback! (AIA) fprintf(stderr, "%s(): Eeek! Run list truncation failed. " "Leaving inconsistent metadata!\n", diff --git a/libntfs/runlist.c b/libntfs/runlist.c index e0c5a21d..85d1ec3f 100644 --- a/libntfs/runlist.c +++ b/libntfs/runlist.c @@ -1309,15 +1309,18 @@ err_out: /** * ntfs_rl_truncate - truncate a runlist starting at a specified vcn - * @rl: runlist to truncate + * @rl: address of runlist to truncate * @start_vcn: first vcn which should be cut off * - * Truncate the runlist @rl starting at vcn @start_vcn as well as the memory + * Truncate the runlist *@rl starting at vcn @start_vcn as well as the memory * buffer holding the runlist. * * Return 0 on success and -1 on error with errno set to the error code. + * + * NOTE: @rl is the address of the runlist. We need the address so we can + * modify the pointer to the runlist with the new, reallocated memory buffer. */ -int ntfs_rl_truncate(runlist_element *rl, const VCN start_vcn) +int ntfs_rl_truncate(runlist **rl, const VCN start_vcn) { errno = ENOTSUP; return -1;