Implement SMB AFP_AfpInfo read/write via xattr (Phase 2.8 complete)
This commit is contained in:
65
vendor/smb-server/src/fs/local.rs
vendored
65
vendor/smb-server/src/fs/local.rs
vendored
@@ -428,6 +428,71 @@ impl ShareBackend for LocalFsBackend {
|
||||
case_sensitive: cfg!(any(target_os = "linux", target_os = "freebsd")),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_xattr(&self, path: &SmbPath, name: &str) -> SmbResult<Vec<u8>> {
|
||||
let rel = to_rel_path(path);
|
||||
let root = Arc::clone(&self.root);
|
||||
let xattr_name = name.to_string();
|
||||
|
||||
spawn_blocking(move || {
|
||||
let full_path = root.join(&rel);
|
||||
xattr::get(full_path.as_std_path(), &xattr_name)
|
||||
.map_err(|e| SmbError::Io(e.into()))
|
||||
})
|
||||
.await
|
||||
.map_err(join_to_io)?
|
||||
}
|
||||
|
||||
async fn set_xattr(&self, path: &SmbPath, name: &str, value: &[u8]) -> SmbResult<()> {
|
||||
if self.read_only {
|
||||
return Err(SmbError::AccessDenied);
|
||||
}
|
||||
|
||||
let rel = to_rel_path(path);
|
||||
let root = Arc::clone(&self.root);
|
||||
let xattr_name = name.to_string();
|
||||
let value = value.to_vec();
|
||||
|
||||
spawn_blocking(move || {
|
||||
let full_path = root.join(&rel);
|
||||
xattr::set(full_path.as_std_path(), &xattr_name, &value)
|
||||
.map_err(|e| SmbError::Io(e.into()))
|
||||
})
|
||||
.await
|
||||
.map_err(join_to_io)?
|
||||
}
|
||||
|
||||
async fn remove_xattr(&self, path: &SmbPath, name: &str) -> SmbResult<()> {
|
||||
if self.read_only {
|
||||
return Err(SmbError::AccessDenied);
|
||||
}
|
||||
|
||||
let rel = to_rel_path(path);
|
||||
let root = Arc::clone(&self.root);
|
||||
let xattr_name = name.to_string();
|
||||
|
||||
spawn_blocking(move || {
|
||||
let full_path = root.join(&rel);
|
||||
xattr::remove(full_path.as_std_path(), &xattr_name)
|
||||
.map_err(|e| SmbError::Io(e.into()))
|
||||
})
|
||||
.await
|
||||
.map_err(join_to_io)?
|
||||
}
|
||||
|
||||
async fn list_xattrs(&self, path: &SmbPath) -> SmbResult<Vec<String>> {
|
||||
let rel = to_rel_path(path);
|
||||
let root = Arc::clone(&self.root);
|
||||
|
||||
spawn_blocking(move || {
|
||||
let full_path = root.join(&rel);
|
||||
xattr::list(full_path.as_std_path())
|
||||
.map(|attrs| attrs.into_iter().map(|s| s.to_string()).collect())
|
||||
.map_err(|e| SmbError::Io(e.into()))
|
||||
})
|
||||
.await
|
||||
.map_err(join_to_io)?
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user