From: Charles Manning Date: Mon, 3 Apr 2017 04:49:42 +0000 (+1200) Subject: yaffs direct: Fix opening of a directory. X-Git-Tag: aleph1-release~3 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=5e0db4930940ade57ea3bf3dce0d3db0362a9f0e yaffs direct: Fix opening of a directory. If opening a directory using yaffs_open(), Yaffs Direct was checking that the file was being opened with O_RDONLY. In fact those flags should actually be ignored and it should be treated as if opened O_RDONLY. Therefore override flags if opening a directory. Signed-off-by: Charles Manning --- diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 7647444..8593cbe 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -893,12 +893,14 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, is_dir = (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY); - /* A directory can't be opened except for read */ - if ( is_dir && - (writeRequested || !readRequested || rwflags != O_RDONLY)) { - openDenied = __LINE__; - yaffsfs_SetError(-EISDIR); - errorReported = __LINE__; + /* + * A directory can't be opened except for read, so we + * ignore other flags + */ + if (is_dir) { + writeRequested = 0; + readRequested = 1; + rwflags = O_RDONLY; } if(is_dir) { @@ -3635,7 +3637,7 @@ struct yaffs_dirent *yaffs_readdir_fd(int fd) yaffsfs_Lock(); f = yaffsfs_HandleToFileDes(fd); - if(f && f->isDir) + if(f && f->isDir && f->v.dir) ret = yaffsfs_readdir_no_lock(f->v.dir); yaffsfs_Unlock(); return ret;