ksmbd: treat unnamed DATA stream as base file

The SMB path suffix :: names the unnamed data stream of the base
file, not an alternate data stream backed by a DosStream xattr.

Canonicalize an empty stream name with an explicit  type to a NULL
stream name after parsing. This keeps the base filename produced by
strsep() and lets open continue through the normal base-file path instead
of looking for a non-existent empty stream xattr.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Namjae Jeon
2026-06-18 10:36:17 +09:00
committed by Steve French
parent 80a56d4a82
commit 171b5d72dd

View File

@@ -121,7 +121,9 @@ int parse_stream_name(char *filename, char **stream_name, int *s_type)
char *stream_type;
char *s_name;
int rc = 0;
bool has_stream_type = false;
*stream_name = NULL;
s_name = filename;
filename = strsep(&s_name, ":");
ksmbd_debug(SMB, "filename : %s, streams : %s\n", filename, s_name);
@@ -137,14 +139,20 @@ int parse_stream_name(char *filename, char **stream_name, int *s_type)
ksmbd_debug(SMB, "stream name : %s, stream type : %s\n", s_name,
stream_type);
if (!strncasecmp("$data", stream_type, 5))
if (!strncasecmp("$data", stream_type, 5)) {
*s_type = DATA_STREAM;
else if (!strncasecmp("$index_allocation", stream_type, 17))
has_stream_type = true;
} else if (!strncasecmp("$index_allocation", stream_type, 17)) {
*s_type = DIR_STREAM;
else
has_stream_type = true;
} else {
rc = -ENOENT;
}
}
if (has_stream_type && !s_name[0] && *s_type == DATA_STREAM)
goto out;
*stream_name = s_name;
out:
return rc;