cifs: Fix calling CIFSFindFirst() for root path without msearch

To query root path (without msearch wildcard) it is needed to
send pattern '\' instead of '' (empty string).

This allows to use CIFSFindFirst() to query information about root path
which is being used in followup changes.

This change fixes the stat() syscall called on the root path on the mount.
It is because stat() syscall uses the cifs_query_path_info() function and
it can fallback to the CIFSFindFirst() usage with msearch=false.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Pali Rohár 2024-12-30 20:54:11 +01:00 committed by Steve French
parent 33cfdd7263
commit b460249b9a

View File

@ -4020,6 +4020,12 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
pSMB->FileName[name_len] = 0;
pSMB->FileName[name_len+1] = 0;
name_len += 2;
} else if (!searchName[0]) {
pSMB->FileName[0] = CIFS_DIR_SEP(cifs_sb);
pSMB->FileName[1] = 0;
pSMB->FileName[2] = 0;
pSMB->FileName[3] = 0;
name_len = 4;
}
} else {
name_len = copy_path_name(pSMB->FileName, searchName);
@ -4031,6 +4037,10 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
pSMB->FileName[name_len] = '*';
pSMB->FileName[name_len+1] = 0;
name_len += 2;
} else if (!searchName[0]) {
pSMB->FileName[0] = CIFS_DIR_SEP(cifs_sb);
pSMB->FileName[1] = 0;
name_len = 2;
}
}