Accept incorrect $Bitmap size if it covers the entire volume

edge.strict_endians
szaka 2005-09-29 23:30:15 +00:00
parent 9ee916bbd0
commit ab2ad80ae7
3 changed files with 22 additions and 37 deletions

View File

@ -63,6 +63,11 @@ xx/xx/2005 - 1.12.0-WIP
- ntfsclone: fix saving by sectors during --rescue (Scott Hansen, Szaka)
- Fix the definition of the CHKD ntfs record magic. It had an off by
two error causing it to be CHKB instead of CHKD. (Anton)
- Add new utility ntfscmp (make extra) which compares two NTFS volumes
and tell the differences. It's used for development, debugging,
testing, etc. (Szaka)
- ntfsresize, ntfsclone: accept incorrect $Bitmap size if it covers
the entire volume. (Szaka)
08/08/2005 - 1.11.2 - ntfsdecrypt now works and lots of fixes and improvements.

View File

@ -419,25 +419,6 @@ static void progress_update(struct progress_bar *p, u64 current)
fflush(msg_out);
}
/**
* nr_clusters_to_bitmap_byte_size
*
* Take the number of clusters in the volume and calculate the size of $Bitmap.
* The size will always be a multiple of 8 bytes.
*/
static s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
{
s64 bm_bsize;
bm_bsize = rounded_up_division(nr_clusters, 8);
bm_bsize = (bm_bsize + 7) & ~7;
Dprintf("Bitmap byte size : %lld (%lld clusters)\n",
bm_bsize, rounded_up_division(bm_bsize, vol->cluster_size));
return bm_bsize;
}
static s64 is_critical_metadata(ntfs_walk_clusters_ctx *image, runlist *rl)
{
s64 inode = image->ni->mft_no;
@ -875,16 +856,18 @@ static void compare_bitmaps(struct bitmap *a)
perr_exit("Couldn't get $Bitmap $DATA");
if (count == 0) {
if (a->size != pos)
err_exit("$Bitmap file size doesn't match "
"calculated size (%lld != %lld)\n",
a->size, pos);
if (a->size > pos)
err_exit("$Bitmap size is smaller than expected"
" (%lld != %lld)\n", a->size, pos);
break;
}
for (i = 0; i < count; i++, pos++) {
s64 cl; /* current cluster */
if (a->size <= pos)
goto done;
if (a->bm[pos] == bm[i])
continue;
@ -910,7 +893,7 @@ static void compare_bitmaps(struct bitmap *a)
}
}
}
done:
if (mismatch) {
Printf("Totally %d cluster accounting mismatches.\n", mismatch);
if (opt.ignore_fs_check) {
@ -1071,7 +1054,7 @@ static void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
static void setup_lcn_bitmap(void)
{
/* Determine lcn bitmap byte size and allocate it. */
lcn_bitmap.size = nr_clusters_to_bitmap_byte_size(vol->nr_clusters);
lcn_bitmap.size = rounded_up_division(vol->nr_clusters, 8);
if (!(lcn_bitmap.bm = (unsigned char *)calloc(1, lcn_bitmap.size)))
perr_exit("Failed to allocate internal buffer");

View File

@ -616,7 +616,7 @@ static void dump_runlist(runlist *rl)
* nr_clusters_to_bitmap_byte_size
*
* Take the number of clusters in the volume and calculate the size of $Bitmap.
* The size will always be a multiple of 8 bytes.
* The size must be always a multiple of 8 bytes.
*/
static s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
{
@ -927,21 +927,18 @@ static void compare_bitmaps(ntfs_volume *vol, struct bitmap *a)
perr_exit("Couldn't get $Bitmap $DATA");
if (count == 0) {
if (a->size != pos)
err_exit("$Bitmap file size doesn't match "
"calculated size (%lld != %lld)\n",
a->size, pos);
if (a->size > pos)
err_exit("$Bitmap size is smaller than expected"
" (%lld != %lld)\n", a->size, pos);
break;
}
if (a->size < pos + count)
err_exit("$Bitmap file size is larger than "
"expected (%lld+ versus %lld)\n",
pos + count, a->size);
for (i = 0; i < count; i++, pos++) {
s64 cl; /* current cluster */
if (a->size <= pos)
goto done;
if (a->bm[pos] == bm[i])
continue;
@ -972,7 +969,7 @@ static void compare_bitmaps(ntfs_volume *vol, struct bitmap *a)
}
}
}
done:
if (mismatch) {
err_printf("Filesystem check failed! Totally %d cluster "
"accounting mismatches.\n", mismatch);
@ -2087,7 +2084,7 @@ static void truncate_bitmap_file(ntfs_resize_t *resize)
static int setup_lcn_bitmap(struct bitmap *bm, s64 nr_clusters)
{
/* Determine lcn bitmap byte size and allocate it. */
bm->size = nr_clusters_to_bitmap_byte_size(nr_clusters);
bm->size = rounded_up_division(nr_clusters, 8);
if (!(bm->bm = (unsigned char *)calloc(1, bm->size)))
return -1;