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 d9be490..9ac08ab 100644 (file)
@@ -1637,7 +1637,10 @@ int yaffs_mkdir(const YCHAR *path, mode_t mode)
 
        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)