Skip to content

Commit 33e7070

Browse files
fs/ntfs3: Add ability to format new mft records with bigger/smaller header
Just define in ntfs.h #define MFTRECORD_FIXUP_OFFSET MFTRECORD_FIXUP_OFFSET_1 or #define MFTRECORD_FIXUP_OFFSET MFTRECORD_FIXUP_OFFSET_3 Signed-off-by: Konstantin Komarov <[email protected]>
1 parent a81f47c commit 33e7070

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

fs/ntfs3/ntfs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ struct MFT_REC {
288288

289289
#define MFTRECORD_FIXUP_OFFSET_1 offsetof(struct MFT_REC, res)
290290
#define MFTRECORD_FIXUP_OFFSET_3 offsetof(struct MFT_REC, fixups)
291+
/*
292+
* define MFTRECORD_FIXUP_OFFSET as MFTRECORD_FIXUP_OFFSET_3 (0x30)
293+
* to format new mft records with bigger header (as current ntfs.sys does)
294+
*
295+
* define MFTRECORD_FIXUP_OFFSET as MFTRECORD_FIXUP_OFFSET_1 (0x2A)
296+
* to format new mft records with smaller header (as old ntfs.sys did)
297+
* Both variants are valid.
298+
*/
299+
#define MFTRECORD_FIXUP_OFFSET MFTRECORD_FIXUP_OFFSET_1
291300

292301
static_assert(MFTRECORD_FIXUP_OFFSET_1 == 0x2A);
293302
static_assert(MFTRECORD_FIXUP_OFFSET_3 == 0x30);

fs/ntfs3/record.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ int mi_format_new(struct mft_inode *mi, struct ntfs_sb_info *sbi, CLST rno,
388388

389389
rec->seq = cpu_to_le16(seq);
390390
rec->flags = RECORD_FLAG_IN_USE | flags;
391+
if (MFTRECORD_FIXUP_OFFSET == MFTRECORD_FIXUP_OFFSET_3)
392+
rec->mft_record = cpu_to_le32(rno);
391393

392394
mi->dirty = true;
393395

fs/ntfs3/super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
867867
}
868868

869869
sbi->max_bytes_per_attr =
870-
record_size - ALIGN(MFTRECORD_FIXUP_OFFSET_1, 8) -
870+
record_size - ALIGN(MFTRECORD_FIXUP_OFFSET, 8) -
871871
ALIGN(((record_size >> SECTOR_SHIFT) * sizeof(short)), 8) -
872872
ALIGN(sizeof(enum ATTR_TYPE), 8);
873873

@@ -909,10 +909,10 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
909909

910910
sbi->new_rec = rec;
911911
rec->rhdr.sign = NTFS_FILE_SIGNATURE;
912-
rec->rhdr.fix_off = cpu_to_le16(MFTRECORD_FIXUP_OFFSET_1);
912+
rec->rhdr.fix_off = cpu_to_le16(MFTRECORD_FIXUP_OFFSET);
913913
fn = (sbi->record_size >> SECTOR_SHIFT) + 1;
914914
rec->rhdr.fix_num = cpu_to_le16(fn);
915-
ao = ALIGN(MFTRECORD_FIXUP_OFFSET_1 + sizeof(short) * fn, 8);
915+
ao = ALIGN(MFTRECORD_FIXUP_OFFSET + sizeof(short) * fn, 8);
916916
rec->attr_off = cpu_to_le16(ao);
917917
rec->used = cpu_to_le32(ao + ALIGN(sizeof(enum ATTR_TYPE), 8));
918918
rec->total = cpu_to_le32(sbi->record_size);

0 commit comments

Comments
 (0)