#include "string.h"
+#define YAFFS_MAX_RW_SIZE 0x70000000
#define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
#ifndef NULL
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) {
/* Not a reading handle */
yaffsfs_SetError(-EINVAL);
totalRead = -1;
- } else if (nbyte > YAFFS_MAX_FILE_SIZE) {
+ } else if (nbyte > YAFFS_MAX_RW_SIZE) {
yaffsfs_SetError(-EINVAL);
totalRead = -1;
} else {
endPos = pos + nbyte;
if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE ||
- nbyte > YAFFS_MAX_FILE_SIZE ||
+ nbyte > YAFFS_MAX_RW_SIZE ||
endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
totalRead = -1;
nbyte = 0;
while (nbyte > 0) {
nToRead = YAFFSFS_RW_SIZE -
(pos & (YAFFSFS_RW_SIZE - 1));
- if (nToRead > nbyte)
+ if (nToRead > (int)nbyte)
nToRead = nbyte;
/* Tricky bit...
endPos = pos + nbyte;
if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE ||
- nbyte > YAFFS_MAX_FILE_SIZE ||
+ nbyte > YAFFS_MAX_RW_SIZE ||
endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
totalWritten = -1;
nbyte = 0;
nToWrite = YAFFSFS_RW_SIZE -
(pos & (YAFFSFS_RW_SIZE - 1));
- if (nToWrite > nbyte)
+ if (nToWrite > (int)nbyte)
nToWrite = nbyte;
/* Tricky bit...
{
struct yaffsfs_FileDes *fdp = yaffsfs_HandleToFileDes(fd);
int retVal;
-
+
yaffsfs_Lock();
if(!flags || !fdp) {
*flags = O_RDONLY;
retVal = 0;
}
-
+
yaffsfs_Unlock();
return retVal;
}
obj = yaffs_get_equivalent_obj(obj);
if (obj && buf) {
- buf->st_dev = (int)obj->my_dev->os_context;
+ buf->st_dev = 0;
buf->st_ino = obj->obj_id;
buf->st_mode = obj->yst_mode & ~S_IFMT;
if (dsc->nextReturn) {
dsc->de.d_ino =
yaffs_get_equivalent_obj(dsc->nextReturn)->obj_id;
- dsc->de.d_dont_use = (unsigned)dsc->nextReturn;
+ dsc->de.d_dont_use = 0;
dsc->de.d_off = dsc->offset++;
yaffs_get_obj_name(dsc->nextReturn,
dsc->de.d_name, NAME_MAX);
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;