Changes by: aia21
Update of /cvs/linux-ntfs/ntfsprogs/libntfs
In directory delta357:/tmp/cvs-serv17714/libntfs
Modified Files:
bootsect.c
Log Message:
When the bootsector contains an incorrect checksum, ignore this just printing
a warning.
Some utilities update the bootsector ignoring the checksum which leaves the
checksum out-of-date so we don't want to abort when it is wrong.
This change is taken from the NTFS kernel driver where it has been for ages...
I must have forgotten to apply it to libntfs when I fixed the kernel...
Index: bootsect.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/bootsect.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -p -r1.23 -r1.24
--- bootsect.c 11 Dec 2006 03:02:23 -0000 1.23
+++ bootsect.c 27 Jun 2007 15:29:10 -0000 1.24
@@ -63,22 +63,26 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_
ntfs_log_debug("\nBeginning bootsector check...\n");
- /* Calculate the checksum. Note, this is just a simple addition of
- all u32 values in the bootsector starting at the beginning and
- finishing at the offset of the checksum itself (i.e. not including
- the checksum...). */
- if ((void*)b < (void*)&b->checksum) {
+ /*
+ * Check that checksum == sum of u32 values from b to the checksum
+ * field. If checksum is zero, no checking is done. We will work when
+ * the checksum test fails, since some utilities update the boot sector
+ * ignoring the checksum which leaves the checksum out-of-date. We
+ * report a warning if this is the case.
+ */
+ if ((void*)b < (void*)&b->checksum && b->checksum) {
u32 *u = (u32 *)b;
u32 *bi = (u32 *)(&b->checksum);
ntfs_log_debug("Calculating bootsector checksum... ");
-
for (i = 0; u < bi; ++u)
i += le32_to_cpup(u);
-
- if (le32_to_cpu(b->checksum) && le32_to_cpu(b->checksum) != i)
- goto not_ntfs;
- ntfs_log_debug("OK\n");
+ if (le32_to_cpu(b->checksum) && le32_to_cpu(b->checksum) != i) {
+ ntfs_log_debug("FAILED\n");
+ ntfs_log_debug("The NTFS bootsector contains an "
+ "incorrect checksum.");
+ } else
+ ntfs_log_debug("OK\n");
}
/* Check OEMidentifier is "NTFS " */
|