Changes by: antona
Update of /cvsroot/linux-ntfs/ntfsprogs/libntfs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv322/libntfs
Modified Files:
volume.c
Log Message:
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. Ported from kernel driver 2.1.27 release and aplied both
to libntfs/volume.c mount related code and to ntfsprogs/ntfsfix.c's
fixup code. (Anton)
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/volume.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -p -r1.68 -r1.69
--- volume.c 3 Feb 2006 22:19:19 -0000 1.68
+++ volume.c 27 Mar 2006 22:43:09 -0000 1.69
@@ -816,6 +816,7 @@ ntfs_volume *ntfs_device_mount(struct nt
}
ntfs_log_debug("Comparing $MFTMirr to $MFT... ");
for (i = 0; i < vol->mftmirr_size; ++i) {
+ MFT_RECORD *mrec, *mrec2;
const char *ESTR[12] = { "$MFT", "$MFTMirr", "$LogFile",
"$Volume", "$AttrDef", "root directory", "$Bitmap",
"$Boot", "$BadClus", "$Secure", "$UpCase", "$Extend" };
@@ -828,33 +829,39 @@ ntfs_volume *ntfs_device_mount(struct nt
else
s = "mft record";
- if (ntfs_is_baad_recordp(m + i * vol->mft_record_size)) {
- ntfs_log_debug("FAILED\n");
- ntfs_log_debug("$MFT error: Incomplete multi sector transfer "
- "detected in %s.\n", s);
- goto io_error_exit;
- }
- if (!ntfs_is_mft_recordp(m + i * vol->mft_record_size)) {
- ntfs_log_debug("FAILED\n");
- ntfs_log_debug("$MFT error: Invalid mft record for %s.\n", s);
- goto io_error_exit;
- }
- if (ntfs_is_baad_recordp(m2 + i * vol->mft_record_size)) {
- ntfs_log_debug("FAILED\n");
- ntfs_log_debug("$MFTMirr error: Incomplete multi sector "
- "transfer detected in %s.\n", s);
- goto io_error_exit;
+ mrec = (MFT_RECORD*)(m + i * vol->mft_record_size);
+ if (mrec->flags & MFT_RECORD_IN_USE) {
+ if (ntfs_is_baad_recordp(mrec)) {
+ ntfs_log_debug("FAILED\n");
+ ntfs_log_debug("$MFT error: Incomplete multi "
+ "sector transfer detected in "
+ "%s.\n", s);
+ goto io_error_exit;
+ }
+ if (!ntfs_is_mft_recordp(mrec)) {
+ ntfs_log_debug("FAILED\n");
+ ntfs_log_debug("$MFT error: Invalid mft "
+ "record for %s.\n", s);
+ goto io_error_exit;
+ }
}
- if (!ntfs_is_mft_recordp(m2 + i * vol->mft_record_size)) {
- ntfs_log_debug("FAILED\n");
- ntfs_log_debug("$MFTMirr error: Invalid mft record for "
- "%s.\n", s);
- goto io_error_exit;
+ mrec2 = (MFT_RECORD*)(m2 + i * vol->mft_record_size);
+ if (mrec2->flags & MFT_RECORD_IN_USE) {
+ if (ntfs_is_baad_recordp(mrec2)) {
+ ntfs_log_debug("FAILED\n");
+ ntfs_log_debug("$MFTMirr error: Incomplete "
+ "multi sector transfer "
+ "detected in %s.\n", s);
+ goto io_error_exit;
+ }
+ if (!ntfs_is_mft_recordp(mrec2)) {
+ ntfs_log_debug("FAILED\n");
+ ntfs_log_debug("$MFTMirr error: Invalid mft "
+ "record for %s.\n", s);
+ goto io_error_exit;
+ }
}
- if (memcmp((u8*)m + i * vol->mft_record_size, (u8*)m2 +
- i * vol->mft_record_size,
- ntfs_mft_record_get_data_size((MFT_RECORD*)(
- (u8*)m + i * vol->mft_record_size)))) {
+ if (memcmp(mrec, mrec2, ntfs_mft_record_get_data_size(mrec))) {
ntfs_log_debug(FAILED);
ntfs_log_debug("$MFTMirr does not match $MFT. Run "
"chkdsk.\n");
|