yaffs Fix problem trying to mkdir a mountpt in yaffs direct
authorCharles Manning <cdhmanning@gmail.com>
Mon, 23 Aug 2010 22:12:15 +0000 (10:12 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 23 Aug 2010 22:12:15 +0000 (10:12 +1200)
yaffs_mkdir would create a directory if you passed the name of
a mount point. This change fails such attempts with -EEXIST.

tested with:
"yaffs2"
"/yaffs2"
"/yaffs2/"
"/yaffs2///////"
"yaffs2////"

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/yaffsfs.c

index d9be4907e2064d5d1f3d8d76ff2f9632fa43c272..9ac08abb15be867cd69da6e466cd54523cfbf57a 100644 (file)
@@ -1637,7 +1637,10 @@ int yaffs_mkdir(const YCHAR *path, mode_t mode)
 
        yaffsfs_Lock();
        parent = yaffsfs_FindDirectory(NULL,path,&name,0);
 
        yaffsfs_Lock();
        parent = yaffsfs_FindDirectory(NULL,path,&name,0);
-       if(parent && parent->myDev->readOnly){
+       if(parent && yaffs_strnlen(name,5) == 0){
+               /* Trying to make the root itself */
+               yaffsfs_SetError(-EEXIST);
+       } else if(parent && parent->myDev->readOnly){
                yaffsfs_SetError(-EINVAL);
        } else {
                if(parent)
                yaffsfs_SetError(-EINVAL);
        } else {
                if(parent)