提交 805a67ae 编写于 作者: O openharmony_ci 提交者: Gitee

!661 文件系统Open性能优化

Merge pull request !661 from Far/master
......@@ -606,7 +606,7 @@ int fatfs_open(struct file *filep)
FIL *fp;
int ret;
fp = (FIL *)zalloc(sizeof(FIL));
fp = (FIL *)zalloc(sizeof(FIL) + SS(fs));
if (fp == NULL) {
ret = ENOMEM;
goto ERROR_EXIT;
......@@ -630,19 +630,13 @@ int fatfs_open(struct file *filep)
fp->err = 0;
fp->sect = 0;
fp->fptr = 0;
fp->buf = (BYTE*) ff_memalloc(SS(fs));
if (fp->buf == NULL) {
ret = ENOMEM;
goto ERROR_UNLOCK;
}
fp->buf = (BYTE *)fp + sizeof(FIL);
LOS_ListAdd(&finfo->fp_list, &fp->fp_entry);
unlock_fs(fs, FR_OK);
filep->f_priv = fp;
return fatfs_sync(vp->originMount->mountFlags, fs);
return 0;
ERROR_UNLOCK:
unlock_fs(fs, FR_OK);
ERROR_FREE:
free(fp);
ERROR_EXIT:
......@@ -672,7 +666,6 @@ int fatfs_close(struct file *filep)
}
#endif
LOS_ListDelete(&fp->fp_entry);
ff_memfree(fp->buf);
free(fp);
filep->f_priv = NULL;
EXIT:
......
......@@ -163,6 +163,7 @@ int VnodeDevInit(void);
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **vnode);
int VnodeFree(struct Vnode *vnode);
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags);
int VnodeLookupAt(const char *path, struct Vnode **vnode, uint32_t flags, struct Vnode *orgVnode);
int VnodeHold(void);
int VnodeDrop(void);
......
......@@ -388,7 +388,7 @@ int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struc
}
}
if (normalizedPath[0] == '/' && normalizedPath[1] == '\0') {
if (normalizedPath[1] == '\0' && normalizedPath[0] == '/') {
*result = g_rootVnode;
free(normalizedPath);
return LOS_OK;
......@@ -447,6 +447,11 @@ int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags)
return VnodeLookupAt(path, vnode, flags, NULL);
}
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags)
{
return VnodeLookupAt(fullpath, vnode, flags, g_rootVnode);
}
static void ChangeRootInternal(struct Vnode *rootOld, char *dirname)
{
int ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册