yaffs direct: Fix more error handling
authorCharles Manning <cdhmanning@gmail.com>
Mon, 29 Nov 2010 02:09:11 +0000 (15:09 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 29 Nov 2010 02:24:35 +0000 (15:24 +1300)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/yaffsfs.c

index 577cb36..5194dd4 100644 (file)
@@ -1210,7 +1210,7 @@ int yaffs_truncate(const YCHAR *path,off_t new_size)
        else if(obj->variant_type != YAFFS_OBJECT_TYPE_FILE)
                yaffsfs_SetError(-EISDIR);
        else if(obj->my_dev->read_only)
-               yaffsfs_SetError(-EACCES);
+               yaffsfs_SetError(-EROFS);
        else if(new_size < 0 || new_size > YAFFS_MAX_FILE_SIZE)
                yaffsfs_SetError(-EINVAL);
        else
@@ -1234,6 +1234,8 @@ int yaffs_ftruncate(int fd, off_t new_size)
        if(!h || !obj)
                /* bad handle */
                yaffsfs_SetError(-EBADF);
+       else if(!h->writing)
+               yaffsfs_SetError(-EINVAL);
        else if(obj->my_dev->read_only)
                yaffsfs_SetError(-EROFS);
        else if( new_size < 0 || new_size > YAFFS_MAX_FILE_SIZE)