X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=direct%2Fyaffsfs.c;h=952ffacdbdf259901c5f3608b233210e03bf7bcc;hb=6f398a8b6eab8d0c61010c144f01d706dc0dad8b;hp=dedd76ca08138e26bb0b0c9573f53111a7e36652;hpb=1ebec0597a033cba1b18b32466bbd6b7dcfdcecb;p=yaffs2.git diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index dedd76c..952ffac 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -747,7 +747,20 @@ static struct yaffs_obj *yaffsfs_FindObject(struct yaffs_obj *relDir, if (dirOut) *dirOut = dir; - if (dir && *name) + /* At this stage we have looked up directory part and have the name part + * in name if there is one. + * + * eg /nand/x/ will give us a name of "" + * /nand/x will give us a name of "x" + * + * Since the name part might be "." or ".." which need to be fixed. + */ + if (dir && (yaffs_strcmp(name, _Y("..")) == 0)) { + dir = dir->parent; + obj = dir; + } else if (dir && (yaffs_strcmp(name, _Y(".")) == 0)) + obj = dir; + else if (dir && *name) obj = yaffs_find_by_name(dir, name); else obj = dir; @@ -840,7 +853,7 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, oflag &= ~(O_EXCL); /* O_TRUNC has no meaning if (O_CREAT | O_EXCL) is specified */ - if ((oflag & O_CREAT) & (oflag & O_EXCL)) + if ((oflag & O_CREAT) && (oflag & O_EXCL)) oflag &= ~(O_TRUNC); /* Todo: Are there any more flag combos to sanitise ? */ @@ -3428,6 +3441,7 @@ static yaffs_DIR *yaffsfs_opendir_reldir_no_lock(struct yaffs_obj *reldir, } obj = yaffsfs_FindObject(reldir, dirname, 0, 1, NULL, ¬Dir, &loop); + obj = yaffsfs_FollowLink(obj, 0, &loop); if (!obj && notDir) yaffsfs_SetError(-ENOTDIR);