From a40f1c30b6b20ec3d054af8f3592ba57c55064b9 Mon Sep 17 00:00:00 2001 From: "(none)!yura" <(none)!yura> Date: Thu, 5 Aug 2004 19:35:51 +0000 Subject: [PATCH] * bugfix ntfs_attr_truncate: determine what we need to do with attribute (expand or shrink) from na->data_size not from na->initialized_size * revert code and comment update about highest in ntfs_non_resident_attr_{shrink,expand}, because I fixed that bug (Logical change 1.478) --- libntfs/attrib.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libntfs/attrib.c b/libntfs/attrib.c index f303d987..7951754b 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -3017,11 +3017,10 @@ static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize) /* * Reminder: It is ok for a->highest_vcn to be -1 for zero * length files. - * FIXME: We may not update a->highest_vcn if it equal to 0. - * But bug in runlist mapping code prevent us from doing so. - * Find and remove this bug. + * Reminder: We may not update a->highest_vcn if it equal to 0. */ - a->highest_vcn = scpu_to_le64(first_free_vcn - 1); + if (a->highest_vcn) + a->highest_vcn = scpu_to_le64(first_free_vcn - 1); /* Get the size for the new mapping pairs array. */ mp_size = ntfs_get_size_for_mapping_pairs(vol, na->rl); if (mp_size <= 0) { @@ -3365,11 +3364,10 @@ static int ntfs_non_resident_attr_expand(ntfs_attr *na, const s64 newsize) na->allocated_size = first_free_vcn << vol->cluster_size_bits; a->allocated_size = scpu_to_le64(na->allocated_size); /* - * FIXME: We may not update a->highest_vcn if it equal to 0. - * But bug in runlist mapping code prevent us from doing so. - * Find and remove this bug. + * Reminder: We may not update a->highest_vcn if it equal to 0. */ - a->highest_vcn = scpu_to_le64(first_free_vcn - 1); + if (a->highest_vcn) + a->highest_vcn = scpu_to_le64(first_free_vcn - 1); } /* Update the attribute record and the ntfs attribute structure. */ na->data_size = newsize; @@ -3460,7 +3458,7 @@ int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize) return -1; } if (NAttrNonResident(na)) { - if (newsize > na->initialized_size) + if (newsize > na->data_size) return ntfs_non_resident_attr_expand(na, newsize); else return ntfs_non_resident_attr_shrink(na, newsize);