Only allow directory reads at the root level

This commit is contained in:
pjht 2024-11-08 14:54:01 -06:00
parent 6288fbbd31
commit 13238344bf
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A

View File

@ -25,7 +25,15 @@ impl fs_rpc::Server for Serv {
Ok((Some(device_pid), fd))
}
fn open_dir(&self, _path: &std::path::Path, _mount_id: u64) -> Result<(Option<u64>, u64), Errno> {
fn open_dir(&self, path: &std::path::Path, _mount_id: u64) -> Result<(Option<u64>, u64), Errno> {
let path = path.to_str().ok_or(Errno::EINVALDAT)?;
if !path.is_empty() {
if self.devices.read().contains_key(path) {
return Err(Errno::ENOTDIR);
} else {
return Err(Errno::ENOENT);
}
}
let entries = self.devices.read().keys().cloned().collect::<Vec<_>>();
self.dirs
.write()