diff --git a/fs/vfs/fs_symlink.c b/fs/vfs/fs_symlink.c index 1bf94f13caf8672a2c221dfe526e212ca3c320ed..dcc8c7df0f00b1def2f99a387fac311099f77103 100644 --- a/fs/vfs/fs_symlink.c +++ b/fs/vfs/fs_symlink.c @@ -37,14 +37,13 @@ int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **ful { int ret; struct Vnode *newvnode = NULL; - char pathname[PATH_MAX] = {0}; + char *pathname = (char *)path; + char buffer[PATH_MAX] = {0}; if (path == NULL) { return -EINVAL; } - (void)strcpy_s(pathname, PATH_MAX, path); - for (int i = 0; i < CONFIG_FS_MAX_LNK_CNT; i++) { if (*fullpath) @@ -59,7 +58,7 @@ int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **ful return ret; } - ret = VnodeLookup(*fullpath, &newvnode, 0); + ret = VnodeLookupFullpath(*fullpath, &newvnode, 0); if (ret != OK) { /* The object of fullpath is not exist. Return its parent's vnode. */ @@ -79,7 +78,7 @@ int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **ful } /* The object of fullpath is a symbol link. Read its target and find the source file successively. */ - (void)memset_s(pathname, PATH_MAX, 0, PATH_MAX); + pathname = buffer; ret = newvnode->vop->Readlink(newvnode, pathname, PATH_MAX); if (ret < 0) {