diff --git a/fs/fat/os_adapt/fatfs.c b/fs/fat/os_adapt/fatfs.c index 504e775561a6114d0ffa4b11b46f3d60fdd983e9..d8bf81b84f16973ceb203746b997ccbc022ccbb7 100644 --- a/fs/fat/os_adapt/fatfs.c +++ b/fs/fat/os_adapt/fatfs.c @@ -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: diff --git a/fs/vfs/include/vnode.h b/fs/vfs/include/vnode.h index 169a091595fe67f0b4b9debb44448fdbdbf35ab5..f04e1a11935824e21aaae28c76120cb25ce4e3bf 100644 --- a/fs/vfs/include/vnode.h +++ b/fs/vfs/include/vnode.h @@ -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); diff --git a/fs/vfs/vnode.c b/fs/vfs/vnode.c index c5933a3324185c9d3488af2d292e0c9baf59d7d6..c85665ac06b24918debe713ae565e4318c909b90 100644 --- a/fs/vfs/vnode.c +++ b/fs/vfs/vnode.c @@ -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;