From 93f7ec7a558dba356dcf609fedad361adf629b18 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott <ian@iandouglasscott.com> Date: Fri, 11 Aug 2017 18:31:42 -0700 Subject: [PATCH] Make it not an error to open a directory without O_DIRECTORY or O_STAT POSIX says this should work, and some software seems to rely on that. --- mount/redox/scheme.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mount/redox/scheme.rs b/mount/redox/scheme.rs index 0190eba..ffe888e 100644 --- a/mount/redox/scheme.rs +++ b/mount/redox/scheme.rs @@ -189,12 +189,7 @@ impl Scheme for FileScheme { Some(node) => if flags & (O_CREAT | O_EXCL) == O_CREAT | O_EXCL { return Err(Error::new(EEXIST)); } else if node.1.is_dir() { - if flags & O_STAT != O_STAT && flags & O_DIRECTORY != O_DIRECTORY { - // println!("{:X} & {:X}: EISDIR {}", flags, O_DIRECTORY, path); - return Err(Error::new(EISDIR)); - } - - if flags & O_ACCMODE == O_RDONLY { + if flags & O_ACCMODE == O_RDONLY && flags & O_DIRECTORY == O_DIRECTORY { if ! node.1.permission(uid, gid, Node::MODE_READ) { // println!("dir not readable {:o}", node.1.mode); return Err(Error::new(EACCES)); @@ -214,11 +209,11 @@ impl Scheme for FileScheme { } Box::new(DirResource::new(path.to_string(), node.0, data)) - } else if flags & O_STAT == O_STAT { - Box::new(DirResource::new(path.to_string(), node.0, Vec::new())) + } else if flags & O_RDONLY == O_RDONLY || flags & O_WRONLY == O_WRONLY { + // println!("{:X} & {:X}: EISDIR {}", flags, O_DIRECTORY, path); + return Err(Error::new(EISDIR)); } else { - // println!("dir not opened with O_RDONLY"); - return Err(Error::new(EACCES)); + Box::new(DirResource::new(path.to_string(), node.0, Vec::new())) } } else if node.1.is_symlink() && !(flags & O_STAT == O_STAT && flags & O_NOFOLLOW == O_NOFOLLOW) && flags & O_SYMLINK != O_SYMLINK { let mut resolve_nodes = Vec::new(); -- GitLab