yaffs direct: Dereference symlinks in chmod
[yaffs2.git] / direct / yaffsfs.c
index e3f6fb04d03ff15da2777fdeb08d58021761f506..c7937b075a04aa7f22410cef1139084446caf0bc 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))
@@ -2006,6 +2009,7 @@ int yaffs_chmod(const YCHAR *path, mode_t mode)
        yaffsfs_Lock();
 
        obj = yaffsfs_FindObject(NULL,path,0,1, &dir, &notDir,&loop);
+       obj = yaffsfs_FollowLink(obj,0,&loop);
 
        if(!dir && notDir) 
                yaffsfs_SetError(-ENOTDIR);