From nobody Wed Feb 11 16:10:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED4B6C77B73 for ; Mon, 8 May 2023 12:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234800AbjEHMjm (ORCPT ); Mon, 8 May 2023 08:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234426AbjEHMjg (ORCPT ); Mon, 8 May 2023 08:39:36 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D647DC41; Mon, 8 May 2023 05:39:20 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 51A9A21C3; Mon, 8 May 2023 12:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549272; bh=RZn6MEBLEPB8PODbTWpyKrutKazvJ93u3sSJUo2QDe0=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=J8R8cYIvFDJzrpNRE3G922qcYFnnI/bBOt8ad0u0N5q6Er9X6MnYLf7IE68IgRSGr Cq0289oRYMayQVh4ydPTBa2Qt13pQMsi88iGtZZzOCwK2xRbpSrg8q3xKdZZdanJ5+ bxFPnNDaGTF7QL2IBC2zfx2Q/H/bNWwDos1xmuuY= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 017652191; Mon, 8 May 2023 12:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549559; bh=RZn6MEBLEPB8PODbTWpyKrutKazvJ93u3sSJUo2QDe0=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=LrMJkh4GqzhuNnEemwuNCNXOfSOiHzgcWJI5IDQnK+hU1RVOjLaFxFSFe/rwqSK1e GEMmkGr8V+GZb5edstNj+eeqb45lPijVKaqK/s2sWD+E0MOOXZtLB4hnD3upKqzdR8 mKk7xAzkrW1WThUpFmZrffB4C/F6/rsqJGr/42/w= Received: from [192.168.211.146] (192.168.211.146) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 8 May 2023 15:39:17 +0300 Message-ID: <39d06f0d-f30d-c7c7-39e6-e4a566e6d5f4@paragon-software.com> Date: Mon, 8 May 2023 16:39:17 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: [PATCH 08/10] fs/ntfs3: Add ability to format new mft records with bigger/smaller header Content-Language: en-US From: Konstantin Komarov To: CC: Linux Kernel Mailing List , References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.146] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just define in ntfs.h =C2=A0=C2=A0 =C2=A0#define MFTRECORD_FIXUP_OFFSET=C2=A0 MFTRECORD_FIXUP_OF= FSET_1 or =C2=A0=C2=A0 =C2=A0#define MFTRECORD_FIXUP_OFFSET=C2=A0 MFTRECORD_FIXUP_OF= FSET_3 Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/ntfs.h=C2=A0=C2=A0 | 9 +++++++++ =C2=A0fs/ntfs3/record.c | 2 ++ =C2=A0fs/ntfs3/super.c=C2=A0 | 6 +++--- =C2=A03 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 3ec2eaf31996..98b76d1b09e7 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -288,6 +288,15 @@ struct MFT_REC { =C2=A0#define MFTRECORD_FIXUP_OFFSET_1 offsetof(struct MFT_REC, res) =C2=A0#define MFTRECORD_FIXUP_OFFSET_3 offsetof(struct MFT_REC, fixups) +/* + * define MFTRECORD_FIXUP_OFFSET as MFTRECORD_FIXUP_OFFSET_3 (0x30) + * to format new mft records with bigger header (as current ntfs.sys does) + * + * define MFTRECORD_FIXUP_OFFSET as MFTRECORD_FIXUP_OFFSET_1 (0x2A) + * to format new mft records with smaller header (as old ntfs.sys did) + * Both variants are valid. + */ +#define MFTRECORD_FIXUP_OFFSET=C2=A0 MFTRECORD_FIXUP_OFFSET_1 =C2=A0static_assert(MFTRECORD_FIXUP_OFFSET_1 =3D=3D 0x2A); =C2=A0static_assert(MFTRECORD_FIXUP_OFFSET_3 =3D=3D 0x30); diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index e73ca2df42eb..c12ebffc94da 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -388,6 +388,8 @@ int mi_format_new(struct mft_inode *mi, struct=20 ntfs_sb_info *sbi, CLST rno, =C2=A0=C2=A0=C2=A0 =C2=A0rec->seq =3D cpu_to_le16(seq); =C2=A0=C2=A0=C2=A0 =C2=A0rec->flags =3D RECORD_FLAG_IN_USE | flags; +=C2=A0=C2=A0 =C2=A0if (MFTRECORD_FIXUP_OFFSET =3D=3D MFTRECORD_FIXUP_OFFSE= T_3) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0rec->mft_record =3D cpu_to_le32(rno); =C2=A0=C2=A0=C2=A0 =C2=A0mi->dirty =3D true; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 12019bfe1325..7ab0a79c7d84 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -867,7 +867,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0sbi->max_bytes_per_attr =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0record_size - ALIGN(MFTRECORD_FIXUP_= OFFSET_1, 8) - +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0record_size - ALIGN(MFTRECORD_FIXUP_= OFFSET, 8) - =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ALIGN(((record_size >> SECTOR_= SHIFT) * sizeof(short)), 8) - =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ALIGN(sizeof(enum ATTR_TYPE), = 8); @@ -909,10 +909,10 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0sbi->new_rec =3D rec; =C2=A0=C2=A0=C2=A0 =C2=A0rec->rhdr.sign =3D NTFS_FILE_SIGNATURE; -=C2=A0=C2=A0 =C2=A0rec->rhdr.fix_off =3D cpu_to_le16(MFTRECORD_FIXUP_OFFSE= T_1); +=C2=A0=C2=A0 =C2=A0rec->rhdr.fix_off =3D cpu_to_le16(MFTRECORD_FIXUP_OFFSE= T); =C2=A0=C2=A0=C2=A0 =C2=A0fn =3D (sbi->record_size >> SECTOR_SHIFT) + 1; =C2=A0=C2=A0=C2=A0 =C2=A0rec->rhdr.fix_num =3D cpu_to_le16(fn); -=C2=A0=C2=A0 =C2=A0ao =3D ALIGN(MFTRECORD_FIXUP_OFFSET_1 + sizeof(short) *= fn, 8); +=C2=A0=C2=A0 =C2=A0ao =3D ALIGN(MFTRECORD_FIXUP_OFFSET + sizeof(short) * f= n, 8); =C2=A0=C2=A0=C2=A0 =C2=A0rec->attr_off =3D cpu_to_le16(ao); =C2=A0=C2=A0=C2=A0 =C2=A0rec->used =3D cpu_to_le32(ao + ALIGN(sizeof(enum = ATTR_TYPE), 8)); =C2=A0=C2=A0=C2=A0 =C2=A0rec->total =3D cpu_to_le32(sbi->record_size); --=20 2.34.1