提交 ab5bb707 编写于 作者: F Far

refactor: 文件系统open接口性能优化

优化包括:
1. 用VnodeLookupFullpath接口替代VnodeLookup;
2. 修改逻辑,减少strcpy和memset的调用

Close #I4E0CT
Signed-off-by: NFar <yesiyuan2@huawei.com>
上级 924604f7
......@@ -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)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册