Avoided logging meaningless fixup errors in ntfsclone and ntfsresize
Logging of fixup errors for uninitialized inodes cause unnecessary worries and suspicion of malfunctions in ntfs-3g. This patch silences these loggings in ntfsclone and ntfsresize which have to analyze all inodes, including the uninitialized ones.edge.strict_endians
parent
ad53f4c24a
commit
08bf2b5bcb
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue