diff --git a/fs/driver/fs_blockproxy.c b/fs/driver/fs_blockproxy.c index 2950a5feea42a227fa9084ce3a602457b11de366..9bfedd4a1b050f79111a34247424914f4879fede 100755 --- a/fs/driver/fs_blockproxy.c +++ b/fs/driver/fs_blockproxy.c @@ -227,7 +227,9 @@ int block_proxy(FAR const char *blkdev, int oflags) VnodeDrop(); /* Block char device is no need for file mapping */ +#ifdef LOSCFG_KERNEL_VM (void)remove_mapping(chardev); +#endif /* Free the allocate character driver name and return the open file * descriptor. diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index 35164a4e3dd3afdef80815116c44cced5c0aa19e..8d4179b62d4aee40be2992892891e64d35319b78 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -507,7 +507,6 @@ int files_allocate(struct Vnode *vnode_ptr, int oflags, off_t pos, void *priv, i static int files_close_internal(int fd, LosProcessCB *processCB) { int ret = OK; - struct file *filep = NULL; struct filelist *list = NULL; struct files_struct *process_files = NULL; @@ -544,15 +543,18 @@ static int files_close_internal(int fd, LosProcessCB *processCB) /* The filep->f_refcount may not be zero here, when the filep is shared in parent-child processes. so, upon closing the filep in current process, relevant region must be released immediately */ - - filep = &list->fl_files[fd]; +#ifdef LOSCFG_KERNEL_VM + struct file *filep = &list->fl_files[fd]; OsVmmFileRegionFree(filep, processCB); +#endif list->fl_files[fd].f_refcount--; if (list->fl_files[fd].f_refcount == 0) { +#ifdef LOSCFG_KERNEL_VM dec_mapping_nolock(filep->f_mapping); +#endif ret = _files_close(&list->fl_files[fd]); if (ret == OK) { diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index c89c69bf63b5becdaa5f5d988dfe547b09d9b98d..40d0ae0b0488fff1cbf60157aa8f8973302e136f 100755 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -305,7 +305,9 @@ int fp_open(char *fullpath, int oflags, mode_t mode) /* we do not bother to handle the NULL scenario, if so, page-cache feature will not be used * when we do the file fault */ +#ifdef LOSCFG_KERNEL_VM add_mapping(filep, fullpath); +#endif return fd; diff --git a/fs/vfs/fs_unlink.c b/fs/vfs/fs_unlink.c index 4936457dbd431836de6bf9903a4a5bfe437b1c70..13888675dfb9e86069adae5ed976d0d0eb8c63c9 100644 --- a/fs/vfs/fs_unlink.c +++ b/fs/vfs/fs_unlink.c @@ -140,7 +140,9 @@ int do_unlink(int dirfd, const char *pathname) VnodeFree(vnode); VnodeDrop(); +#ifdef LOSCFG_KERNEL_VM (void)remove_mapping(fullpath); +#endif /* Successfully unlinked */ free(fullpath);