[PATCH 05/14] NTFS: Fix comparison of $MFT and $MFTMirr

From: Anton Altaparmakov
Date: Thu Mar 23 2006 - 12:21:57 EST


NTFS: Fix comparison of $MFT and $MFTMirr to not bail out when there are
unused, invalid mft records which are the same in both $MFT and
$MFTMirr.

Signed-off-by: Anton Altaparmakov <aia21@xxxxxxxxxx>

---

Best regards,

Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/

fs/ntfs/ChangeLog | 3 +++
fs/ntfs/super.c | 38 +++++++++++++++++++++++++-------------
2 files changed, 28 insertions(+), 13 deletions(-)

949763b2b8822c6dc6da0d0e1d4af092152546c2
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 8df1070..548d905 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -28,6 +28,9 @@ ToDo/Notes:
continued the attribute lookup loop instead of aborting it.
- Use buffer_migrate_page() for the ->migratepage function of all ntfs
address space operations.
+ - Fix comparison of $MFT and $MFTMirr to not bail out when there are
+ unused, invalid mft records which are the same in both $MFT and
+ $MFTMirr.

2.1.26 - Minor bug fixes and updates.

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 71c58ec..fd4aecc 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1099,26 +1099,38 @@ static BOOL check_mft_mirror(ntfs_volume
kmirr = page_address(mirr_page);
++index;
}
- /* Make sure the record is ok. */
- if (ntfs_is_baad_recordp((le32*)kmft)) {
- ntfs_error(sb, "Incomplete multi sector transfer "
- "detected in mft record %i.", i);
+ /* Do not check the record if it is not in use. */
+ if (((MFT_RECORD*)kmft)->flags & MFT_RECORD_IN_USE) {
+ /* Make sure the record is ok. */
+ if (ntfs_is_baad_recordp((le32*)kmft)) {
+ ntfs_error(sb, "Incomplete multi sector "
+ "transfer detected in mft "
+ "record %i.", i);
mm_unmap_out:
- ntfs_unmap_page(mirr_page);
+ ntfs_unmap_page(mirr_page);
mft_unmap_out:
- ntfs_unmap_page(mft_page);
- return FALSE;
+ ntfs_unmap_page(mft_page);
+ return FALSE;
+ }
}
- if (ntfs_is_baad_recordp((le32*)kmirr)) {
- ntfs_error(sb, "Incomplete multi sector transfer "
- "detected in mft mirror record %i.", i);
- goto mm_unmap_out;
+ /* Do not check the mirror record if it is not in use. */
+ if (((MFT_RECORD*)kmirr)->flags & MFT_RECORD_IN_USE) {
+ if (ntfs_is_baad_recordp((le32*)kmirr)) {
+ ntfs_error(sb, "Incomplete multi sector "
+ "transfer detected in mft "
+ "mirror record %i.", i);
+ goto mm_unmap_out;
+ }
}
/* Get the amount of data in the current record. */
bytes = le32_to_cpu(((MFT_RECORD*)kmft)->bytes_in_use);
- if (!bytes || bytes > vol->mft_record_size) {
+ if (bytes < sizeof(MFT_RECORD_OLD) ||
+ bytes > vol->mft_record_size ||
+ ntfs_is_baad_recordp((le32*)kmft)) {
bytes = le32_to_cpu(((MFT_RECORD*)kmirr)->bytes_in_use);
- if (!bytes || bytes > vol->mft_record_size)
+ if (bytes < sizeof(MFT_RECORD_OLD) ||
+ bytes > vol->mft_record_size ||
+ ntfs_is_baad_recordp((le32*)kmirr))
bytes = vol->mft_record_size;
}
/* Compare the two records. */
--
1.2.3.g9821

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/