yaffs direct: Fix EROFS handling for yaffs_access
[yaffs2.git] / direct / yaffsfs.c
index e3f6fb04d03ff15da2777fdeb08d58021761f506..f6654cf8e79981bda0526ef43bbd88613a65f85d 100644 (file)
@@ -1183,6 +1183,7 @@ int yaffs_truncate(const YCHAR *path,off_t new_size)
        yaffsfs_Lock();
 
        obj = yaffsfs_FindObject(NULL,path,0,1,&dir,&notDir,&loop);
+       obj = yaffsfs_FollowLink(obj,0,&loop);
 
        if(!dir && notDir)
                yaffsfs_SetError(-ENOTDIR);
@@ -1962,7 +1963,9 @@ int yaffs_access(const YCHAR *path, int amode)
                yaffsfs_SetError(-ELOOP);
        else if(!dir || !obj) 
                yaffsfs_SetError(-ENOENT);
-       else {
+       else if((amode & W_OK) && obj->my_dev->read_only)
+               yaffsfs_SetError(-EROFS);
+       else{
                int access_ok = 1;
 
                if((amode & R_OK) && !(obj->yst_mode & S_IREAD))