Skip to content

Commit e0f363a

Browse files
fs/ntfs3: Mark ntfs dirty when on-disk struct is corrupted
Signed-off-by: Konstantin Komarov <[email protected]>
1 parent d6cd7ce commit e0f363a

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

fs/ntfs3/fsntfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER *rhdr, size_t bytes,
178178
/* Check errors. */
179179
if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_SIZE || !fn-- ||
180180
fn * SECTOR_SIZE > bytes) {
181-
return -EINVAL; /* Native chkntfs returns ok! */
181+
return -E_NTFS_CORRUPT;
182182
}
183183

184184
/* Get fixup pointer. */

fs/ntfs3/index.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,12 @@ int indx_read(struct ntfs_index *indx, struct ntfs_inode *ni, CLST vbn,
11131113
*node = in;
11141114

11151115
out:
1116+
if (err == -E_NTFS_CORRUPT) {
1117+
ntfs_inode_err(&ni->vfs_inode, "directory corrupted");
1118+
ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR);
1119+
err = -EINVAL;
1120+
}
1121+
11161122
if (ib != in->index)
11171123
kfree(ib);
11181124

fs/ntfs3/ntfs_fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ enum utf16_endian;
5353
#define E_NTFS_NONRESIDENT 556
5454
/* NTFS specific error code about punch hole. */
5555
#define E_NTFS_NOTALIGNED 557
56+
/* NTFS specific error code when on-disk struct is corrupted. */
57+
#define E_NTFS_CORRUPT 558
5658

5759

5860
/* sbi->flags */

fs/ntfs3/record.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ int mi_read(struct mft_inode *mi, bool is_mft)
180180
return 0;
181181

182182
out:
183+
if (err == -E_NTFS_CORRUPT) {
184+
ntfs_err(sbi->sb, "mft corrupted");
185+
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
186+
err = -EINVAL;
187+
}
188+
183189
return err;
184190
}
185191

0 commit comments

Comments
 (0)