X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=direct%2Fyaffsfs.c;h=b93f29534962ac909489f81cfcfd91a17532fdd1;hb=ca0474074161712816ce1ead07dcc83c4e2ebe29;hp=fc68b969e017c9a82af5b66452f95cfdfae87408;hpb=f792554ed6d0b514dfb040097033417d8e41f420;p=yaffs2.git diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index fc68b96..b93f295 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -573,12 +573,21 @@ int yaffs_open(const YCHAR *path, int oflag, int mode) if(obj) obj = yaffs_GetEquivalentObject(obj); - if(obj && obj->variantType != YAFFS_OBJECT_TYPE_FILE) + if(obj && + obj->variantType != YAFFS_OBJECT_TYPE_FILE && + obj->variantType != YAFFS_OBJECT_TYPE_DIRECTORY) obj = NULL; if(obj){ - /* The file already exists */ + /* The file already exists or it might be a directory */ + + /* If it is a directory then we can't open it as a file */ + if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY){ + openDenied = 1; + yaffsfs_SetError(-EISDIR); + errorReported = 1; + } /* Open should fail if O_CREAT and O_EXCL are specified since * the file exists @@ -1702,7 +1711,7 @@ int yaffs_sync(const YCHAR *path) yaffs_FlushEntireDeviceCache(dev); yaffs_CheckpointSave(dev); - + retVal = 0; } else /* todo error - not mounted. */