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) {
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;