From mboxrd@z Thu Jan 1 00:00:00 1970 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 6CB30C4167D for ; Sun, 29 Oct 2023 22:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231407AbjJ2Wza (ORCPT ); Sun, 29 Oct 2023 18:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbjJ2WzO (ORCPT ); Sun, 29 Oct 2023 18:55:14 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D184B1BB; Sun, 29 Oct 2023 15:55:04 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C39AC433C8; Sun, 29 Oct 2023 22:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698620103; bh=E7esBqLyr0+1UTE13D8ejR5e9vkrfaQoW0PQHcPr7CY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hro/1mUoXWTdkLjZarRvCSA3XkZoUQ+mGhgkQ22HUboKPiRTCRZ73W77rNscTA0vS c51R1qWhAZVDrFp31hJYE9sQdivTpoX03hDMHWK4PHK8mVRcQwhFYFdaXrgqV33y+M XNRt3AEgZoTY6izMowAlzGSyTcsWi0Sgs+CRXOUfIO3s4u5Tl+B10N2CmZAMFHfQQ4 yfGnpVfvudTzJnug52CaUQCCNqIN8HqddWMFtNl9YH23k7X5Mfw4q7GsQ14CFJfS5/ q+9LWowC+gFPwNjtd8hkkOEXTx2OnzgazwWL1cl6fR3Ya4RtRbW9lFy0VtW8iWNCD7 H1S2ecgnwSV6Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gabriel Marcano , Konstantin Komarov , Sasha Levin , ntfs3@lists.linux.dev Subject: [PATCH AUTOSEL 6.5 14/52] fs/ntfs3: Fix directory element type detection Date: Sun, 29 Oct 2023 18:53:01 -0400 Message-ID: <20231029225441.789781-14-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231029225441.789781-1-sashal@kernel.org> References: <20231029225441.789781-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.9 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Gabriel Marcano [ Upstream commit 85a4780dc96ed9dd643bbadf236552b3320fae26 ] Calling stat() from userspace correctly identified junctions in an NTFS partition as symlinks, but using readdir() and iterating through the directory containing the same junction did not identify the junction as a symlink. When emitting directory contents, check FILE_ATTRIBUTE_REPARSE_POINT attribute to detect junctions and report them as links. Signed-off-by: Gabriel Marcano Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 063a6654199bc..ec0566b322d5d 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -309,7 +309,11 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni, return 0; } - dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG; + /* NTFS: symlinks are "dir + reparse" or "file + reparse" */ + if (fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT) + dt_type = DT_LNK; + else + dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG; return !dir_emit(ctx, (s8 *)name, name_len, ino, dt_type); } -- 2.42.0