Changes by: szaka
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19035/ntfsprogs
Modified Files:
ntfsclone.c ntfsresize.c
Log Message:
Accept incorrect $Bitmap size if it covers the entire volume
Index: ntfsclone.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsclone.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -p -r1.51 -r1.52
--- ntfsclone.c 28 Sep 2005 13:47:48 -0000 1.51
+++ ntfsclone.c 29 Sep 2005 23:30:16 -0000 1.52
@@ -419,25 +419,6 @@ static void progress_update(struct progr
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 bitma
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 bitma
}
}
}
-
+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 c
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");
Index: ntfsresize.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsresize.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -p -r1.90 -r1.91
--- ntfsresize.c 28 Sep 2005 13:47:48 -0000 1.90
+++ ntfsresize.c 29 Sep 2005 23:30:16 -0000 1.91
@@ -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
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
}
}
}
-
+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_re
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;
|