Fix for ntfs_rl_truncate() EIO: always set the correct size for $BadClus:$Bad,

even if Windows set it incorrectly
edge.strict_endians
szaka 2005-08-03 22:40:29 +00:00
parent 36c5f89d13
commit 4e8e7ae9fa
2 changed files with 22 additions and 5 deletions

View File

@ -27,6 +27,8 @@ xx/xx/xxxx - 1.12.0-WIP
harmony with the kernel driver. (Szaka)
- Fix ntfs_is_cb_compressed for nasty runlist merging case in which
compression block was incorrectly treated as not compressed. (Yura)
- ntfsresize: fix for ntfs_rl_truncate() EIO: always set the correct
size for $BadClus:$Bad, even if Windows set it incorrectly. (Szaka)
20/07/2005 - 1.11.1 - Fix several ntfsmount bugs.

View File

@ -1835,6 +1835,25 @@ static void rl_expand(runlist **rl, const VCN last_vcn)
err_exit("rl_expand: bad LCN: %lld\n", p[len - 1].lcn);
}
static void rl_truncate(runlist **rl, const VCN last_vcn)
{
int len;
VCN vcn;
len = rl_items(*rl) - 1;
if (len <= 0)
err_exit("rl_truncate: bad runlist length: %d\n", len);
vcn = (*rl)[len].vcn;
if (vcn < last_vcn)
rl_expand(rl, last_vcn);
else if (vcn > last_vcn)
if (ntfs_rl_truncate(rl, last_vcn) == -1)
perr_exit("ntfs_rl_truncate");
}
/**
* bitmap_file_data_fixup
*
@ -1870,11 +1889,7 @@ static void truncate_badclust_bad_attr(ntfs_resize_t *resize)
if (!(rl_bad = ntfs_mapping_pairs_decompress(vol, a, NULL)))
perr_exit("ntfs_mapping_pairs_decompress");
if (resize->shrink) {
if (ntfs_rl_truncate(&rl_bad, nr_clusters) == -1)
perr_exit("ntfs_rl_truncate");
} else
rl_expand(&rl_bad, nr_clusters);
rl_truncate(&rl_bad, nr_clusters);
a->highest_vcn = cpu_to_le64(nr_clusters - 1LL);
a->allocated_size = cpu_to_le64(nr_clusters * vol->cluster_size);