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 <cdhmanning@gmail.com>
is_dir = (obj->variant_type ==
YAFFS_OBJECT_TYPE_DIRECTORY);
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;
yaffsfs_Lock();
f = yaffsfs_HandleToFileDes(fd);
yaffsfs_Lock();
f = yaffsfs_HandleToFileDes(fd);
+ if(f && f->isDir && f->v.dir)
ret = yaffsfs_readdir_no_lock(f->v.dir);
yaffsfs_Unlock();
return ret;
ret = yaffsfs_readdir_no_lock(f->v.dir);
yaffsfs_Unlock();
return ret;