SMB fixes: IPC$ ShareMode=Public, capabilities=0, FILE_ID_BOTH_DIRECTORY_INFORMATION Reserved2 removed, NextEntryOffset=0 for last entry, debug logging

This commit is contained in:
Warren
2026-06-23 03:22:39 +08:00
parent bb796ec6b9
commit 8ef1406ed3
8 changed files with 55 additions and 19 deletions

View File

@@ -306,16 +306,20 @@ impl ShareBackend for LocalFsBackend {
}
match opts.intent {
OpenIntent::Open | OpenIntent::OpenOrCreate => {
let root = Arc::clone(&self.root);
let rel = rel.clone();
let dir_handle = spawn_blocking(move || root.open_dir(&rel))
.await
.map_err(join_to_io)
.map_err(io_to_smb)?
.map_err(io_to_smb)?;
let dir_handle = if path.is_root() {
Arc::clone(&self.root)
} else {
let root = Arc::clone(&self.root);
let rel = rel.clone();
Arc::new(spawn_blocking(move || root.open_dir(&rel))
.await
.map_err(join_to_io)
.map_err(io_to_smb)?
.map_err(io_to_smb)?)
};
return Ok(Box::new(LocalHandle::Dir {
name: file_name_for(path),
dir_handle: Arc::new(dir_handle),
dir_handle,
}));
}
OpenIntent::Create => return Err(SmbError::Exists),
@@ -696,21 +700,19 @@ impl Handle for LocalHandle {
let entry = entry?;
let os_name = entry.file_name();
let Some(name) = os_name.to_str().map(str::to_owned) else {
// Skip non-UTF-8 names; SMB wire format is UTF-16
// and we never want to emit invalid Unicode here.
continue;
};
if let Some(p) = pat.as_deref() {
// Empty / "*" / "*.*" all mean "match everything"
// in DOS-speak.
if !(p.is_empty() || p == "*" || p == "*.*" || glob_match(p, &name)) {
continue;
}
}
let md = entry.metadata()?;
let info = file_info_from_metadata(name, &md);
tracing::debug!(name = %info.name, is_dir = %info.is_directory, "list_dir entry");
out.push(SmbDirEntry { info });
}
tracing::debug!(count = %out.len(), "list_dir complete");
Ok(out)
})
.await