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

!661 文件系统Open性能优化

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