From nobody Wed Feb 11 14:44:14 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 2083CC77B75 for ; Mon, 8 May 2023 12:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234218AbjEHMg0 (ORCPT ); Mon, 8 May 2023 08:36:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233918AbjEHMgY (ORCPT ); Mon, 8 May 2023 08:36:24 -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 5199E37E57; Mon, 8 May 2023 05:36:06 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id B025E21C2; Mon, 8 May 2023 12:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549077; bh=8YnqHs6viNhkNZ9+6wZf88ELrlrGUvvnL2bs2/5eVko=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=HCrARVnRdX+b90e0/I9bBzR4l5wjGoEeWjE4hBXgbuvurr62vl2f/r6LIYWMZ9AM5 QhFavzGfh8C8JjEFbZcixiMiI+gpMEkj1fvRdg0N7YknMtwK9/HnLZ8f+Ov7Y4/SFG MacEJQfAmzJeUxlGld1jYnzRwsoWN56Sa4oduakI= 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:36:03 +0300 Message-ID: Date: Mon, 8 May 2023 16:36:03 +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 01/10] fs/ntfs3: Correct checking while generating attr_list 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 Correct slightly previous commit: Enhance sanity check while generating attr_list Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/frecord.c | 25 ++++++++++--------------- =C2=A01 file changed, 10 insertions(+), 15 deletions(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 50214b77c6a3..66f3341c65ec 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -813,10 +813,8 @@ int ni_create_attr_list(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0 * Looks like one record_size is always enough. =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0=C2=A0=C2=A0 =C2=A0le =3D kmalloc(al_aligned(rs), GFP_NOFS); -=C2=A0=C2=A0 =C2=A0if (!le) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -ENOMEM; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; -=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0if (!le) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; =C2=A0=C2=A0=C2=A0 =C2=A0mi_get_ref(&ni->mi, &le->ref); =C2=A0=C2=A0=C2=A0 =C2=A0ni->attr_list.le =3D le; @@ -865,14 +863,14 @@ int ni_create_attr_list(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (to_free > free_b) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EI= NVAL; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0/* Allocate child MFT. */ =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_look_free_mft(sbi, &rno, is_mft, ni,= &mi); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; =C2=A0=C2=A0=C2=A0 =C2=A0/* Call mi_remove_attr() in reverse order to keep= pointers=20 'arr_move' valid. */ @@ -884,7 +882,7 @@ int ni_create_attr_list(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D mi_insert_attr(mi, b-= >type, Add2Ptr(b, name_off), =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 b->name_len, asize, name_off); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!attr) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mi_get_ref(mi, &le_b[nb]->ref); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0le_b[nb]->id =3D attr->id; @@ -895,19 +893,19 @@ int ni_create_attr_list(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Remove from primary record.= */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!mi_remove_attr(NULL, &ni-= >mi, b)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (to_free <=3D asize) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0to_free -=3D asize; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!nb) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D mi_insert_attr(&ni->mi, ATTR_LIST, NULL,= 0, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 lsize + SIZEOF_RESIDENT, SIZEOF_RESIDENT); =C2=A0=C2=A0=C2=A0 =C2=A0if (!attr) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0attr->non_res =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0attr->flags =3D 0; @@ -921,16 +919,13 @@ int ni_create_attr_list(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0ni->attr_list.dirty =3D false; =C2=A0=C2=A0=C2=A0 =C2=A0mark_inode_dirty(&ni->vfs_inode); -=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0return 0; -out1: +out: =C2=A0=C2=A0=C2=A0 =C2=A0kfree(ni->attr_list.le); =C2=A0=C2=A0=C2=A0 =C2=A0ni->attr_list.le =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0ni->attr_list.size =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0return err; - -out: -=C2=A0=C2=A0 =C2=A0return 0; =C2=A0} =C2=A0/* --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 CE852C77B75 for ; Mon, 8 May 2023 12:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234037AbjEHMg4 (ORCPT ); Mon, 8 May 2023 08:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233918AbjEHMgo (ORCPT ); Mon, 8 May 2023 08:36:44 -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 4986D391BE; Mon, 8 May 2023 05:36:39 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 8DF8E21C3; Mon, 8 May 2023 12:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549110; bh=h5cbTykc9cuI68jfwGBg6SVUQfDSQ4DeVKUgsn+zaao=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=IrRYPMph4pWjLaHDypU5B9Y9R8yzwcToPVA1MQT0qienyTf8C7Jc/lyXDBRspjxm3 xBjgaKNCbXDoM4ITCj4bNnfrFkSulkmJlrN1KvGcO16aiOWNnJ/YQhrWutKP5hdwFd f+Js0zqSZmcLd9I6q7WK31VNpe0aZbd0Rtd1hXRM= 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 3F15B2191; Mon, 8 May 2023 12:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549397; bh=h5cbTykc9cuI68jfwGBg6SVUQfDSQ4DeVKUgsn+zaao=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=hm7oaKhjn6FnPfk/UtGsGFWrGvBA3FZap6DH8mF8yNUveTW8HtyndqQPBPLq0ejLy WPcBcwjAY7MnJdaxo42FUMZr12HEfrb37EbjxJ54u171P56ki/U8JhYVPTp1BxIE9j NoRKwmUiiObDkS0+UUxS6B5laYvBTH6CFeDXKSLc= 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:36:36 +0300 Message-ID: Date: Mon, 8 May 2023 16:36:36 +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 02/10] fs/ntfs3: Fix ntfs_atomic_open 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 This fixes xfstest 633/696. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/namei.c | 15 +++------------ =C2=A01 file changed, 3 insertions(+), 12 deletions(-) diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 9736b1e4a0f6..343bce6da58a 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -422,19 +422,10 @@ static int ntfs_atomic_open(struct inode *dir,=20 struct dentry *dentry, =C2=A0=C2=A0=C2=A0 =C2=A0 * fnd contains tree's path to insert to. =C2=A0=C2=A0=C2=A0 =C2=A0 * If fnd is not NULL then dir is locked. =C2=A0=C2=A0=C2=A0 =C2=A0 */ - -=C2=A0=C2=A0 =C2=A0/* -=C2=A0=C2=A0 =C2=A0 * Unfortunately I don't know how to get here correct '= struct=20 nameidata *nd' -=C2=A0=C2=A0 =C2=A0 * or 'struct mnt_idmap *idmap'. -=C2=A0=C2=A0 =C2=A0 * See atomic_open in fs/namei.c. -=C2=A0=C2=A0 =C2=A0 * This is why xfstest/633 failed. -=C2=A0=C2=A0 =C2=A0 * Looks like ntfs_atomic_open must accept 'struct mnt_= idmap=20 *idmap' as argument. -=C2=A0=C2=A0 =C2=A0 */ - -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(&nop_mnt_idmap, dir, dentry= , uni, mode, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, fnd); +=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(mnt_idmap(file->f_path.mnt)= , dir, dentry,=20 uni, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 mode, 0, NULL, 0, fnd); =C2=A0=C2=A0=C2=A0 =C2=A0err =3D IS_ERR(inode) ? PTR_ERR(inode) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 finish_open(file, dentry, ntfs_file_open); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 finish_open(file, dentry, ntfs_file_open); =C2=A0=C2=A0=C2=A0 =C2=A0dput(d); =C2=A0out2: --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 5831DC77B75 for ; Mon, 8 May 2023 12:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234225AbjEHMhJ (ORCPT ); Mon, 8 May 2023 08:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234236AbjEHMhE (ORCPT ); Mon, 8 May 2023 08:37:04 -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 7B9C83702A; Mon, 8 May 2023 05:37:02 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 9754021C3; Mon, 8 May 2023 12:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549133; bh=Sg0UiYsarTe92ydsTCL9y6XxwHeH2AmXLAFXljDEI6s=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=tPo/NAlD9PThmgQqltZ6Hqx/EHFIp4JWKcj24vVACX2ClRtdQbjzGRHtj/ryuV0HL LvA3Q1en1sRJ20sJJyniCi8J3Hg6rAJYLqagxiMMmU1y0KR7pJOLJpMf4paZEvzMfI rYk/6uFsdXQFzfAF4V5qo0WLfJ2oxezIFRaKxC8I= 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:36:59 +0300 Message-ID: Date: Mon, 8 May 2023 16:36:59 +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 03/10] fs/ntfs3: Mark ntfs dirty when on-disk struct is corrupted 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 Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fsntfs.c=C2=A0 | 2 +- =C2=A0fs/ntfs3/index.c=C2=A0=C2=A0 | 6 ++++++ =C2=A0fs/ntfs3/ntfs_fs.h | 2 ++ =C2=A0fs/ntfs3/record.c=C2=A0 | 6 ++++++ =C2=A04 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 28cc421102e5..21567e58265c 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -178,7 +178,7 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER=20 *rhdr, size_t bytes, =C2=A0=C2=A0=C2=A0 =C2=A0/* Check errors. */ =C2=A0=C2=A0=C2=A0 =C2=A0if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_= SIZE || !fn-- || =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 fn * SECTOR_SIZE > bytes) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; /* Native chkntfs re= turns ok! */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -E_NTFS_CORRUPT; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0/* Get fixup pointer. */ diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 0a48d2d67219..b40da258e684 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1113,6 +1113,12 @@ int indx_read(struct ntfs_index *indx, struct=20 ntfs_inode *ni, CLST vbn, =C2=A0=C2=A0=C2=A0 =C2=A0*node =3D in; =C2=A0out: +=C2=A0=C2=A0 =C2=A0if (err =3D=3D -E_NTFS_CORRUPT) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_inode_err(&ni->vfs_inode, "dire= ctory corrupted"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_set_state(ni->mi.sbi, NTFS_DIRT= Y_ERROR); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; +=C2=A0=C2=A0 =C2=A0} + =C2=A0=C2=A0=C2=A0 =C2=A0if (ib !=3D in->index) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kfree(ib); diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index eb01f7e76479..2e4be773728d 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -53,6 +53,8 @@ enum utf16_endian; =C2=A0#define E_NTFS_NONRESIDENT=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0556 =C2=A0/* NTFS specific error code about punch hole. */ =C2=A0#define E_NTFS_NOTALIGNED=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0557 +/* NTFS specific error code when on-disk struct is corrupted. */ +#define E_NTFS_CORRUPT=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0558 =C2=A0/* sbi->flags */ diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 7060f784c2d7..7974ca35a15c 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -180,6 +180,12 @@ int mi_read(struct mft_inode *mi, bool is_mft) =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0out: +=C2=A0=C2=A0 =C2=A0if (err =3D=3D -E_NTFS_CORRUPT) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sbi->sb, "mft corrupted"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_set_state(sbi, NTFS_DIRTY_ERROR= ); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; +=C2=A0=C2=A0 =C2=A0} + =C2=A0=C2=A0=C2=A0 =C2=A0return err; =C2=A0} --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 E95C8C77B75 for ; Mon, 8 May 2023 12:37:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234212AbjEHMhs (ORCPT ); Mon, 8 May 2023 08:37:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbjEHMhp (ORCPT ); Mon, 8 May 2023 08:37:45 -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 6881B1FCF; Mon, 8 May 2023 05:37:43 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id D959E21C3; Mon, 8 May 2023 12:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549174; bh=eUdOqgEPzuhDm6m+TY/pQxrmqpwlAoPXqQwZwQwVKkY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=YxxnbcMTWh4mPw9jfZnz2qtaaE5AKm89YFCKlmka7B2ABUXDCnuRFM+YZRqEYPRRA cjSDow7lrBVbtKBfUaGg6r9QQgVja4CER6+m7RwDrYrb6lc3E8YQmp7oDGtTUe4JdN EbncVRwCMDXO4mpXEVRPLmhqOayU70+JZ3EPAIyQ= 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 861E12191; Mon, 8 May 2023 12:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549461; bh=eUdOqgEPzuhDm6m+TY/pQxrmqpwlAoPXqQwZwQwVKkY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=HgClNu2/GVnhUC7bcq6YJjoYakmdbi9vxn15wOUXoU35l5qCHFF2DrDNHy/GYrLmW OHodTeo94tL3x8cqCKd5b9Zy3DB3h3RjybM69L7G6hC69mVW0rHEJxenUGWPCC5CjI Z6hXSAe5sajP2XzLMXRUZd3+9V4pu4NSS5C2i2xA= 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:37:41 +0300 Message-ID: <24e18e44-b97b-b896-f1b0-0c7e58f23a1c@paragon-software.com> Date: Mon, 8 May 2023 16:37:40 +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 04/10] fs/ntfs3: Alternative boot if primary boot is corrupted 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 Some code refactoring added also. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/super.c | 98 +++++++++++++++++++++++++++++++++++-----------= -- =C2=A01 file changed, 71 insertions(+), 27 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 5158dd31fd97..ecf899d571d8 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -724,6 +724,8 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REC *rec; =C2=A0=C2=A0=C2=A0 =C2=A0u16 fn, ao; =C2=A0=C2=A0=C2=A0 =C2=A0u8 cluster_bits; +=C2=A0=C2=A0 =C2=A0u32 boot_off =3D 0; +=C2=A0=C2=A0 =C2=A0const char *hint =3D "Primary boot"; =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.blocks =3D dev_size >> PAGE_SHIFT; @@ -731,11 +733,12 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0if (!bh) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EIO; +check_boot: =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; -=C2=A0=C2=A0 =C2=A0boot =3D (struct NTFS_BOOT *)bh->b_data; +=C2=A0=C2=A0 =C2=A0boot =3D (struct NTFS_BOOT *)Add2Ptr(bh->b_data, boot_o= ff); =C2=A0=C2=A0=C2=A0 =C2=A0if (memcmp(boot->system_id, "NTFS=C2=A0=C2=A0=C2= =A0 ", sizeof("NTFS=C2=A0=C2=A0=C2=A0 ") - 1)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Boot's signature is no= t NTFS."); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "%s signature is not NT= FS.", hint); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -748,14 +751,16 @@ 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=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 boot->bytes_per_sector[0]; =C2=A0=C2=A0=C2=A0 =C2=A0if (boot_sector_size < SECTOR_SIZE || =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 !is_power_of_2(boot_sector_siz= e)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Invalid bytes per sect= or %u.", boot_sector_size); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "%s: invalid bytes per = sector %u.", hint, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 boot_sector_size= ); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0/* cluster size: 512, 1K, 2K, 4K, ... 2M */ =C2=A0=C2=A0=C2=A0 =C2=A0sct_per_clst =3D true_sectors_per_clst(boot); =C2=A0=C2=A0=C2=A0 =C2=A0if ((int)sct_per_clst < 0 || !is_power_of_2(sct_p= er_clst)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Invalid sectors per cl= uster %u.", sct_per_clst); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "%s: invalid sectors pe= r cluster %u.", hint, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sct_per_clst); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -771,8 +776,8 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0if (mlcn * sct_per_clst >=3D sectors || mlcn2 * s= ct_per_clst >=3D=20 sectors) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err( =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sb, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"Start of MFT 0x%= llx (0x%llx) is out of volume 0x%llx.", -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mlcn, mlcn2, sect= ors); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"%s: start of MFT= 0x%llx (0x%llx) is out of volume 0x%llx.", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hint, mlcn, mlcn2= , sectors); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -784,7 +789,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0/* Check MFT record size. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (record_size < SECTOR_SIZE || !is_power_of_2(r= ecord_size)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Invalid bytes per MFT = record %u (%d).", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "%s: invalid bytes per = MFT record %u (%d).", hint, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 record_siz= e, boot->record_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -801,13 +806,13 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0/* Check index record size. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (sbi->index_size < SECTOR_SIZE ||=20 !is_power_of_2(sbi->index_size)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Invalid bytes per inde= x %u(%d).", sbi->index_size, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 boot->index_size= ); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "%s: invalid bytes per = index %u(%d).", hint, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sbi->index_size,= boot->index_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0if (sbi->index_size > MAXIMUM_BYTES_PER_INDEX) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Unsupported bytes per = index %u.", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "%s: unsupported bytes = per index %u.", hint, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sbi->index= _size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -834,7 +839,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0/* Compare boot's cluster and sector. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (sbi->cluster_size < boot_sector_size) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Invalid bytes per clus= ter (%u).", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "%s: invalid bytes per = cluster (%u).", hint, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sbi->clust= er_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -930,7 +935,46 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0err =3D 0; +=C2=A0=C2=A0 =C2=A0if (bh->b_blocknr && !sb_rdonly(sb)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* +=C2=A0=C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 * Alternative boot is ok but prima= ry is not ok. +=C2=A0=C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 * Update primary boot. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct buffer_head *bh0 =3D sb_getbl= k(sb, 0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (bh0) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (buffer_locked= (bh0)) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0__wait_on_buffer(bh0); + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0lock_buffer(bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(bh0->b_dat= a, boot, sizeof(*boot)); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0set_buffer_uptoda= te(bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mark_buffer_dirty= (bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unlock_buffer(bh0= ); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!sync_dirty_b= uffer(bh0)) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0ntfs_warn(sb, "primary boot is updated"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0put_bh(bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0} + =C2=A0out: +=C2=A0=C2=A0 =C2=A0if (err =3D=3D -EINVAL && !bh->b_blocknr && dev_size > = PAGE_SHIFT) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 block_size =3D min_t(u32, sector= _size, PAGE_SIZE); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u64 lbo =3D dev_size - sizeof(*boot); + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* +=C2=A0=C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 * Try alternative boot (last secto= r) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0brelse(bh); + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sb_set_blocksize(sb, block_size); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bh =3D ntfs_bread(sb, lbo >> blksize= _bits(block_size)); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!bh) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0boot_off =3D lbo & (block_size - 1); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hint =3D "Alternative boot"; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto check_boot; +=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0brelse(bh); =C2=A0=C2=A0=C2=A0 =C2=A0return err; @@ -955,6 +999,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_DEF_ENTRY *t; =C2=A0=C2=A0=C2=A0 =C2=A0u16 *shared; =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REF ref; +=C2=A0=C2=A0 =C2=A0bool ro =3D sb_rdonly(sb); =C2=A0=C2=A0=C2=A0 =C2=A0ref.high =3D 0; @@ -1035,6 +1080,10 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.minor_ver =3D info->minor_ver; =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.flags =3D info->flags; =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.ni =3D ni; +=C2=A0=C2=A0 =C2=A0if (info->flags & VOLUME_FLAG_DIRTY) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.real_dirty =3D true; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_info(sb, "It is recommened to u= se chkdsk."); +=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0/* Load $MFTMirr to estimate recs_mirr. */ =C2=A0=C2=A0=C2=A0 =C2=A0ref.low =3D cpu_to_le32(MFT_REC_MIRR); @@ -1069,21 +1118,16 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0iput(inode); -=C2=A0=C2=A0 =C2=A0if (sbi->flags & NTFS_FLAGS_NEED_REPLAY) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!sb_rdonly(sb)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn(sb, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 "failed to replay log file. Can't mount rw!"); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0} else if (sbi->volume.flags & VOLUME_FLAG_DIRTY) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!sb_rdonly(sb) && !options->forc= e) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn( -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0sb, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0"volume is dirty and \"force\" flag is not set!"); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0if ((sbi->flags & NTFS_FLAGS_NEED_REPLAY) && !ro) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn(sb, "failed to replay log = file. Can't mount rw!"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0if ((sbi->volume.flags & VOLUME_FLAG_DIRTY) && !ro &&=20 !options->force) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn(sb, "volume is dirty and \= "force\" flag is not set!"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0/* Load $MFT. */ @@ -1173,7 +1217,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bad_len +=3D len; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bad_frags +=3D 1; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (sb_rdonly(sb)) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ro) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0continue; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (wnd_set_used_safe(&sbi->us= ed.bitmap, lcn, len, &tt) || tt) { --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 A4EB9C7EE23 for ; Mon, 8 May 2023 12:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234240AbjEHMiT (ORCPT ); Mon, 8 May 2023 08:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234261AbjEHMiQ (ORCPT ); Mon, 8 May 2023 08:38:16 -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 9B318DC41; Mon, 8 May 2023 05:38:12 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 0BB2221C3; Mon, 8 May 2023 12:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549204; bh=ozLaxeqLvZ1koAu7iHKobUtKETfbqwTAtHlsxw0uvGA=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=Tuy+0aG7q59X0miTQqawIcroIrb0MO6DRbdAf33UgW6iBCm2NMR7pLt3UIdczne9/ bYF0sZRpzlk6eux3NkIBH9aFhnv+4IDSafaJ7AULTAArckZcq2JFYaCPiootiaRXRs 7SrXmHgkoo6zk0XSUM6pKAlIwg3+ColKFUQXF2V0= 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:38:10 +0300 Message-ID: <45f18870-379f-fa88-382c-5600e31d33a6@paragon-software.com> Date: Mon, 8 May 2023 16:38:09 +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 05/10] fs/ntfs3: Do not update primary boot in ntfs_init_from_boot() 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 'cause it may be faked boot. Let ntfs to be mounted and update boot later. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/super.c | 58 ++++++++++++++++++++++++++++++++--------------= -- =C2=A01 file changed, 39 insertions(+), 19 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index ecf899d571d8..2b48b45238ea 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -711,9 +711,16 @@ static u32 true_sectors_per_clst(const struct=20 NTFS_BOOT *boot) =C2=A0/* =C2=A0 * ntfs_init_from_boot - Init internal info from on-disk boot sector. + * + * NTFS mount begins from boot - special formatted 512 bytes. + * There are two boots: the first and the last 512 bytes of volume. + * The content of boot is not changed during ntfs life. + * + * NOTE: ntfs.sys checks only first (primary) boot. + * chkdsk checks both boots. =C2=A0 */ =C2=A0static int ntfs_init_from_boot(struct super_block *sb, u32 sector_si= ze, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 u64 dev_size) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 u64 dev_size, struct NTFS_BOOT **boot2) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D sb->s_fs_info; =C2=A0=C2=A0=C2=A0 =C2=A0int err; @@ -937,23 +944,11 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0if (bh->b_blocknr && !sb_rdonly(sb)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* -=C2=A0=C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 * Alternative boot is ok but prima= ry is not ok. -=C2=A0=C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 * Update primary boot. -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 */ -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct buffer_head *bh0 =3D sb_getbl= k(sb, 0); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (bh0) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (buffer_locked= (bh0)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0__wait_on_buffer(bh0); - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0lock_buffer(bh0); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(bh0->b_dat= a, boot, sizeof(*boot)); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0set_buffer_uptoda= te(bh0); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mark_buffer_dirty= (bh0); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unlock_buffer(bh0= ); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!sync_dirty_b= uffer(bh0)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0ntfs_warn(sb, "primary boot is updated"); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0put_bh(bh0); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Alternative boot is ok but p= rimary is not ok. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Do not update primary boot h= ere 'cause it may be faked boot. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Let ntfs to be mounted and u= pdate boot later. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0*boot2 =3D kmemdup(boot, sizeof(*boo= t), GFP_NOFS | __GFP_NOWARN); =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0out: @@ -1000,6 +995,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0u16 *shared; =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REF ref; =C2=A0=C2=A0=C2=A0 =C2=A0bool ro =3D sb_rdonly(sb); +=C2=A0=C2=A0 =C2=A0struct NTFS_BOOT *boot2 =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0ref.high =3D 0; @@ -1030,7 +1026,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0/* Parse boot. */ =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_init_from_boot(sb, bdev_logical_bloc= k_size(bdev), -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 bdev_nr_bytes(bdev)); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 bdev_nr_bytes(bdev), &boot2); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; @@ -1412,6 +1408,29 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_out; =C2=A0=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0if (boot2) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Alternative boot is ok but p= rimary is not ok. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Volume is recognized as NTFS= . Update primary boot. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct buffer_head *bh0 =3D sb_getbl= k(sb, 0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (bh0) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (buffer_locked= (bh0)) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0__wait_on_buffer(bh0); + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0lock_buffer(bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(bh0->b_dat= a, boot2, sizeof(*boot2)); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0set_buffer_uptoda= te(bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mark_buffer_dirty= (bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unlock_buffer(bh0= ); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!sync_dirty_b= uffer(bh0)) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0ntfs_warn(sb, "primary boot is updated"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0put_bh(bh0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kfree(boot2); +=C2=A0=C2=A0 =C2=A0} + =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0put_inode_out: @@ -1424,6 +1443,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0put_mount_options(sbi->options); =C2=A0=C2=A0=C2=A0 =C2=A0put_ntfs(sbi); =C2=A0=C2=A0=C2=A0 =C2=A0sb->s_fs_info =3D NULL; +=C2=A0=C2=A0 =C2=A0kfree(boot2); =C2=A0=C2=A0=C2=A0 =C2=A0return err; =C2=A0} --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 B25CAC77B73 for ; Mon, 8 May 2023 12:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234185AbjEHMil (ORCPT ); Mon, 8 May 2023 08:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234365AbjEHMih (ORCPT ); Mon, 8 May 2023 08:38:37 -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 DD3023847D; Mon, 8 May 2023 05:38:28 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 321E621C3; Mon, 8 May 2023 12:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549220; bh=m8J2DhIaj3TzmKf7gCBnUyygD/mI1P53ydepgnojJwg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=ZV35sZfUcJxuTGkegN09yLdiMGkSMbNKfRVhu2v/+HjHcYNR79o1udEVeqZcAycz8 Yb1lyiyy2IfndhzuvBx4eKWQC4XqXUYRfJcVU0BOmZflN7SxluB5U1p2oiNrd2DsD3 y2k20MYorcZ3RPW/nY8O6U868xzppfR2aUa33A/c= 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 D5EA32191; Mon, 8 May 2023 12:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549506; bh=m8J2DhIaj3TzmKf7gCBnUyygD/mI1P53ydepgnojJwg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=nx46qKAPqKXTjS1lOLPI8rVmduNnSNAYmelRkzYOKviVzieW7hOUPqHv0NVD3L7K/ 2Fo+5B7D/iywEEWQ+pIENcalq6ZcVx+Lb/sdZJubJ/eX1GNdEZryFm8YhIRd0tHG3R MBbkTJGyC84JblzCfBXdTSSKS1iDyAIsN3adP9ck= 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:38:26 +0300 Message-ID: <516867bf-9ff1-f232-82d9-583e96de7335@paragon-software.com> Date: Mon, 8 May 2023 16:38:25 +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 06/10] fs/ntfs3: Code formatting 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 clang-format-15 was used to format code according kernel's .clang-format. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrib.c=C2=A0 |=C2=A0 2 +- =C2=A0fs/ntfs3/bitmap.c=C2=A0 | 10 +++++----- =C2=A0fs/ntfs3/file.c=C2=A0=C2=A0=C2=A0 |=C2=A0 4 ++-- =C2=A0fs/ntfs3/frecord.c | 16 ++++++++++------ =C2=A0fs/ntfs3/fslog.c=C2=A0=C2=A0 | 40 ++++++++++++++++++++--------------= ------ =C2=A0fs/ntfs3/fsntfs.c=C2=A0 |=C2=A0 2 +- =C2=A0fs/ntfs3/index.c=C2=A0=C2=A0 | 14 +++++++------- =C2=A0fs/ntfs3/inode.c=C2=A0=C2=A0 | 18 +++++++++--------- =C2=A0fs/ntfs3/lznt.c=C2=A0=C2=A0=C2=A0 |=C2=A0 6 +++--- =C2=A0fs/ntfs3/namei.c=C2=A0=C2=A0 | 16 ++++++++-------- =C2=A0fs/ntfs3/ntfs_fs.h | 10 +++++----- =C2=A0fs/ntfs3/run.c=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 4 ++-- =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0 | 17 ++++++++++++----- =C2=A0fs/ntfs3/xattr.c=C2=A0=C2=A0 | 16 +++++++--------- =C2=A014 files changed, 92 insertions(+), 83 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 0b8bc66377db..a9d82bbb4729 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -573,7 +573,7 @@ int attr_set_size(struct ntfs_inode *ni, enum=20 ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0sbi, run, vcn, lcn, to_allocate, &pre_alloc, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0is_mft ? ALLOCATE_MFT : ALLOCATE_DEF, &alen, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0is_mft ? 0 : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (sbi->record_siz= e - +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0 (sbi->record_size - =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 le32_to_cpu(rec->used) + 8) / =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 3 + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 1, diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index 9a6c6a09d70c..107e808e06ea 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -287,8 +287,8 @@ static void wnd_add_free_ext(struct wnd_bitmap *wnd,=20 size_t bit, size_t len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check bi= ts before 'bit'. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ib =3D wnd-= >zone_bit =3D=3D wnd->zone_end || =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bit < wnd->zone_end ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 0 : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 wnd->zone_end; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 0 : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 wnd->zone_end; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0while (bit = > ib && wnd_is_free_hlp(wnd, bit - 1, 1)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0bit -=3D 1; @@ -298,8 +298,8 @@ static void wnd_add_free_ext(struct wnd_bitmap *wnd,=20 size_t bit, size_t len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check bi= ts after 'end_in'. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ib =3D wnd-= >zone_bit =3D=3D wnd->zone_end || =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end_in > wnd->zone_bi= t ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 wnd->nbits : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 wnd->zone_bit; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 wnd->nbits : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 wnd->zone_bit; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0while (end_= in < ib && wnd_is_free_hlp(wnd, end_in, 1)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0end_in +=3D 1; @@ -418,7 +418,7 @@ static void wnd_remove_free_ext(struct wnd_bitmap=20 *wnd, size_t bit, size_t len) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0n3 =3D rb_first(&wnd->count_tr= ee); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0wnd->extent_max =3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0n3 ? rb_ent= ry(n3, struct e_node, count.node)->count.key : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 0; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 0; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return; =C2=A0=C2=A0=C2=A0 =C2=A0} diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index c4983e028d90..4c653945ef08 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -192,7 +192,7 @@ static int ntfs_zero_range(struct inode *inode, u64=20 vbo, u64 vbo_to) =C2=A0=C2=A0=C2=A0 =C2=A0for (; idx < idx_end; idx +=3D 1, from =3D 0) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0page_off =3D (loff_t)idx << PA= GE_SHIFT; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0to =3D (page_off + PAGE_SIZE) = > vbo_to ? (vbo_to - page_off) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 PAGE_SIZE; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 PAGE_SIZE; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0iblock =3D page_off >> inode->= i_blkbits; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0page =3D find_or_create_page(m= apping, idx, @@ -1052,7 +1052,7 @@ static ssize_t ntfs_file_write_iter(struct kiocb=20 *iocb, struct iov_iter *from) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0ret =3D is_compressed(ni) ? ntfs_compress_write(i= ocb, from) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0__generic_file_write_iter(iocb, from); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 __generic_file_write_iter(iocb, from); =C2=A0out: =C2=A0=C2=A0=C2=A0 =C2=A0inode_unlock(inode); diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 66f3341c65ec..4227e3f590a5 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -77,7 +77,7 @@ struct ATTR_STD_INFO *ni_std(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D mi_find_attr(&ni->mi, NULL, ATTR_STD, NU= LL, 0, NULL); =C2=A0=C2=A0=C2=A0 =C2=A0return attr ? resident_data_ex(attr, sizeof(struc= t ATTR_STD_INFO)) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 NULL; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NULL; =C2=A0} =C2=A0/* @@ -92,7 +92,7 @@ struct ATTR_STD_INFO5 *ni_std5(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D mi_find_attr(&ni->mi, NULL, ATTR_STD, NU= LL, 0, NULL); =C2=A0=C2=A0=C2=A0 =C2=A0return attr ? resident_data_ex(attr, sizeof(struc= t ATTR_STD_INFO5)) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 NULL; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NULL; =C2=A0} =C2=A0/* @@ -517,6 +517,9 @@ ni_ins_new_attr(struct ntfs_inode *ni, struct=20 mft_inode *mi, =C2=A0 */ =C2=A0static int ni_repack(struct ntfs_inode *ni) =C2=A0{ +#if 1 +=C2=A0=C2=A0 =C2=A0return 0; +#else =C2=A0=C2=A0=C2=A0 =C2=A0int err =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D ni->mi.sbi; =C2=A0=C2=A0=C2=A0 =C2=A0struct mft_inode *mi, *mi_p =3D NULL; @@ -639,6 +642,7 @@ static int ni_repack(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0run_close(&run); =C2=A0=C2=A0=C2=A0 =C2=A0return err; +#endif =C2=A0} =C2=A0/* @@ -1758,8 +1762,8 @@ int ni_new_attr_flags(struct ntfs_inode *ni, enum=20 FILE_ATTRIBUTE new_fa) =C2=A0=C2=A0=C2=A0 =C2=A0/* Resize nonresident empty attribute in-place on= ly. */ =C2=A0=C2=A0=C2=A0 =C2=A0new_asize =3D (new_aflags & (ATTR_FLAG_COMPRESSED= |=20 ATTR_FLAG_SPARSED)) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 (SIZEOF_NONRESIDENT_EX + 8) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 (SIZEOF_NONRESIDENT + 8); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 (SIZEOF_NONRESIDENT_EX + 8) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 (SIZEOF_NONRESIDENT + 8); =C2=A0=C2=A0=C2=A0 =C2=A0if (!mi_resize_attr(mi, attr, new_asize - le32_to= _cpu(attr->size))) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EOPNOTSUPP; @@ -3161,8 +3165,8 @@ static bool ni_update_parent(struct ntfs_inode=20 *ni, struct NTFS_DUP_INFO *dup, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__le64 vali= d_le; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dup->alloc_= size =3D is_attr_ext(attr) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->nres.tota= l_size : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->nres.allo= c_size; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 attr->nres.total_size : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 attr->nres.alloc_size; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dup->data_s= ize =3D attr->nres.data_size; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (new_val= id > data_size) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index 57762c5fe68b..12f28cdf5c83 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -828,8 +828,8 @@ static inline struct RESTART_TABLE=20 *extend_rsttbl(struct RESTART_TABLE *tbl, =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(rt + 1, tbl + 1, esize * used); =C2=A0=C2=A0=C2=A0 =C2=A0rt->free_goal =3D free_goal =3D=3D ~0u ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cpu_to_le32(~0u) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cpu_to_le32(sizeof(struct RESTART_TABLE) + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0cpu_to_le32(~0u) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0cpu_to_le32(sizeof(struct RESTART_TABLE) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 free_goal * esize); =C2=A0=C2=A0=C2=A0 =C2=A0if (tbl->first_free) { @@ -1090,8 +1090,8 @@ static inline u64 base_lsn(struct ntfs_log *log, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 << log->file_data= _bits) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 ((((is_log_record_end(h= dr) && =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= h_lsn <=3D le64_to_cpu(hdr->record_hdr.last_end_lsn)) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 le16_to_cpu(hdr->record_hdr.next_record_off) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 log->page_size) + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 le16_to_cpu(hdr->record_hdr.next_record_off) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 log->page_size) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 lsn) >> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 3); @@ -1299,8 +1299,8 @@ static void log_init_pg_hdr(struct ntfs_log *log,=20 u32 sys_page_size, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0log->clst_per_page =3D 1; =C2=A0=C2=A0=C2=A0 =C2=A0log->first_page =3D major_ver >=3D 2 ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A00x22 * page_size : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0((sys_page_size << 1) + (page_size << 1)); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 0x22 * page_size : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 ((sys_page_size << 1) + (page_size << 1)); =C2=A0=C2=A0=C2=A0 =C2=A0log->major_ver =3D major_ver; =C2=A0=C2=A0=C2=A0 =C2=A0log->minor_ver =3D minor_ver; =C2=A0} @@ -1513,8 +1513,8 @@ static u32 current_log_avail(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0 * If there is no oldest lsn then start at the fi= rst page of the file. =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0=C2=A0=C2=A0 =C2=A0oldest_off =3D (log->l_flags & NTFSLOG_NO_OLDEST_= LSN) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 log->first_page : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 (log->oldest_lsn_off & ~log->sys_page_mask); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 log->first_page : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (log->oldest_lsn_off & ~log->sys_page_mask); =C2=A0=C2=A0=C2=A0 =C2=A0/* =C2=A0=C2=A0=C2=A0 =C2=A0 * We will use the next log page offset to comput= e the next free page. @@ -1522,9 +1522,9 @@ static u32 current_log_avail(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0 * If we are at the first page then use the end o= f the file. =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0=C2=A0=C2=A0 =C2=A0next_free_off =3D (log->l_flags & NTFSLOG_REUSE_T= AIL) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 log->next_page + log->page_size : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0log->next_page + log->page_size : =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0log->next_p= age =3D=3D log->first_page ? log->l_size : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0 log->next_page; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 log->next_page; =C2=A0=C2=A0=C2=A0 =C2=A0/* If the two offsets are the same then there is = no available=20 space. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (oldest_off =3D=3D next_free_off) @@ -1535,8 +1535,8 @@ static u32 current_log_avail(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0=C2=A0=C2=A0 =C2=A0free_bytes =3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0oldest_off < next_free_off ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 log->total_avail_pages - (next_free_off - oldest_off) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 oldest_off - next_free_off; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0log->total_avail_= pages - (next_free_off - oldest_off) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0oldest_off - next= _free_off; =C2=A0=C2=A0=C2=A0 =C2=A0free_bytes >>=3D log->page_bits; =C2=A0=C2=A0=C2=A0 =C2=A0return free_bytes * log->reserved; @@ -1671,7 +1671,7 @@ static int last_log_lsn(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0best_lsn1 =3D first_tail ? base_lsn(log, first_ta= il, first_file_off)=20 : 0; =C2=A0=C2=A0=C2=A0 =C2=A0best_lsn2 =3D second_tail ? base_lsn(log, second_= tail,=20 second_file_off) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A00; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 0; =C2=A0=C2=A0=C2=A0 =C2=A0if (first_tail && second_tail) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (best_lsn1 > best_lsn2) { @@ -1767,7 +1767,7 @@ static int last_log_lsn(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0page_cnt =3D page_pos =3D 1; =C2=A0=C2=A0=C2=A0 =C2=A0curpage_off =3D seq_base =3D=3D log->seq_num ? mi= n(log->next_page,=20 page_off) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 log->next_page; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 log->next_page; =C2=A0=C2=A0=C2=A0 =C2=A0wrapped_file =3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0curpage_off =3D=3D log->first_= page && @@ -1826,8 +1826,8 @@ static int last_log_lsn(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 ((lsn_cur >= > log->file_data_bits) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((cur= page_off < =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 (lsn_to_vbo(log, lsn_cur) & ~log->page_mask)) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 1 : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 0)) !=3D expected_seq) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 1 : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 0)) !=3D expected_seq) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto check_= tail; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -2643,8 +2643,8 @@ static inline bool check_index_root(const struct=20 ATTRIB *attr, =C2=A0=C2=A0=C2=A0 =C2=A0const struct INDEX_ROOT *root =3D resident_data(a= ttr); =C2=A0=C2=A0=C2=A0 =C2=A0u8 index_bits =3D le32_to_cpu(root->index_block_s= ize) >=3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->cluster_size ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sbi->cluster_bits : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SECTOR_SHIFT; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0sbi->cluster_bits : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0SECTOR_SHIFT; =C2=A0=C2=A0=C2=A0 =C2=A0u8 block_clst =3D root->index_block_clst; =C2=A0=C2=A0=C2=A0 =C2=A0if (le32_to_cpu(attr->res.data_size) < sizeof(str= uct INDEX_ROOT) || @@ -3861,9 +3861,9 @@ int log_replay(struct ntfs_inode *ni, bool=20 *initialized) =C2=A0=C2=A0=C2=A0 =C2=A0/* If we have a valid page then grab a pointer to= the restart area. */ =C2=A0=C2=A0=C2=A0 =C2=A0ra2 =3D rst_info.valid_page ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 Add2Ptr(rst_info.r_page, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Add2P= tr(rst_info.r_page, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 le16_to_cpu(rst_info.r_page->ra_off)) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 NULL; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NULL; =C2=A0=C2=A0=C2=A0 =C2=A0if (rst_info.chkdsk_was_run || =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (ra2 && ra2->client_idx[1] =3D= =3D LFS_NO_CLIENT_LE)) { diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 21567e58265c..1a0527e81ebb 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -173,7 +173,7 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER=20 *rhdr, size_t bytes, =C2=A0=C2=A0=C2=A0 =C2=A0fo =3D le16_to_cpu(rhdr->fix_off); =C2=A0=C2=A0=C2=A0 =C2=A0fn =3D simple ? ((bytes >> SECTOR_SHIFT) + 1) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 le16_to_cpu(rhdr->fix_num); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 le16_= to_cpu(rhdr->fix_num); =C2=A0=C2=A0=C2=A0 =C2=A0/* Check errors. */ =C2=A0=C2=A0=C2=A0 =C2=A0if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_= SIZE || !fn-- || diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index b40da258e684..124c6e822623 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -432,8 +432,8 @@ static int scan_nres_bitmap(struct ntfs_inode *ni,=20 struct ATTRIB *bitmap, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0nbits =3D 8= * (data_size - vbo); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ok =3D nbits > from ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 (*fn)((ulong *)bh->b_data, from, nbits, ret) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 false; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (*fn)((ulong *)bh->b_data, from, nbits, ret) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 false; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0put_bh(bh); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ok) { @@ -1682,8 +1682,8 @@ static int indx_insert_into_root(struct ntfs_index=20 *indx, struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0/* Create alloc and bitmap attributes (if not). */ =C2=A0=C2=A0=C2=A0 =C2=A0err =3D run_is_empty(&indx->alloc_run) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 indx_create_allocate(indx, ni, &new_vbn) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 indx_add_allocate(indx, ni, &new_vbn); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 indx_= create_allocate(indx, ni, &new_vbn) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 indx_= add_allocate(indx, ni, &new_vbn); =C2=A0=C2=A0=C2=A0 =C2=A0/* Layout of record may be changed, so rescan roo= t. */ =C2=A0=C2=A0=C2=A0 =C2=A0root =3D indx_get_root(indx, ni, &attr, &mi); @@ -1874,8 +1874,8 @@ indx_insert_into_buffer(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (*indx->cmp)(new_de + 1, le16_to_cpu(new_de->key_size), =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 up_e + 1, le16_to_cpu(up_e->key_size), =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 ctx) < 0 ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 hdr2 : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 hdr1, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 hdr2 : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 hdr1, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= new_de, NULL, ctx); =C2=A0=C2=A0=C2=A0 =C2=A0indx_mark_used(indx, ni, new_vbn >> indx->idx2vbn= _bits); @@ -2346,7 +2346,7 @@ int indx_delete_entry(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 re, ctx, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 fnd->level - 1, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 fnd) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 indx_insert_into_root(indx, ni, re= , e, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 indx_insert_into_root(indx, ni, re, e, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0 ctx, fnd, 0); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kfree(re); diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 6c560245eef4..f699cc053655 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -263,7 +263,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto next_a= ttr; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0run =3D ino =3D=3D MFT_REC_BIT= MAP ? &sbi->used.bitmap.run : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 &ni->file.run; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &ni->file.run; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; =C2=A0=C2=A0=C2=A0 =C2=A0case ATTR_ROOT: @@ -291,8 +291,8 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mode =3D sb->s_root ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (S_IFDIR | (0777 & sbi->options->fs_dmask_inv))= : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (S_IFDIR | 0777); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (S_IFDIR | (0777 & sbi->options->fs_dmask_inv)) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (S_IFDIR | 0777); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto next_attr; =C2=A0=C2=A0=C2=A0 =C2=A0case ATTR_ALLOC: @@ -450,7 +450,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_op =3D &ntfs_file_ino= de_operations; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_fop =3D &ntfs_file_op= erations; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_mapping->a_ops =3D is= _compressed(ni) ? &ntfs_aops_cmpr : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0=C2=A0 &ntfs_aops; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 &ntfs_aops; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ino !=3D MFT_REC_MFT) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0init_rwsem(= &ni->file.run_lock); =C2=A0=C2=A0=C2=A0 =C2=A0} else if (S_ISCHR(mode) || S_ISBLK(mode) || S_IS= FIFO(mode) || @@ -787,7 +787,7 @@ static ssize_t ntfs_direct_IO(struct kiocb *iocb,=20 struct iov_iter *iter) =C2=A0=C2=A0=C2=A0 =C2=A0ret =3D blockdev_direct_IO(iocb, inode, iter, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0 wr ? ntfs_get_block_direct_IO_W : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 ntfs_get_block_direct_IO_R); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ntfs_get_block_direct_IO_R); =C2=A0=C2=A0=C2=A0 =C2=A0if (ret > 0) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0end =3D vbo + ret; @@ -1191,11 +1191,11 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info=20 *sbi, const char *symname, =C2=A0 * - ntfs_symlink =C2=A0 * - ntfs_mkdir =C2=A0 * - ntfs_atomic_open - * + * =C2=A0 * NOTE: if fnd !=3D NULL (ntfs_atomic_open) then @dir is locked =C2=A0 */ -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct inode *dir, struct dentry *dentry, +struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct dentry *dentry, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0const struct cpu_str *uni, umode_t mode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0dev_t dev, const char *symname, u32 size, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0struct ntfs_fnd *fnd) @@ -1605,7 +1605,7 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_op =3D &ntfs_file_ino= de_operations; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_fop =3D &ntfs_file_op= erations; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_mapping->a_ops =3D is= _compressed(ni) ? &ntfs_aops_cmpr : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0=C2=A0 &ntfs_aops; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 &ntfs_aops; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0init_rwsem(&ni->file.run_lock); =C2=A0=C2=A0=C2=A0 =C2=A0} else { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_op =3D &ntfs_special_= inode_operations; diff --git a/fs/ntfs3/lznt.c b/fs/ntfs3/lznt.c index 61e161c7c567..4aae598d6d88 100644 --- a/fs/ntfs3/lznt.c +++ b/fs/ntfs3/lznt.c @@ -297,7 +297,7 @@ static inline ssize_t decompress_chunk(u8 *unc, u8=20 *unc_end, const u8 *cmpr, =C2=A0struct lznt *get_lznt_ctx(int level) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct lznt *r =3D kzalloc(level ? offsetof(struc= t lznt, hash) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(struct lz= nt), +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0 sizeof(struct lznt), =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0 GFP_NOFS); =C2=A0=C2=A0=C2=A0 =C2=A0if (r) @@ -393,8 +393,8 @@ ssize_t decompress_lznt(const void *cmpr, size_t=20 cmpr_size, void *unc, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} else { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* This chu= nk does not contain compressed data. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unc_use =3D= unc_chunk + LZNT_CHUNK_SIZE > unc_end ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unc_end - unc_chunk : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0LZNT_CHUNK_SIZE; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0 unc_end - unc_chunk : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0 LZNT_CHUNK_SIZE; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (cmpr_ch= unk + sizeof(chunk_hdr) + unc_use > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0 cmpr_end) { diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 343bce6da58a..70f8c859e0ad 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -109,8 +109,8 @@ static int ntfs_create(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct inode *inode; -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFREG | mode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 0, NULL, 0, NULL); +=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFREG | mode, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, NULL); =C2=A0=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; =C2=A0} @@ -125,8 +125,8 @@ static int ntfs_mknod(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct inode *inode; -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, m= ode, rdev, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, NULL); +=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, m= ode, rdev,=20 NULL, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL); =C2=A0=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; =C2=A0} @@ -199,8 +199,8 @@ static int ntfs_symlink(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0u32 size =3D strlen(symname); =C2=A0=C2=A0=C2=A0 =C2=A0struct inode *inode; -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFLNK | 0777, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 0, symname, size, NULL); +=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFLNK | 0777, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 symname, size, NULL); =C2=A0=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; =C2=A0} @@ -213,8 +213,8 @@ static int ntfs_mkdir(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct inode *inode; -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFDIR | mode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 0, NULL, 0, NULL); +=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFDIR | mode, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, NULL); =C2=A0=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; =C2=A0} diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 2e4be773728d..6667a75411fc 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -708,8 +708,8 @@ int ntfs_sync_inode(struct inode *inode); =C2=A0int ntfs_flush_inodes(struct super_block *sb, struct inode *i1, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct inode *i2); =C2=A0int inode_write_data(struct inode *inode, const void *data, size_t b= ytes); -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct inode *dir, struct dentry *dentry, +struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct dentry *dentry, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0const struct cpu_str *uni, umode_t mode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0dev_t dev, const char *symname, u32 size, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0struct ntfs_fnd *fnd); @@ -858,12 +858,12 @@ unsigned long ntfs_names_hash(const u16 *name,=20 size_t len, const u16 *upcase, =C2=A0/* globals from xattr.c */ =C2=A0#ifdef CONFIG_NTFS3_FS_POSIX_ACL -struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 struct dentry *dentry, int type); +struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry=20 *dentry, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 int type); =C2=A0int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 struct posix_acl *acl, int ty= pe); =C2=A0int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 struct inode *dir); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 struct inode *dir); =C2=A0#else =C2=A0#define ntfs_get_acl NULL =C2=A0#define ntfs_set_acl NULL diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c index 47612d16c027..cb8cf0161177 100644 --- a/fs/ntfs3/run.c +++ b/fs/ntfs3/run.c @@ -434,8 +434,8 @@ bool run_add_entry(struct runs_tree *run, CLST vcn,=20 CLST lcn, CLST len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (should_= add_tail) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0tail_lcn =3D r->lcn =3D=3D SPARSE_LCN ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 SPARSE_LCN : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (r->lcn + Tovc= n); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 SPARSE_LCN : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (r->lcn + Tovcn); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0tail_vcn =3D r->vcn + Tovcn; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0tail_len =3D r->len - Tovcn; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 2b48b45238ea..12019bfe1325 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -116,8 +116,8 @@ void ntfs_inode_printk(struct inode *inode, const=20 char *fmt, ...) =C2=A0=C2=A0=C2=A0 =C2=A0/* Use static allocated buffer, if possible. */ =C2=A0=C2=A0=C2=A0 =C2=A0name =3D atomic_dec_and_test(&s_name_buf_cnt) ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 s_name_buf : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 kmalloc(sizeof(s_name_buf), GFP_NOFS); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= s_name_buf : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= kmalloc(sizeof(s_name_buf), GFP_NOFS); =C2=A0=C2=A0=C2=A0 =C2=A0if (name) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct dentry *de =3D d_find_a= lias(inode); @@ -257,6 +257,7 @@ enum Opt { =C2=A0=C2=A0=C2=A0 =C2=A0Opt_err, =C2=A0}; +// clang-format off =C2=A0static const struct fs_parameter_spec ntfs_fs_parameters[] =3D { =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_u32("uid",=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0Opt_uid), =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_u32("gid",=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0Opt_gid), @@ -277,9 +278,13 @@ static const struct fs_parameter_spec=20 ntfs_fs_parameters[] =3D { =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_flag_no("nocase",=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0Opt_nocase), =C2=A0=C2=A0=C2=A0 =C2=A0{} =C2=A0}; +// clang-format on =C2=A0/* =C2=A0 * Load nls table or if @nls is utf8 then return NULL. + * + * It is good idea to use here "const char *nls". + * But load_nls accepts "char*". =C2=A0 */ =C2=A0static struct nls_table *ntfs_load_nls(char *nls) =C2=A0{ @@ -790,7 +795,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0sbi->record_size =3D record_size =3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0boot->record_size < 0 ? 1 << (= -boot->record_size) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (u32)boot->record_size= << cluster_bits; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0(u32)boot->record_size << cluster_bits; =C2=A0=C2=A0=C2=A0 =C2=A0sbi->record_bits =3D blksize_bits(record_size); =C2=A0=C2=A0=C2=A0 =C2=A0sbi->attr_size_tr =3D (5 * record_size >> 4); // = ~320 bytes @@ -808,8 +813,8 @@ 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->index_size =3D boot->index_size < 0 ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A01u << (-boot->index_size) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0(u32)boot->index_size << cluster_bits; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 1u << (-boot->index_size) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 (u32)boot->index_size << cluster_bits; =C2=A0=C2=A0=C2=A0 =C2=A0/* Check index record size. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (sbi->index_size < SECTOR_SIZE ||=20 !is_power_of_2(sbi->index_size)) { @@ -1537,12 +1542,14 @@ static void ntfs_fs_free(struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0put_mount_options(opts); =C2=A0} +// clang-format off =C2=A0static const struct fs_context_operations ntfs_context_ops =3D { =C2=A0=C2=A0=C2=A0 =C2=A0.parse_param=C2=A0=C2=A0 =C2=A0=3D ntfs_fs_parse_= param, =C2=A0=C2=A0=C2=A0 =C2=A0.get_tree=C2=A0=C2=A0 =C2=A0=3D ntfs_fs_get_tree, =C2=A0=C2=A0=C2=A0 =C2=A0.reconfigure=C2=A0=C2=A0 =C2=A0=3D ntfs_fs_reconf= igure, =C2=A0=C2=A0=C2=A0 =C2=A0.free=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D nt= fs_fs_free, =C2=A0}; +// clang-format on =C2=A0/* =C2=A0 * ntfs_init_fs_context - Initialize sbi and opts diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 26787c2bbf75..023f314e8950 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -24,7 +24,7 @@ =C2=A0static inline size_t unpacked_ea_size(const struct EA_FULL *ea) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0return ea->size ? le32_to_cpu(ea->size) : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0ALIGN(struct_size(ea, name, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 ALIGN(stru= ct_size(ea, name, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 1 + ea->name_len + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 le16_to_= cpu(ea->elength)), =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A04); @@ -528,8 +528,8 @@ static noinline int ntfs_set_ea(struct inode *inode,=20 const char *name, =C2=A0/* =C2=A0 * ntfs_get_acl - inode_operations::get_acl =C2=A0 */ -struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 struct dentry *dentry, int type) +struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry=20 *dentry, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 int type) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct inode *inode =3D d_inode(dentry); =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni =3D ntfs_i(inode); @@ -596,8 +596,7 @@ static noinline int ntfs_set_acl_ex(struct mnt_idmap=20 *idmap, =C2=A0=C2=A0=C2=A0 =C2=A0case ACL_TYPE_ACCESS: =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Do not change i_mode if we = are in init_acl */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (acl && !init_acl) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D posix_acl= _update_mode(idmap, inode, &mode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 &acl); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D posix_acl= _update_mode(idmap, inode, &mode, &acl); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0return err; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -820,10 +819,9 @@ static int ntfs_getxattr(const struct xattr_handler=20 *handler, struct dentry *de, =C2=A0 * ntfs_setxattr - inode_operations::setxattr =C2=A0 */ =C2=A0static noinline int ntfs_setxattr(const struct xattr_handler *handle= r, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 struct mnt_idmap *idmap, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 struct dentry *de, struct inode *inode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 const char *name, const void *value, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 size_t size, int flags) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 struct mnt_idmap *idmap, struct dentry *de, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 struct inode *inode, const char *name, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 const void *value, size_t size, int flags) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err =3D -EINVAL; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni =3D ntfs_i(inode); --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 68A9EC77B7F for ; Mon, 8 May 2023 12:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234252AbjEHMjD (ORCPT ); Mon, 8 May 2023 08:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234633AbjEHMi5 (ORCPT ); Mon, 8 May 2023 08:38:57 -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 3C93539196; Mon, 8 May 2023 05:38:49 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 7713221C3; Mon, 8 May 2023 12:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549240; bh=d84Ds9/cfWxjNs2/jfAkCt+5qkUgSqpdu5xT/2Jr3EI=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=baKqxaTL8KClyo2ZLOJzvkpx/AItLISWL6uH91JodSZwMNMyE5ulsY3OFgJAvIxlG gFZQLSyDcq4tthScvZirvZ3XkcBeP5vSSTFRnD8EIgwpMZVnSsp8bW+2GgfcXswEZe O9219w2ELaLMb297vuqHSbDNdGnQQxRo06UBqXsw= 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:38:46 +0300 Message-ID: <4356fa5f-db35-4e2a-35bb-8f727a08dd63@paragon-software.com> Date: Mon, 8 May 2023 16:38:46 +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 07/10] fs/ntfs3: Code refactoring 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 Check functions arguments. Use u8 instead of size_t for ntfs names, more=20 consts and other. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrlist.c |=C2=A0=C2=A0 3 +- =C2=A0fs/ntfs3/frecord.c=C2=A0 |=C2=A0=C2=A0 2 +- =C2=A0fs/ntfs3/fsntfs.c=C2=A0=C2=A0 |=C2=A0 37 +++++++-------- =C2=A0fs/ntfs3/inode.c=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 5 +- =C2=A0fs/ntfs3/ntfs.h=C2=A0=C2=A0=C2=A0=C2=A0 | 108 ++++++++++++++++++++++= ++-------------------- =C2=A0fs/ntfs3/ntfs_fs.h=C2=A0 |=C2=A0 12 ++--- =C2=A0fs/ntfs3/record.c=C2=A0=C2=A0 |=C2=A0=C2=A0 2 +- =C2=A07 files changed, 88 insertions(+), 81 deletions(-) diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c index 81c22df27c72..42631b31adf1 100644 --- a/fs/ntfs3/attrlist.c +++ b/fs/ntfs3/attrlist.c @@ -375,8 +375,7 @@ bool al_remove_le(struct ntfs_inode *ni, struct=20 ATTR_LIST_ENTRY *le) =C2=A0 * al_delete_le - Delete first le from the list which matches its=20 parameters. =C2=A0 */ =C2=A0bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST v= cn, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 const __le16 *name, size_t na= me_len, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 const struct MFT_REF *ref) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 const __le16 *name, u8 name_l= en, const struct MFT_REF *ref) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0u16 size; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_LIST_ENTRY *le; diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 4227e3f590a5..be59bd399fd1 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -384,7 +384,7 @@ bool ni_add_subrecord(struct ntfs_inode *ni, CLST=20 rno, struct mft_inode **mi) =C2=A0 * ni_remove_attr - Remove all attributes for the given type/name/id. =C2=A0 */ =C2=A0int ni_remove_attr(struct ntfs_inode *ni, enum ATTR_TYPE type, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 const __le16 *name, siz= e_t name_len, bool base_only, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 const __le16 *name, u8 = name_len, bool base_only, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 const __le16 *id) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err; diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 1a0527e81ebb..1c05c088d1c6 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -1661,7 +1661,8 @@ int ntfs_vbo_to_lbo(struct ntfs_sb_info *sbi,=20 const struct runs_tree *run, =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0} -struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST rno,=20 bool dir) +struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST rno, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 enum RECORD_FLAG flag) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D sbi->sb; @@ -1673,8 +1674,7 @@ struct ntfs_inode *ntfs_new_inode(struct=20 ntfs_sb_info *sbi, CLST rno, bool dir) =C2=A0=C2=A0=C2=A0 =C2=A0ni =3D ntfs_i(inode); -=C2=A0=C2=A0 =C2=A0err =3D mi_format_new(&ni->mi, sbi, rno, dir ? RECORD_F= LAG_DIR : 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 false); +=C2=A0=C2=A0 =C2=A0err =3D mi_format_new(&ni->mi, sbi, rno, flag, false); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; @@ -1937,7 +1937,7 @@ int ntfs_security_init(struct ntfs_sb_info *sbi) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sii_e =3D (struct NTFS_DE_SII = *)ne; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (le16_to_cpu(ne->view.data_size) = < SIZEOF_SECURITY_HDR) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (le16_to_cpu(ne->view.data_size) = < sizeof(sii_e->sec_hdr)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0continue; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0next_id =3D le32_to_cpu(sii_e-= >sec_id) + 1; @@ -1998,18 +1998,18 @@ int ntfs_get_security_by_id(struct ntfs_sb_info=20 *sbi, __le32 security_id, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0t32 =3D le32_to_cpu(sii_e->sec_hdr.size); -=C2=A0=C2=A0 =C2=A0if (t32 < SIZEOF_SECURITY_HDR) { +=C2=A0=C2=A0 =C2=A0if (t32 < sizeof(struct SECURITY_HDR)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0if (t32 > SIZEOF_SECURITY_HDR + 0x10000) { +=C2=A0=C2=A0 =C2=A0if (t32 > sizeof(struct SECURITY_HDR) + 0x10000) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Looks like too big security= . 0x10000 - is arbitrary big=20 number. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EFBIG; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0*size =3D t32 - SIZEOF_SECURITY_HDR; +=C2=A0=C2=A0 =C2=A0*size =3D t32 - sizeof(struct SECURITY_HDR); =C2=A0=C2=A0=C2=A0 =C2=A0p =3D kmalloc(*size, GFP_NOFS); =C2=A0=C2=A0=C2=A0 =C2=A0if (!p) { @@ -2023,14 +2023,14 @@ int ntfs_get_security_by_id(struct ntfs_sb_info=20 *sbi, __le32 security_id, =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; -=C2=A0=C2=A0 =C2=A0if (memcmp(&d_security, &sii_e->sec_hdr, SIZEOF_SECURIT= Y_HDR)) { +=C2=A0=C2=A0 =C2=A0if (memcmp(&d_security, &sii_e->sec_hdr, sizeof(d_secur= ity))) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_read_run_nb(sbi, &ni->file.run, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 le64_to_cpu(sii_e->sec_hdr.off) + -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SIZEOF_SECURITY_HDR, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(struct SECURITY_HDR), =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 p, *size, NULL); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; @@ -2069,7 +2069,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi, =C2=A0=C2=A0=C2=A0 =C2=A0struct NTFS_DE_SDH sdh_e; =C2=A0=C2=A0=C2=A0 =C2=A0struct NTFS_DE_SII sii_e; =C2=A0=C2=A0=C2=A0 =C2=A0struct SECURITY_HDR *d_security; -=C2=A0=C2=A0 =C2=A0u32 new_sec_size =3D size_sd + SIZEOF_SECURITY_HDR; +=C2=A0=C2=A0 =C2=A0u32 new_sec_size =3D size_sd + sizeof(struct SECURITY_H= DR); =C2=A0=C2=A0=C2=A0 =C2=A0u32 aligned_sec_size =3D ALIGN(new_sec_size, 16); =C2=A0=C2=A0=C2=A0 =C2=A0struct SECURITY_KEY hash_key; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_fnd *fnd_sdh =3D NULL; @@ -2207,14 +2207,14 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi, =C2=A0=C2=A0=C2=A0 =C2=A0/* Fill SII entry. */ =C2=A0=C2=A0=C2=A0 =C2=A0sii_e.de.view.data_off =3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0cpu_to_le16(offsetof(struct NT= FS_DE_SII, sec_hdr)); -=C2=A0=C2=A0 =C2=A0sii_e.de.view.data_size =3D cpu_to_le16(SIZEOF_SECURITY= _HDR); +=C2=A0=C2=A0 =C2=A0sii_e.de.view.data_size =3D cpu_to_le16(sizeof(struct S= ECURITY_HDR)); =C2=A0=C2=A0=C2=A0 =C2=A0sii_e.de.view.res =3D 0; -=C2=A0=C2=A0 =C2=A0sii_e.de.size =3D cpu_to_le16(SIZEOF_SII_DIRENTRY); +=C2=A0=C2=A0 =C2=A0sii_e.de.size =3D cpu_to_le16(sizeof(struct NTFS_DE_SII= )); =C2=A0=C2=A0=C2=A0 =C2=A0sii_e.de.key_size =3D cpu_to_le16(sizeof(d_securi= ty->key.sec_id)); =C2=A0=C2=A0=C2=A0 =C2=A0sii_e.de.flags =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0sii_e.de.res =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0sii_e.sec_id =3D d_security->key.sec_id; -=C2=A0=C2=A0 =C2=A0memcpy(&sii_e.sec_hdr, d_security, SIZEOF_SECURITY_HDR); +=C2=A0=C2=A0 =C2=A0memcpy(&sii_e.sec_hdr, d_security, sizeof(struct SECURI= TY_HDR)); =C2=A0=C2=A0=C2=A0 =C2=A0err =3D indx_insert_entry(indx_sii, ni, &sii_e.de= , NULL, NULL, 0); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) @@ -2223,7 +2223,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi, =C2=A0=C2=A0=C2=A0 =C2=A0/* Fill SDH entry. */ =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.de.view.data_off =3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0cpu_to_le16(offsetof(struct NT= FS_DE_SDH, sec_hdr)); -=C2=A0=C2=A0 =C2=A0sdh_e.de.view.data_size =3D cpu_to_le16(SIZEOF_SECURITY= _HDR); +=C2=A0=C2=A0 =C2=A0sdh_e.de.view.data_size =3D cpu_to_le16(sizeof(struct S= ECURITY_HDR)); =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.de.view.res =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.de.size =3D cpu_to_le16(SIZEOF_SDH_DIRENTRY= ); =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.de.key_size =3D cpu_to_le16(sizeof(sdh_e.ke= y)); @@ -2231,7 +2231,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi, =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.de.res =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.key.hash =3D d_security->key.hash; =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.key.sec_id =3D d_security->key.sec_id; -=C2=A0=C2=A0 =C2=A0memcpy(&sdh_e.sec_hdr, d_security, SIZEOF_SECURITY_HDR); +=C2=A0=C2=A0 =C2=A0memcpy(&sdh_e.sec_hdr, d_security, sizeof(struct SECURI= TY_HDR)); =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.magic[0] =3D cpu_to_le16('I'); =C2=A0=C2=A0=C2=A0 =C2=A0sdh_e.magic[1] =3D cpu_to_le16('I'); @@ -2522,7 +2522,8 @@ void mark_as_free_ex(struct ntfs_sb_info *sbi,=20 CLST lcn, CLST len, bool trim) =C2=A0/* =C2=A0 * run_deallocate - Deallocate clusters. =C2=A0 */ -int run_deallocate(struct ntfs_sb_info *sbi, struct runs_tree *run,=20 bool trim) +int run_deallocate(struct ntfs_sb_info *sbi, const struct runs_tree *run, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 bool trim) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0CLST lcn, len; =C2=A0=C2=A0=C2=A0 =C2=A0size_t idx =3D 0; @@ -2578,13 +2579,13 @@ static inline bool=20 name_has_forbidden_chars(const struct le_str *fname) =C2=A0=C2=A0=C2=A0 =C2=A0return false; =C2=A0} -static inline bool is_reserved_name(struct ntfs_sb_info *sbi, +static inline bool is_reserved_name(const struct ntfs_sb_info *sbi, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0 const struct le_str *fname) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int port_digit; =C2=A0=C2=A0=C2=A0 =C2=A0const __le16 *name =3D fname->name; =C2=A0=C2=A0=C2=A0 =C2=A0int len =3D fname->len; -=C2=A0=C2=A0 =C2=A0u16 *upcase =3D sbi->upcase; +=C2=A0=C2=A0 =C2=A0const u16 *upcase =3D sbi->upcase; =C2=A0=C2=A0=C2=A0 =C2=A0/* check for 3 chars reserved names (device names= ) */ =C2=A0=C2=A0=C2=A0 =C2=A0/* name by itself or with any extension is forbid= den */ diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index f699cc053655..dc7e7ab701c6 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -1309,7 +1309,7 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out2; -=C2=A0=C2=A0 =C2=A0ni =3D ntfs_new_inode(sbi, ino, fa & FILE_ATTRIBUTE_DIR= ECTORY); +=C2=A0=C2=A0 =C2=A0ni =3D ntfs_new_inode(sbi, ino, S_ISDIR(mode) ? RECORD_= FLAG_DIR : 0); =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ERR(ni)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D PTR_ERR(ni); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni =3D NULL; @@ -1437,8 +1437,7 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0root =3D Add2Ptr(attr, sizeof(= I30_NAME) + SIZEOF_RESIDENT); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(root, dir_root, offseto= f(struct INDEX_ROOT, ihdr)); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0root->ihdr.de_off =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0cpu_to_le32(sizeo= f(struct INDEX_HDR)); // 0x10 +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0root->ihdr.de_off =3D cpu_to_le32(si= zeof(struct INDEX_HDR)); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0root->ihdr.used =3D cpu_to_le3= 2(sizeof(struct INDEX_HDR) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(struct N= TFS_DE)); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0root->ihdr.total =3D root->ihd= r.used; diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 90151e56c122..3ec2eaf31996 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -95,11 +95,10 @@ enum RECORD_NUM { =C2=A0=C2=A0=C2=A0 =C2=A0MFT_REC_BITMAP=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D 6, =C2=A0=C2=A0=C2=A0 =C2=A0MFT_REC_BOOT=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D 7, =C2=A0=C2=A0=C2=A0 =C2=A0MFT_REC_BADCLUST=C2=A0=C2=A0 =C2=A0=3D 8, -=C2=A0=C2=A0 =C2=A0//MFT_REC_QUOTA=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D 9, -=C2=A0=C2=A0 =C2=A0MFT_REC_SECURE=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D= 9, // NTFS 3.0 +=C2=A0=C2=A0 =C2=A0MFT_REC_SECURE=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D= 9, =C2=A0=C2=A0=C2=A0 =C2=A0MFT_REC_UPCASE=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D 10, -=C2=A0=C2=A0 =C2=A0MFT_REC_EXTEND=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D= 11, // NTFS 3.0 -=C2=A0=C2=A0 =C2=A0MFT_REC_RESERVED=C2=A0=C2=A0 =C2=A0=3D 11, +=C2=A0=C2=A0 =C2=A0MFT_REC_EXTEND=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D= 11, +=C2=A0=C2=A0 =C2=A0MFT_REC_RESERVED=C2=A0=C2=A0 =C2=A0=3D 12, =C2=A0=C2=A0=C2=A0 =C2=A0MFT_REC_FREE=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D 16, =C2=A0=C2=A0=C2=A0 =C2=A0MFT_REC_USER=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D 24, =C2=A0}; @@ -109,7 +108,6 @@ enum ATTR_TYPE { =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_STD=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D= cpu_to_le32(0x10), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_LIST=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D cpu_to_le32(0x20), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_NAME=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D cpu_to_le32(0x30), -=C2=A0=C2=A0 =C2=A0// ATTR_VOLUME_VERSION on Nt4 =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_ID=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=3D cpu_to_le32(0x40), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_SECURE=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D cpu_to_le32(0x50), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_LABEL=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D cpu_to_le32(0x60), @@ -118,7 +116,6 @@ enum ATTR_TYPE { =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_ROOT=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D cpu_to_le32(0x90), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_ALLOC=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D cpu_to_le32(0xA0), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_BITMAP=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =3D cpu_to_le32(0xB0), -=C2=A0=C2=A0 =C2=A0// ATTR_SYMLINK on Nt4 =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_REPARSE=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D cpu_to_le32(0xC0), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_EA_INFO=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D cpu_to_le32(0xD0), =C2=A0=C2=A0=C2=A0 =C2=A0ATTR_EA=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=3D cpu_to_le32(0xE0), @@ -144,6 +141,7 @@ enum FILE_ATTRIBUTE { =C2=A0=C2=A0=C2=A0 =C2=A0FILE_ATTRIBUTE_ENCRYPTED=C2=A0=C2=A0 =C2=A0=3D cp= u_to_le32(0x00004000), =C2=A0=C2=A0=C2=A0 =C2=A0FILE_ATTRIBUTE_VALID_FLAGS=C2=A0=C2=A0 =C2=A0=3D = cpu_to_le32(0x00007fb7), =C2=A0=C2=A0=C2=A0 =C2=A0FILE_ATTRIBUTE_DIRECTORY=C2=A0=C2=A0 =C2=A0=3D cp= u_to_le32(0x10000000), +=C2=A0=C2=A0 =C2=A0FILE_ATTRIBUTE_INDEX=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=3D cpu_to_le32(0x20000000) =C2=A0}; =C2=A0static_assert(sizeof(enum FILE_ATTRIBUTE) =3D=3D 4); @@ -266,7 +264,7 @@ enum RECORD_FLAG { =C2=A0=C2=A0=C2=A0 =C2=A0RECORD_FLAG_IN_USE=C2=A0=C2=A0 =C2=A0=3D cpu_to_l= e16(0x0001), =C2=A0=C2=A0=C2=A0 =C2=A0RECORD_FLAG_DIR=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=3D cpu_to_le16(0x0002), =C2=A0=C2=A0=C2=A0 =C2=A0RECORD_FLAG_SYSTEM=C2=A0=C2=A0 =C2=A0=3D cpu_to_l= e16(0x0004), -=C2=A0=C2=A0 =C2=A0RECORD_FLAG_UNKNOWN=C2=A0=C2=A0 =C2=A0=3D cpu_to_le16(0= x0008), +=C2=A0=C2=A0 =C2=A0RECORD_FLAG_INDEX=C2=A0=C2=A0 =C2=A0=3D cpu_to_le16(0x0= 008), =C2=A0}; =C2=A0/* MFT Record structure. */ @@ -331,18 +329,18 @@ struct ATTR_NONRESIDENT { =C2=A0=C2=A0=C2=A0 =C2=A0__le64 svcn;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// 0x10: Starting VCN of this segment. =C2=A0=C2=A0=C2=A0 =C2=A0__le64 evcn;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// 0x18: End VCN of this segment. =C2=A0=C2=A0=C2=A0 =C2=A0__le16 run_off;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0// 0x20: Offset to packed runs. -=C2=A0=C2=A0 =C2=A0//=C2=A0 Unit of Compression size for this stream, expr= essed -=C2=A0=C2=A0 =C2=A0//=C2=A0 as a log of the cluster size. +=C2=A0=C2=A0 =C2=A0// Unit of Compression size for this stream, expressed +=C2=A0=C2=A0 =C2=A0// as a log of the cluster size. =C2=A0=C2=A0=C2=A0 =C2=A0// -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A00 means file is not compressed -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A01, 2, 3, and 4 are potentially leg= al values if the -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 stream is compr= essed, however the implementation -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 may only choose= to use 4, or possibly 3.=C2=A0 Note -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 that 4 means cl= uster size time 16.=C2=A0=C2=A0 =C2=A0If convenient -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 the implementat= ion may wish to accept a -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 reasonable rang= e of legal values here (1-5?), -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 even if the imp= lementation only generates -=C2=A0=C2=A0 =C2=A0//=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 a smaller set o= f values itself. +=C2=A0=C2=A0 =C2=A0// 0 means file is not compressed +=C2=A0=C2=A0 =C2=A0// 1, 2, 3, and 4 are potentially legal values if the +=C2=A0=C2=A0 =C2=A0// stream is compressed, however the implementation +=C2=A0=C2=A0 =C2=A0// may only choose to use 4, or possibly 3. +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // Note that 4 means cluster si= ze time 16. +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // If convenient the implementa= tion may wish to accept a +=C2=A0=C2=A0 =C2=A0// reasonable range of legal values here (1-5?), +=C2=A0=C2=A0 =C2=A0// even if the implementation only generates +=C2=A0=C2=A0 =C2=A0// a smaller set of values itself. =C2=A0=C2=A0=C2=A0 =C2=A0u8 c_unit;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/= / 0x22: =C2=A0=C2=A0=C2=A0 =C2=A0u8 res1[5];=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= // 0x23: =C2=A0=C2=A0=C2=A0 =C2=A0__le64 alloc_size;=C2=A0=C2=A0 =C2=A0// 0x28: The= allocated size of attribute in=20 bytes. @@ -836,16 +834,22 @@ static_assert(sizeof(struct ATTR_DEF_ENTRY) =3D=3D 0x= a0); =C2=A0/* Object ID (0x40) */ =C2=A0struct OBJECT_ID { =C2=A0=C2=A0=C2=A0 =C2=A0struct GUID ObjId;=C2=A0=C2=A0 =C2=A0// 0x00: Uni= que Id assigned to file. -=C2=A0=C2=A0 =C2=A0struct GUID BirthVolumeId; // 0x10: Birth Volume Id is = the Object=20 Id of the Volume on. -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// which the Object Id was allocated. It never changes. -=C2=A0=C2=A0 =C2=A0struct GUID BirthObjectId; // 0x20: Birth Object Id is = the first=20 Object Id that was -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// ever assigned to this MFT Record. I.e. If the Object Id -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// is changed for some reason, this field will reflect the -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// original value of the Object Id. -=C2=A0=C2=A0 =C2=A0struct GUID DomainId;=C2=A0=C2=A0 =C2=A0// 0x30: Domain= Id is currently unused but=20 it is intended to be -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// used in a network environment where the local machine is -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// part of a Windows 2000 Domain. This may be used in a=20 Windows -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// 2000 Advanced Server managed domain. + +=C2=A0=C2=A0 =C2=A0// Birth Volume Id is the Object Id of the Volume on. +=C2=A0=C2=A0 =C2=A0// which the Object Id was allocated. It never changes. +=C2=A0=C2=A0 =C2=A0struct GUID BirthVolumeId; //0x10: + +=C2=A0=C2=A0 =C2=A0// Birth Object Id is the first Object Id that was +=C2=A0=C2=A0 =C2=A0// ever assigned to this MFT Record. I.e. If the Object= Id +=C2=A0=C2=A0 =C2=A0// is changed for some reason, this field will reflect = the +=C2=A0=C2=A0 =C2=A0// original value of the Object Id. +=C2=A0=C2=A0 =C2=A0struct GUID BirthObjectId; // 0x20: + +=C2=A0=C2=A0 =C2=A0// Domain Id is currently unused but it is intended to = be +=C2=A0=C2=A0 =C2=A0// used in a network environment where the local machin= e is +=C2=A0=C2=A0 =C2=A0// part of a Windows 2000 Domain. This may be used in a= Windows +=C2=A0=C2=A0 =C2=A0// 2000 Advanced Server managed domain. +=C2=A0=C2=A0 =C2=A0struct GUID DomainId;=C2=A0=C2=A0 =C2=A0// 0x30: =C2=A0}; =C2=A0static_assert(sizeof(struct OBJECT_ID) =3D=3D 0x40); @@ -855,32 +859,35 @@ struct NTFS_DE_O { =C2=A0=C2=A0=C2=A0 =C2=A0struct NTFS_DE de; =C2=A0=C2=A0=C2=A0 =C2=A0struct GUID ObjId;=C2=A0=C2=A0 =C2=A0// 0x10: Uni= que Id assigned to file. =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REF ref;=C2=A0=C2=A0 =C2=A0// 0x20: MF= T record number with this file. -=C2=A0=C2=A0 =C2=A0struct GUID BirthVolumeId; // 0x28: Birth Volume Id is = the Object=20 Id of the Volume on -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// which the Object Id was allocated. It never changes. -=C2=A0=C2=A0 =C2=A0struct GUID BirthObjectId; // 0x38: Birth Object Id is = the first=20 Object Id that was -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// ever assigned to this MFT Record. I.e. If the Object Id -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// is changed for some reason, this field will reflect the -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// original value of the Object Id. -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// This field is valid if data_size =3D=3D 0x48. -=C2=A0=C2=A0 =C2=A0struct GUID BirthDomainId; // 0x48: Domain Id is curren= tly unused=20 but it is intended -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// to be used in a network environment where the local -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// machine is part of a Windows 2000 Domain. This may be -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0// used in a Windows 2000 Advanced Server managed domain. + +=C2=A0=C2=A0 =C2=A0// Birth Volume Id is the Object Id of the Volume on +=C2=A0=C2=A0 =C2=A0// which the Object Id was allocated. It never changes. +=C2=A0=C2=A0 =C2=A0struct GUID BirthVolumeId; // 0x28: + +=C2=A0=C2=A0 =C2=A0// Birth Object Id is the first Object Id that was +=C2=A0=C2=A0 =C2=A0// ever assigned to this MFT Record. I.e. If the Object= Id +=C2=A0=C2=A0 =C2=A0// is changed for some reason, this field will reflect = the +=C2=A0=C2=A0 =C2=A0// original value of the Object Id. +=C2=A0=C2=A0 =C2=A0// This field is valid if data_size =3D=3D 0x48. +=C2=A0=C2=A0 =C2=A0struct GUID BirthObjectId; // 0x38: + +=C2=A0=C2=A0 =C2=A0// Domain Id is currently unused but it is intended +=C2=A0=C2=A0 =C2=A0// to be used in a network environment where the local +=C2=A0=C2=A0 =C2=A0// machine is part of a Windows 2000 Domain. This may be +=C2=A0=C2=A0 =C2=A0// used in a Windows 2000 Advanced Server managed domai= n. +=C2=A0=C2=A0 =C2=A0struct GUID BirthDomainId; // 0x48: =C2=A0}; =C2=A0static_assert(sizeof(struct NTFS_DE_O) =3D=3D 0x58); -#define NTFS_OBJECT_ENTRY_DATA_SIZE1=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 \ -=C2=A0=C2=A0 =C2=A00x38 // struct NTFS_DE_O.BirthDomainId is not used -#define NTFS_OBJECT_ENTRY_DATA_SIZE2=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 \ -=C2=A0=C2=A0 =C2=A00x48 // struct NTFS_DE_O.BirthDomainId is used - =C2=A0/* Q Directory entry structure ( rule =3D 0x11 ) */ =C2=A0struct NTFS_DE_Q { =C2=A0=C2=A0=C2=A0 =C2=A0struct NTFS_DE de; =C2=A0=C2=A0=C2=A0 =C2=A0__le32 owner_id;=C2=A0=C2=A0 =C2=A0// 0x10: Uniqu= e Id assigned to file + +=C2=A0=C2=A0 =C2=A0/* here is 0x30 bytes of user quota. NOTE: 4 byte align= ed! */ =C2=A0=C2=A0=C2=A0 =C2=A0__le32 Version;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0// 0x14: 0x02 -=C2=A0=C2=A0 =C2=A0__le32 flags2;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0// = 0x18: Quota flags, see above +=C2=A0=C2=A0 =C2=A0__le32 Flags;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0// 0= x18: Quota flags, see above =C2=A0=C2=A0=C2=A0 =C2=A0__le64 BytesUsed;=C2=A0=C2=A0 =C2=A0// 0x1C: =C2=A0=C2=A0=C2=A0 =C2=A0__le64 ChangeTime;=C2=A0=C2=A0 =C2=A0// 0x24: =C2=A0=C2=A0=C2=A0 =C2=A0__le64 WarningLimit;=C2=A0=C2=A0 =C2=A0// 0x28: @@ -888,9 +895,9 @@ struct NTFS_DE_Q { =C2=A0=C2=A0=C2=A0 =C2=A0__le64 ExceededTime;=C2=A0=C2=A0 =C2=A0// 0x3C: =C2=A0=C2=A0=C2=A0 =C2=A0// SID is placed here -}; // sizeof() =3D 0x44 +}__packed; // sizeof() =3D 0x44 -#define SIZEOF_NTFS_DE_Q 0x44 +static_assert(sizeof(struct NTFS_DE_Q) =3D=3D 0x44); =C2=A0#define SecurityDescriptorsBlockSize 0x40000 // 256K =C2=A0#define SecurityDescriptorMaxSize=C2=A0=C2=A0=C2=A0 0x20000 // 128K @@ -912,7 +919,7 @@ struct SECURITY_HDR { =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0} __packed; -#define SIZEOF_SECURITY_HDR 0x14 +static_assert(sizeof(struct SECURITY_HDR) =3D=3D 0x14); =C2=A0/* SII Directory entry structure */ =C2=A0struct NTFS_DE_SII { @@ -921,7 +928,8 @@ struct NTFS_DE_SII { =C2=A0=C2=A0=C2=A0 =C2=A0struct SECURITY_HDR sec_hdr;=C2=A0=C2=A0 =C2=A0//= 0x14: =C2=A0} __packed; -#define SIZEOF_SII_DIRENTRY 0x28 +static_assert(offsetof(struct NTFS_DE_SII, sec_hdr) =3D=3D 0x14); +static_assert(sizeof(struct NTFS_DE_SII) =3D=3D 0x28); =C2=A0/* SDH Directory entry structure */ =C2=A0struct NTFS_DE_SDH { @@ -1155,7 +1163,7 @@ struct REPARSE_DATA_BUFFER { =C2=A0#define FILE_NEED_EA 0x80 // See ntifs.h =C2=A0/* - *FILE_NEED_EA, indicates that the file to which the EA belongs cannot be + * FILE_NEED_EA, indicates that the file to which the EA belongs cannot be =C2=A0 * interpreted without understanding the associated extended attribu= tes. =C2=A0 */ =C2=A0struct EA_INFO { diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 6667a75411fc..98b61e4b3215 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -467,8 +467,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE=20 type, const __le16 *name, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ATTR_LIST_E= NTRY **new_le); =C2=A0bool al_remove_le(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le); =C2=A0bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST v= cn, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 const __le16 *name, size_t na= me_len, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 const struct MFT_REF *ref); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 const __le16 *name, u8 name_l= en, const struct MFT_REF *ref); =C2=A0int al_update(struct ntfs_inode *ni, int sync); =C2=A0static inline size_t al_aligned(size_t size) =C2=A0{ @@ -527,7 +526,7 @@ struct ATTRIB *ni_load_attr(struct ntfs_inode *ni,=20 enum ATTR_TYPE type, =C2=A0int ni_load_all_mi(struct ntfs_inode *ni); =C2=A0bool ni_add_subrecord(struct ntfs_inode *ni, CLST rno, struct=20 mft_inode **mi); =C2=A0int ni_remove_attr(struct ntfs_inode *ni, enum ATTR_TYPE type, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 const __le16 *name, siz= e_t name_len, bool base_only, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 const __le16 *name, u8 = name_len, bool base_only, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 const __le16 *id); =C2=A0int ni_create_attr_list(struct ntfs_inode *ni); =C2=A0int ni_expand_list(struct ntfs_inode *ni); @@ -631,7 +630,7 @@ int ntfs_bio_fill_1(struct ntfs_sb_info *sbi, const=20 struct runs_tree *run); =C2=A0int ntfs_vbo_to_lbo(struct ntfs_sb_info *sbi, const struct runs_tree= *run, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 u64 vbo, u6= 4 *lbo, u64 *bytes); =C2=A0struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST nRe= c, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 bool dir); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 enum RECORD_FLAG flag); =C2=A0extern const u8 s_default_security[0x50]; =C2=A0bool is_sd_valid(const struct SECURITY_DESCRIPTOR_RELATIVE *sd, u32 = len); =C2=A0int ntfs_security_init(struct ntfs_sb_info *sbi); @@ -649,7 +648,8 @@ int ntfs_insert_reparse(struct ntfs_sb_info *sbi,=20 __le32 rtag, =C2=A0int ntfs_remove_reparse(struct ntfs_sb_info *sbi, __le32 rtag, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0const struc= t MFT_REF *ref); =C2=A0void mark_as_free_ex(struct ntfs_sb_info *sbi, CLST lcn, CLST len,=20 bool trim); -int run_deallocate(struct ntfs_sb_info *sbi, struct runs_tree *run,=20 bool trim); +int run_deallocate(struct ntfs_sb_info *sbi, const struct runs_tree *run, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 bool trim); =C2=A0bool valid_windows_name(struct ntfs_sb_info *sbi, const struct le_st= r=20 *name); =C2=A0/* Globals from index.c */ @@ -738,7 +738,7 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi,=20 struct ATTRIB *attr); =C2=A0// TODO: id? =C2=A0struct ATTRIB *mi_find_attr(struct mft_inode *mi, struct ATTRIB *att= r, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0 enum ATTR_TYPE type, const __le16 *name, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 size_t name_len, const __le16 *id); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 u8 name_len, const __le16 *id); =C2=A0static inline struct ATTRIB *rec_find_attr_le(struct mft_inode *rec, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ATTR_LIS= T_ENTRY *le) =C2=A0{ diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 7974ca35a15c..e73ca2df42eb 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -302,7 +302,7 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi,=20 struct ATTRIB *attr) =C2=A0 */ =C2=A0struct ATTRIB *mi_find_attr(struct mft_inode *mi, struct ATTRIB *att= r, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0 enum ATTR_TYPE type, const __le16 *name, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 size_t name_len, const __le16 *id) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 u8 name_len, const __le16 *id) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0u32 type_in =3D le32_to_cpu(type); =C2=A0=C2=A0=C2=A0 =C2=A0u32 atype; --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 From nobody Wed Feb 11 14:44:14 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 B6D1AC77B73 for ; Mon, 8 May 2023 12:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234069AbjEHMkL (ORCPT ); Mon, 8 May 2023 08:40:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233727AbjEHMkI (ORCPT ); Mon, 8 May 2023 08:40:08 -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 E4E023DC88; Mon, 8 May 2023 05:39:45 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 4C39321C3; Mon, 8 May 2023 12:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549297; bh=6s1aiYUMi1N3V7VNMRBYWUxpu3ZEhCtn4SbHn7Qf7Fg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=aVk0mrX9MQkqEi99MHlO7uLlgKuUQcXvpr0EXyBauUXaj35rdaVC/KvhvRNxNOBS1 VH0UBergSpSBdZBRl9a1KG61Qyf1wBmdNmNiiVIMBxW7z0CObhot03hGsQ1CsLxZRJ KaWr3N8j91EGcmFDIXvI26wQpNQ5EgtTwhIdwwYE= 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:43 +0300 Message-ID: <5915fbe7-5448-6093-4318-a37987953c7a@paragon-software.com> Date: Mon, 8 May 2023 16:39:42 +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 09/10] fs/ntfs3: Fix endian problem 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 Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/frecord.c | 11 +++++------ =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 2 +- =C2=A02 files changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index be59bd399fd1..16bd9faa2d28 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -236,6 +236,7 @@ struct ATTRIB *ni_find_attr(struct ntfs_inode *ni,=20 struct ATTRIB *attr, =C2=A0=C2=A0=C2=A0 =C2=A0return attr; =C2=A0out: +=C2=A0=C2=A0 =C2=A0ntfs_inode_err(&ni->vfs_inode, "failed to parse mft rec= ord"); =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR); =C2=A0=C2=A0=C2=A0 =C2=A0return NULL; =C2=A0} @@ -1643,14 +1644,13 @@ int ni_delete_all(struct ntfs_inode *ni) =C2=A0 * Return: File name attribute by its value. =C2=A0 */ =C2=A0struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct cpu_str *uni, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct le_str *uni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct MFT_REF *home_dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct mft_inode **mi, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ATTR_LIST_ENTRY **le) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_FILE_NAME *fname; -=C2=A0=C2=A0 =C2=A0struct le_str *fns; =C2=A0=C2=A0=C2=A0 =C2=A0if (le) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0*le =3D NULL; @@ -1674,10 +1674,9 @@ struct ATTR_FILE_NAME *ni_fname_name(struct=20 ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0if (uni->len !=3D fname->name_len) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto next; -=C2=A0=C2=A0 =C2=A0fns =3D (struct le_str *)&fname->name_len; -=C2=A0=C2=A0 =C2=A0if (ntfs_cmp_names_cpu(uni, fns, NULL, false)) +=C2=A0=C2=A0 =C2=A0if (ntfs_cmp_names(uni->name, uni->len, fname->name, un= i->len, NULL, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 fals= e)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto next; - =C2=A0=C2=A0=C2=A0 =C2=A0return fname; =C2=A0} @@ -2915,7 +2914,7 @@ int ni_remove_name(struct ntfs_inode *dir_ni,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0/* Find name in record. */ =C2=A0=C2=A0=C2=A0 =C2=A0mi_get_ref(&dir_ni->mi, &de_name->home); -=C2=A0=C2=A0 =C2=A0fname =3D ni_fname_name(ni, (struct cpu_str *)&de_name-= >name_len, +=C2=A0=C2=A0 =C2=A0fname =3D ni_fname_name(ni, (struct le_str *)&de_name->= name_len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 &de_name->home, &mi, &le); =C2=A0=C2=A0=C2=A0 =C2=A0if (!fname) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOENT; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 98b61e4b3215..00fa782fcada 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -543,7 +543,7 @@ void ni_remove_attr_le(struct ntfs_inode *ni, struct=20 ATTRIB *attr, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 struct mft_inode *mi, struct ATTR_LIST_ENTRY *le); =C2=A0int ni_delete_all(struct ntfs_inode *ni); =C2=A0struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct cpu_str *uni, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct le_str *uni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct MFT_REF *home, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct mft_inode **mi, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ATTR_LIST_ENTRY **entry); --=20 2.34.1 From nobody Wed Feb 11 14:44:14 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 7D554C7EE26 for ; Mon, 8 May 2023 12:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234822AbjEHMkk (ORCPT ); Mon, 8 May 2023 08:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234784AbjEHMkb (ORCPT ); Mon, 8 May 2023 08:40:31 -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 ACB3237617; Mon, 8 May 2023 05:40:08 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id B0B3F21C4; Mon, 8 May 2023 12:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549319; bh=RFF6P7EkHf1hkymDTWXlt6hRdRdlKehS3PqSyelc73s=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=fUcsF5piYtEjDGuyLyMFDW/QqOGqHhyeGHsh/0+9PX5wKbUqoxcTrNs4k5Ji/KYoP iCdSbVJWgklXm7MY7EhQoCLd0Xsowoa3zuJf9688DK0n8nQasEa6C3AtNt7+zTadAn J/J21amew2bNGjOwBlYHCx8YMloXkZ3ek9s7BpzE= 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 5C46F2191; Mon, 8 May 2023 12:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1683549606; bh=RFF6P7EkHf1hkymDTWXlt6hRdRdlKehS3PqSyelc73s=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=uZVKbqli9+/XIjR++PSHIkbD1cAzkkdEVeAvvsj604rYOK9vnNGqCbgVQ+yTuwiEh bsOeSb7M83X+Yu6i8BvLGDuNeIf2cW3jr8wtyEi/jc2ZK73BIgHXfSWVqaDKn9H1Ui H6okkeg7NHGXAVuPRd5QlxxD/+sIzGXZNjkNpDyg= 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:40:05 +0300 Message-ID: <6de6e6ca-f5fb-42b1-9447-591f5c81a356@paragon-software.com> Date: Mon, 8 May 2023 16:40:05 +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 10/10] fs/ntfs3: Add support /proc/fs/ntfs3//volinfo and /proc/fs/ntfs3//label 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 Metafile /proc/fs/ntfs3//label allows to read/write current ntfs label. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fsntfs.c=C2=A0 |=C2=A0 58 ++++++++++++++++++++ =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0=C2=A0 5 +- =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0 | 134 +++++++++++++++++++++++++++++++++= ++++++++++++ =C2=A03 files changed, 195 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 1c05c088d1c6..33afee0f5559 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -9,6 +9,7 @@ =C2=A0#include =C2=A0#include =C2=A0#include +#include =C2=A0#include "debug.h" =C2=A0#include "ntfs.h" @@ -2619,3 +2620,60 @@ bool valid_windows_name(struct ntfs_sb_info *sbi,=20 const struct le_str *fname) =C2=A0=C2=A0=C2=A0 =C2=A0return !name_has_forbidden_chars(fname) && =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !is_reserved= _name(sbi, fname); =C2=A0} + +/* + * ntfs_set_label - updates current ntfs label. + */ +int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len) +{ +=C2=A0=C2=A0 =C2=A0int err; +=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; +=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni =3D sbi->volume.ni; +=C2=A0=C2=A0 =C2=A0const u8 max_ulen =3D 0x80; /* TODO: use attrdef to get= maximum length */ +=C2=A0=C2=A0 =C2=A0/* Allocate PATH_MAX bytes. */ +=C2=A0=C2=A0 =C2=A0struct cpu_str *uni =3D __getname(); + +=C2=A0=C2=A0 =C2=A0if (!uni) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; + +=C2=A0=C2=A0 =C2=A0err =3D ntfs_nls_to_utf16(sbi, label, len, uni, (PATH_M= AX - 2) / 2, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0UTF16_LITTLE_ENDIAN); +=C2=A0=C2=A0 =C2=A0if (err < 0) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; + +=C2=A0=C2=A0 =C2=A0if (uni->len > max_ulen) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn(sbi->sb, "new label is too= long"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EFBIG; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0ni_lock(ni); + +=C2=A0=C2=A0 =C2=A0/* Ignore any errors. */ +=C2=A0=C2=A0 =C2=A0ni_remove_attr(ni, ATTR_LABEL, NULL, 0, false, NULL); + +=C2=A0=C2=A0 =C2=A0err =3D ni_insert_resident(ni, uni->len * sizeof(u16), = ATTR_LABEL, NULL, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 0, &attr, NULL, NULL); +=C2=A0=C2=A0 =C2=A0if (err < 0) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto unlock_out; + +=C2=A0=C2=A0 =C2=A0/* write new label in on-disk struct. */ +=C2=A0=C2=A0 =C2=A0memcpy(resident_data(attr), uni->name, uni->len * sizeo= f(u16)); + +=C2=A0=C2=A0 =C2=A0/* update cached value of current label. */ +=C2=A0=C2=A0 =C2=A0if (len >=3D ARRAY_SIZE(sbi->volume.label)) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0len =3D ARRAY_SIZE(sbi->volume.label= ) - 1; +=C2=A0=C2=A0 =C2=A0memcpy(sbi->volume.label, label, len); +=C2=A0=C2=A0 =C2=A0sbi->volume.label[len] =3D 0; +=C2=A0=C2=A0 =C2=A0mark_inode_dirty_sync(&ni->vfs_inode); + +unlock_out: +=C2=A0=C2=A0 =C2=A0ni_unlock(ni); + +=C2=A0=C2=A0 =C2=A0if (!err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D _ni_write_inode(&ni->vfs_ino= de, 0); + +out: +=C2=A0=C2=A0 =C2=A0__putname(uni); +=C2=A0=C2=A0 =C2=A0return err; +} \ No newline at end of file diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 00fa782fcada..629403ede6e5 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -276,7 +276,7 @@ struct ntfs_sb_info { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__le16 flags; // Cached curren= t VOLUME_INFO::flags,=20 VOLUME_FLAG_DIRTY. =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u8 major_ver; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u8 minor_ver; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0char label[65]; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0char label[256]; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bool real_dirty; // Real fs st= ate. =C2=A0=C2=A0=C2=A0 =C2=A0} volume; @@ -286,7 +286,6 @@ struct ntfs_sb_info { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 next_id; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u64 next_off; - =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__le32 def_security_id; =C2=A0=C2=A0=C2=A0 =C2=A0} security; @@ -314,6 +313,7 @@ struct ntfs_sb_info { =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_mount_options *options; =C2=A0=C2=A0=C2=A0 =C2=A0struct ratelimit_state msg_ratelimit; +=C2=A0=C2=A0 =C2=A0struct proc_dir_entry *procdir; =C2=A0}; =C2=A0/* One MFT record(usually 1024 bytes), consists of attributes. */ @@ -651,6 +651,7 @@ void mark_as_free_ex(struct ntfs_sb_info *sbi, CLST=20 lcn, CLST len, bool trim); =C2=A0int run_deallocate(struct ntfs_sb_info *sbi, const struct runs_tree = *run, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 bool trim); =C2=A0bool valid_windows_name(struct ntfs_sb_info *sbi, const struct le_st= r=20 *name); +int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len); =C2=A0/* Globals from index.c */ =C2=A0int indx_used_bit(struct ntfs_index *indx, struct ntfs_inode *ni,=20 size_t *bit); diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 7ab0a79c7d84..e36769eac7de 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -57,6 +57,7 @@ =C2=A0#include =C2=A0#include =C2=A0#include +#include =C2=A0#include =C2=A0#include @@ -441,6 +442,103 @@ static int ntfs_fs_reconfigure(struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0} +#ifdef CONFIG_PROC_FS +static struct proc_dir_entry *proc_info_root; + +/* + * ntfs3_volinfo: + * + * The content of /proc/fs/ntfs3//volinfo + * + * ntfs3.1 + * cluster size + * number of clusters +*/ +static int ntfs3_volinfo(struct seq_file *m, void *o) +{ +=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D m->private; +=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D sb->s_fs_info; + +=C2=A0=C2=A0 =C2=A0seq_printf(m, "ntfs%d.%d\n%u\n%zu\n", sbi->volume.major= _ver, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sbi->volume.minor_ver, = sbi->cluster_size, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sbi->used.bitmap.nbits); + +=C2=A0=C2=A0 =C2=A0return 0; +} + +static int ntfs3_volinfo_open(struct inode *inode, struct file *file) +{ +=C2=A0=C2=A0 =C2=A0return single_open(file, ntfs3_volinfo, pde_data(inode)= ); +} + +/* read /proc/fs/ntfs3//label */ +static int ntfs3_label_show(struct seq_file *m, void *o) +{ +=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D m->private; +=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D sb->s_fs_info; + +=C2=A0=C2=A0 =C2=A0seq_printf(m, "%s\n", sbi->volume.label); + +=C2=A0=C2=A0 =C2=A0return 0; +} + +/* write /proc/fs/ntfs3//label */ +static ssize_t ntfs3_label_write(struct file *file, const char __user=20 *buffer, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 size_t count, loff_t *ppos) +{ +=C2=A0=C2=A0 =C2=A0int err; +=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D pde_data(file_inode(file)); +=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D sb->s_fs_info; +=C2=A0=C2=A0 =C2=A0ssize_t ret =3D count; +=C2=A0=C2=A0 =C2=A0u8 *label =3D kmalloc(count, GFP_NOFS); + +=C2=A0=C2=A0 =C2=A0if (!label) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; + +=C2=A0=C2=A0 =C2=A0if (copy_from_user(label, buffer, ret)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ret =3D -EFAULT; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0while (ret > 0 && label[ret - 1] =3D=3D '\n') +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ret -=3D 1; + +=C2=A0=C2=A0 =C2=A0err =3D ntfs_set_label(sbi, label, ret); + +=C2=A0=C2=A0 =C2=A0if (err < 0) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "failed (%d) to write l= abel", err); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ret =3D err; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0*ppos +=3D count; +=C2=A0=C2=A0 =C2=A0ret =3D count; +out: +=C2=A0=C2=A0 =C2=A0kfree(label); +=C2=A0=C2=A0 =C2=A0return ret; +} + +static int ntfs3_label_open(struct inode *inode, struct file *file) +{ +=C2=A0=C2=A0 =C2=A0return single_open(file, ntfs3_label_show, pde_data(ino= de)); +} + +static const struct proc_ops ntfs3_volinfo_fops =3D { +=C2=A0=C2=A0 =C2=A0.proc_read =3D seq_read, +=C2=A0=C2=A0 =C2=A0.proc_lseek =3D seq_lseek, +=C2=A0=C2=A0 =C2=A0.proc_release =3D single_release, +=C2=A0=C2=A0 =C2=A0.proc_open =3D ntfs3_volinfo_open, +}; + +static const struct proc_ops ntfs3_label_fops =3D { +=C2=A0=C2=A0 =C2=A0.proc_read =3D seq_read, +=C2=A0=C2=A0 =C2=A0.proc_lseek =3D seq_lseek, +=C2=A0=C2=A0 =C2=A0.proc_release =3D single_release, +=C2=A0=C2=A0 =C2=A0.proc_open =3D ntfs3_label_open, +=C2=A0=C2=A0 =C2=A0.proc_write =3D ntfs3_label_write, +}; + +#endif + =C2=A0static struct kmem_cache *ntfs_inode_cachep; =C2=A0static struct inode *ntfs_alloc_inode(struct super_block *sb) @@ -515,6 +613,16 @@ static void ntfs_put_super(struct super_block *sb) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D sb->s_fs_info; +#ifdef CONFIG_PROC_FS +=C2=A0=C2=A0 =C2=A0// Remove /proc/fs/ntfs3/.. +=C2=A0=C2=A0 =C2=A0if (sbi->procdir) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0remove_proc_entry("label", sbi->proc= dir); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0remove_proc_entry("volinfo", sbi->pr= ocdir); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0remove_proc_entry(sb->s_id, proc_inf= o_root); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->procdir =3D NULL; +=C2=A0=C2=A0 =C2=A0} +#endif + =C2=A0=C2=A0=C2=A0 =C2=A0/* Mark rw ntfs as clear, if possible. */ =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_set_state(sbi, NTFS_DIRTY_CLEAR); @@ -1436,6 +1544,20 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kfree(boot2); =C2=A0=C2=A0=C2=A0 =C2=A0} +#ifdef CONFIG_PROC_FS +=C2=A0=C2=A0 =C2=A0/* Create /proc/fs/ntfs3/.. */ +=C2=A0=C2=A0 =C2=A0if (proc_info_root) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct proc_dir_entry *e =3D proc_mk= dir(sb->s_id, proc_info_root); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (e) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0proc_create_data(= "volinfo", S_IFREG | S_IRUGO, e, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0 &ntfs3_volinfo_fops, sb); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0proc_create_data(= "label", S_IFREG | S_IRUGO | S_IWUGO, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0 e, &ntfs3_label_fops, sb); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->procdir =3D = e; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0} +#endif + =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0put_inode_out: @@ -1630,6 +1752,12 @@ static int __init init_ntfs_fs(void) =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ENABLED(CONFIG_NTFS3_LZX_XPRESS)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0pr_info("ntfs3: Read-only LZX/= Xpress compression included\n"); + +#ifdef CONFIG_PROC_FS +=C2=A0=C2=A0 =C2=A0/* Create "/proc/fs/ntfs3" */ +=C2=A0=C2=A0 =C2=A0proc_info_root =3D proc_mkdir("fs/ntfs3", NULL); +#endif + =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs3_init_bitmap(); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return err; @@ -1661,6 +1789,12 @@ static void __exit exit_ntfs_fs(void) =C2=A0=C2=A0=C2=A0 =C2=A0kmem_cache_destroy(ntfs_inode_cachep); =C2=A0=C2=A0=C2=A0 =C2=A0unregister_filesystem(&ntfs_fs_type); =C2=A0=C2=A0=C2=A0 =C2=A0ntfs3_exit_bitmap(); + +#ifdef CONFIG_PROC_FS +=C2=A0=C2=A0 =C2=A0if (proc_info_root) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0remove_proc_entry("fs/ntfs3", NULL); +#endif + =C2=A0} =C2=A0MODULE_LICENSE("GPL"); --=20 2.34.1