From nobody Fri Sep 12 00:16:11 2025 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 51307C4167B for ; Wed, 6 Dec 2023 15:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442447AbjLFPJn (ORCPT ); Wed, 6 Dec 2023 10:09:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442406AbjLFPJl (ORCPT ); Wed, 6 Dec 2023 10:09:41 -0500 X-Greylist: delayed 99 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 06 Dec 2023 07:09:48 PST Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02ADDC6; Wed, 6 Dec 2023 07:09:47 -0800 (PST) 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 75DD71E1A; Wed, 6 Dec 2023 15:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875001; bh=Ifmg2OmIcc1e099M3eAc7+M0D09LHndtu4YB0fZ10AE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=CM28fQWfl2jtqKv/4Q00K5fqN1XehGPo+klnsLEdY+l3HE67RQZYkzBqf6GrkQUfr djhTyaAxCW/vH267eQpmpDRK6Px0x/CmTqlYadmRB8vyT2X9uyiv7/Ivcky6dxEE49 O+rzp55tAH/NRfKemZdi/99Qye5kO0nISMZtbgX8= Received: from [172.16.192.129] (192.168.211.144) 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; Wed, 6 Dec 2023 18:09:45 +0300 Message-ID: Date: Wed, 6 Dec 2023 18:09:45 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 02/16] fs/ntfs3: Modified fix directory element type detection Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.144] 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 Unfortunately reparse attribute is used for many purposes (several dozens). It is not possible here to know is this name symlink or not. To get exactly the type of name we should to open inode (read mft). getattr for opened file (fstat) correctly returns symlink. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/dir.c | 30 +++++++++++++++++++++++++----- =C2=A01 file changed, 25 insertions(+), 5 deletions(-) diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index ec0566b322d5..22ede4da0450 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -309,11 +309,31 @@ static inline int ntfs_filldir(struct ntfs_sb_info=20 *sbi, struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0/* NTFS: symlinks are "dir + reparse" or "file + repars= e" */ -=C2=A0=C2=A0 =C2=A0if (fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dt_type =3D DT_LNK; -=C2=A0=C2=A0 =C2=A0else -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dt_type =3D (fname->dup.fa & FILE_AT= TRIBUTE_DIRECTORY) ? DT_DIR :=20 DT_REG; +=C2=A0=C2=A0 =C2=A0/* +=C2=A0=C2=A0 =C2=A0 * NTFS: symlinks are "dir + reparse" or "file + repars= e" +=C2=A0=C2=A0 =C2=A0 * Unfortunately reparse attribute is used for many pur= poses=20 (several dozens). +=C2=A0=C2=A0 =C2=A0 * It is not possible here to know is this name symlink= or not. +=C2=A0=C2=A0 =C2=A0 * To get exactly the type of name we should to open in= ode (read mft). +=C2=A0=C2=A0 =C2=A0 * getattr for opened file (fstat) correctly returns sy= mlink. +=C2=A0=C2=A0 =C2=A0 */ +=C2=A0=C2=A0 =C2=A0dt_type =3D (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) = ? DT_DIR : DT_REG; + +=C2=A0=C2=A0 =C2=A0/* +=C2=A0=C2=A0 =C2=A0 * It is not reliable to detect the type of name using = duplicated=20 information +=C2=A0=C2=A0 =C2=A0 * stored in parent directory. +=C2=A0=C2=A0 =C2=A0 * The only correct way to get the type of name - read = MFT record=20 and find ATTR_STD. +=C2=A0=C2=A0 =C2=A0 * The code below is not good idea. +=C2=A0=C2=A0 =C2=A0 * It does additional locks/reads just to get the type = of name. +=C2=A0=C2=A0 =C2=A0 * Should we use additional mount option to enable bran= ch below? +=C2=A0=C2=A0 =C2=A0 */ +=C2=A0=C2=A0 =C2=A0if ((fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT) && +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 ino !=3D ni->mi.rno) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct inode *inode =3D ntfs_iget5(s= bi->sb, &e->ref, NULL); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!IS_ERR_OR_NULL(inode)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dt_type =3D fs_um= ode_to_dtype(inode->i_mode); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0iput(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=A0return !dir_emit(ctx, (s8 *)name, name_len, ino, = dt_type); =C2=A0} --=20 2.34.1