Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Steve French <sfrench@samba.org>, Paulo Alcantara <pc@manguebit.com>
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] cifs: Improve SMB2+ stat() to work also on non-present name surrogate reparse points
Date: Tue, 31 Dec 2024 23:35:12 +0100	[thread overview]
Message-ID: <20241231223514.15595-3-pali@kernel.org> (raw)
In-Reply-To: <20241231223514.15595-1-pali@kernel.org>

SMB server returns STATUS_OBJECT_PATH_NOT_FOUND if the path exists, is the
reparse point of name surrogate type (e.g. mount point) and surrogate
target location does not exist.

So if the server returns STATUS_OBJECT_PATH_NOT_FOUND error then it is
required to send request again with OPEN_REPARSE_POINT flag. This is needed
to distinguish between path does not exist and path exists and points to
non-existent surrogate location.

Before this change, Linux SMB client returned for non-present name
surrogate reparse point -ENOENT error. With this change it correctly
returns that the entry exits, it is of directory type with filled stat
information.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 fs/smb/client/smb2inode.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 0b8d6d8f724d..b6342b043073 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -958,6 +958,18 @@ int smb2_query_path_info(const unsigned int xid,
 	if (!hdr || out_buftype[0] == CIFS_NO_BUFFER)
 		goto out;
 
+	/*
+	 * SMB server returns STATUS_OBJECT_PATH_NOT_FOUND if the path exists,
+	 * is the reparse point of name surrogate type (e.g. mount point) and
+	 * surrogate target location does not exist.
+	 * So if the server returns STATUS_OBJECT_PATH_NOT_FOUND error then it
+	 * is required to send request again with OPEN_REPARSE_POINT flag.
+	 * Re-opening with OPEN_REPARSE_POINT is done in the case when rc is
+	 * -EOPNOTSUPP.
+	 */
+	if (hdr->Status == STATUS_OBJECT_PATH_NOT_FOUND)
+		rc = -EOPNOTSUPP;
+
 	switch (rc) {
 	case 0:
 		rc = parse_create_response(data, cifs_sb, full_path, &out_iov[0]);
-- 
2.20.1


  parent reply	other threads:[~2024-12-31 22:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-31 22:35 [PATCH 1/5] cifs: Fix access_flags_to_smbopen_mode Pali Rohár
2024-12-31 22:35 ` [PATCH 2/5] cifs: Do not add FILE_READ_ATTRIBUTES when using GENERIC_READ/EXECUTE/ALL Pali Rohár
2024-12-31 22:35 ` Pali Rohár [this message]
2024-12-31 22:35 ` [PATCH 4/5] cifs: Improve SMB2+ stat() to work also for paths in DELETE_PENDING state Pali Rohár
2024-12-31 22:35 ` [PATCH 5/5] cifs: Improve detect_directory_symlink_target() function Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241231223514.15595-3-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pc@manguebit.com \
    --cc=sfrench@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox