yaffs direct: Fix more EROFS handling
authorCharles Manning <cdhmanning@gmail.com>
Mon, 29 Nov 2010 01:55:36 +0000 (14:55 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 29 Nov 2010 02:09:25 +0000 (15:09 +1300)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/yaffsfs.c

index e212d0b..577cb36 100644 (file)
@@ -1092,9 +1092,12 @@ int yaffsfs_do_write(int fd, const void *vbuf, unsigned int nbyte, int isPwrite,
                /* bad handle */
                yaffsfs_SetError(-EBADF);
                totalWritten = -1;
-       } else if( h && obj && (!h->writing || obj->my_dev->read_only)){
+       } else if(!h->writing){
                yaffsfs_SetError(-EINVAL);
                totalWritten=-1;
+       } else if(obj->my_dev->read_only){
+               yaffsfs_SetError(-EROFS);
+               totalWritten=-1;
        } else {
                if(h->append)
                        startPos = yaffs_get_obj_length(obj);
@@ -1316,7 +1319,7 @@ int yaffsfs_DoUnlink(const YCHAR *path,int isDirectory)
        else if(!obj)
                yaffsfs_SetError(-ENOENT);
        else if(obj->my_dev->read_only)
-               yaffsfs_SetError(-EINVAL);
+               yaffsfs_SetError(-EROFS);
        else if(!isDirectory && obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY)
                yaffsfs_SetError(-EISDIR);
        else if(isDirectory && obj->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY)