OSDN Git Service

Avoided meaningless errors logging during ntfsundelete scans
authorJean-Pierre André <jpandre@users.sourceforge.net>
Sat, 9 Feb 2013 10:51:40 +0000 (11:51 +0100)
committerJean-Pierre André <jpandre@users.sourceforge.net>
Sat, 9 Feb 2013 10:51:40 +0000 (11:51 +0100)
When ntfsundelete scans the $MFT for possible deleted files, it may
examine extries which have never been used, producing error messages
which most users do not understand. This patch silences such messages.

ntfsprogs/ntfsundelete.c

index 7e1aa86..cee1f2b 100644 (file)
@@ -1160,6 +1160,7 @@ static struct ufile * read_record(ntfs_volume *vol, long long record)
        ATTR_RECORD *attr10, *attr20, *attr90;
        struct ufile *file;
        ntfs_attr *mft;
+       u32 log_levels;
 
        if (!vol)
                return NULL;
@@ -1198,6 +1199,8 @@ static struct ufile * read_record(ntfs_volume *vol, long long record)
        ntfs_attr_close(mft);
        mft = NULL;
 
+       /* disable errors logging, while examining suspicious records */
+       log_levels = ntfs_log_clear_levels(NTFS_LOG_LEVEL_PERROR);
        attr10 = find_first_attribute(AT_STANDARD_INFORMATION,  file->mft);
        attr20 = find_first_attribute(AT_ATTRIBUTE_LIST,        file->mft);
        attr90 = find_first_attribute(AT_INDEX_ROOT,            file->mft);
@@ -1222,6 +1225,8 @@ static struct ufile * read_record(ntfs_volume *vol, long long record)
        if (get_data(file, vol) < 0) {
                ntfs_log_error("ERROR: Couldn't get data streams.\n");
        }
+       /* restore errors logging */
+       ntfs_log_set_levels(log_levels);
 
        return file;
 }
@@ -2008,6 +2013,7 @@ static int scan_disk(ntfs_volume *vol)
                ntfs_log_perror("ERROR: Couldn't open $MFT/$BITMAP");
                return -1;
        }
+       NVolSetNoFixupWarn(vol);
        bmpsize = attr->initialized_size;
 
        buffer = malloc(BUFSIZE);
@@ -2094,6 +2100,7 @@ out:
        if (opts.match)
                regfree(&re);
        free(buffer);
+       NVolClearNoFixupWarn(vol);
        if (attr)
                ntfs_attr_close(attr);
        return results;