diff --git a/include/ntfs-3g/mst.h b/include/ntfs-3g/mst.h index ca813821..d6ca6f27 100644 --- a/include/ntfs-3g/mst.h +++ b/include/ntfs-3g/mst.h @@ -25,8 +25,11 @@ #include "types.h" #include "layout.h" +#include "volume.h" extern int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size); +extern int ntfs_mst_post_read_fixup_warn(NTFS_RECORD *b, const u32 size, + BOOL warn); extern int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size); extern void ntfs_mst_post_write_fixup(NTFS_RECORD *b); diff --git a/include/ntfs-3g/volume.h b/include/ntfs-3g/volume.h index 5781e16b..9d62d668 100644 --- a/include/ntfs-3g/volume.h +++ b/include/ntfs-3g/volume.h @@ -113,6 +113,7 @@ typedef enum { NV_ShowHidFiles, /* 1: Show files marked hidden. */ NV_HideDotFiles, /* 1: Set hidden flag on dot files */ NV_Compression, /* 1: allow compression */ + NV_NoFixupWarn, /* 1: Do not log fixup errors */ } ntfs_volume_state_bits; #define test_nvol_flag(nv, flag) test_bit(NV_##flag, (nv)->state) @@ -147,6 +148,10 @@ typedef enum { #define NVolSetCompression(nv) set_nvol_flag(nv, Compression) #define NVolClearCompression(nv) clear_nvol_flag(nv, Compression) +#define NVolNoFixupWarn(nv) test_nvol_flag(nv, NoFixupWarn) +#define NVolSetNoFixupWarn(nv) set_nvol_flag(nv, NoFixupWarn) +#define NVolClearNoFixupWarn(nv) clear_nvol_flag(nv, NoFixupWarn) + /* * NTFS version 1.1 and 1.2 are used by Windows NT4. * NTFS version 2.x is used by Windows 2000 Beta diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index b790908c..14a2efcd 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -2534,6 +2534,7 @@ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt, { s64 br; u8 *end; + BOOL warn; ntfs_log_trace("Entering for inode 0x%llx, attr type 0x%x, pos 0x%llx.\n", (unsigned long long)na->ni->mft_no, na->type, @@ -2547,9 +2548,11 @@ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt, if (br <= 0) return br; br /= bk_size; + /* log errors unless silenced */ + warn = !na->ni || !na->ni->vol || !NVolNoFixupWarn(na->ni->vol); for (end = (u8*)dst + br * bk_size; (u8*)dst < end; dst = (u8*)dst + bk_size) - ntfs_mst_post_read_fixup((NTFS_RECORD*)dst, bk_size); + ntfs_mst_post_read_fixup_warn((NTFS_RECORD*)dst, bk_size, warn); /* Finally, return the number of blocks read. */ return br; } diff --git a/libntfs-3g/mft.c b/libntfs-3g/mft.c index 6d45a806..0640efe9 100644 --- a/libntfs-3g/mft.c +++ b/libntfs-3g/mft.c @@ -216,8 +216,10 @@ int ntfs_mft_record_check(const ntfs_volume *vol, const MFT_REF mref, int ret = -1; if (!ntfs_is_file_record(m->magic)) { - ntfs_log_error("Record %llu has no FILE magic (0x%x)\n", - (unsigned long long)MREF(mref), *(le32 *)m); + if (!NVolNoFixupWarn(vol)) + ntfs_log_error("Record %llu has no FILE magic (0x%x)\n", + (unsigned long long)MREF(mref), + (int)le32_to_cpu(*(le32*)m)); goto err_out; } diff --git a/libntfs-3g/mst.c b/libntfs-3g/mst.c index 470942d6..b7937b7a 100644 --- a/libntfs-3g/mst.c +++ b/libntfs-3g/mst.c @@ -47,7 +47,8 @@ * EIO Multi sector transfer error was detected. Magic of the NTFS * record in @b will have been set to "BAAD". */ -int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size) +int ntfs_mst_post_read_fixup_warn(NTFS_RECORD *b, const u32 size, + BOOL warn) { u16 usa_ofs, usa_count, usn; u16 *usa_pos, *data_pos; @@ -63,9 +64,14 @@ int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size) (u32)(usa_ofs + (usa_count * 2)) > size || (size >> NTFS_BLOCK_SIZE_BITS) != usa_count) { errno = EINVAL; - ntfs_log_perror("%s: magic: 0x%08x size: %d usa_ofs: %d " - "usa_count: %d", __FUNCTION__, *(le32 *)b, - size, usa_ofs, usa_count); + if (warn) { + ntfs_log_perror("%s: magic: 0x%08lx size: %ld " + " usa_ofs: %d usa_count: %u", + __FUNCTION__, + (long)le32_to_cpu(*(le32 *)b), + (long)size, (int)usa_ofs, + (unsigned int)usa_count); + } return -1; } /* Position of usn in update sequence array. */ @@ -118,6 +124,16 @@ int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size) return 0; } +/* + * Deprotect multi sector transfer protected data + * with a warning if an error is found. + */ + +int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size) +{ + return (ntfs_mst_post_read_fixup_warn(b,size,TRUE)); +} + /** * ntfs_mst_pre_write_fixup - apply multi sector transfer protection * @b: pointer to the data to protect diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 481d240a..72d8d390 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -1292,6 +1292,7 @@ static int walk_clusters(ntfs_volume *volume, struct ntfs_walk_cluster *walk) volume->mft_record_size_bits) - 1; progress_init(&progress, inode, last_mft_rec, 100); + NVolSetNoFixupWarn(volume); for (; inode <= last_mft_rec; inode++) { int err, deleted_inode; diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index e29e32e0..816d657e 100644 --- a/ntfsprogs/ntfsresize.c +++ b/ntfsprogs/ntfsresize.c @@ -2814,6 +2814,7 @@ int main(int argc, char **argv) */ resize.badclusters = check_bad_sectors(vol); + NVolSetNoFixupWarn(vol); check_cluster_allocation(vol, &fsck); print_disk_usage(vol, fsck.inuse);