Skip to content

Commit d211efd

Browse files
committed
fix: return ErrorCode::IsDirectory if a directory is opened with DescriptorFlags::Write
1 parent 35228e7 commit d211efd

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

host/src/vfs/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,11 @@ impl<'a> filesystem::types::HostDescriptor for VfsCtxView<'a> {
753753
return Err(FsError::trap(ErrorCode::Invalid));
754754
}
755755

756+
if directory && flags.contains(DescriptorFlags::WRITE) {
757+
// Per POSIX: "O_DIRECTORY: "If path resolves to a non-directory file, fail and set errno to [ENOTDIR]."
758+
return Err(FsError::trap(ErrorCode::IsDirectory));
759+
}
760+
756761
// Try to resolve the path to an existing node
757762
let existing = self.get_node_from_start(&path, Arc::clone(&base_node));
758763

0 commit comments

Comments
 (0)