[PATCH 07/12] cifs: Improve SMB1 stat() to work also for paths in DELETE_PENDING state

Pali Rohár
2024-12-31T22:37:10Z

Windows NT SMB server may return -EBUSY (STATUS_DELETE_PENDING) from
CIFSSMBQPathInfo() function for files which are in DELETE_PENDING state.
When this happens, it is still possible to use CIFSFindFirst() fallback.
So allow to use CIFSFindFirst() fallback also for -EBUSY error.

This change fixed stat() to work also against Windows Server 2022 for files
in DELETE_PENDING state.

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

diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c
index b0813106df16..a7a846260736 100644
--- a/fs/smb/client/smb1ops.c
+++ b/fs/smb/client/smb1ops.c
@@ -578,7 +578,7 @@ static int cifs_query_path_info(const unsigned int xid,
* so they cannot be used for querying paths with wildcard characters.
* Therefore for such paths returns -ENOENT as they cannot exist.
*/
- if ((rc == -EOPNOTSUPP || rc == -EINVAL) &&
+ if ((rc == -EOPNOTSUPP || rc == -EINVAL || rc == -EBUSY) &&
!(tcon->ses->capabilities & CAP_UNICODE) &&
strpbrk(full_path, "*?\"><"))
rc = -ENOENT;
@@ -587,7 +587,7 @@ static int cifs_query_path_info(const unsigned int xid,
* Then fallback to CIFSFindFirst() which works also with non-NT servers
* but does not does not provide NumberOfLinks.
*/
- if (rc == -EOPNOTSUPP || rc == -EINVAL) {
+ if (rc == -EOPNOTSUPP || rc == -EINVAL || rc == -EBUSY) {
search_info.info_level = SMB_FIND_FILE_FULL_DIRECTORY_INFO;
rc = CIFSFindFirst(xid, tcon, full_path, cifs_sb, NULL,
CIFS_SEARCH_CLOSE_ALWAYS | CIFS_SEARCH_CLOSE_AT_END,
--
2.20.1