fs/file: unify prefix about file_xxx api, like file_open, file_ioctl

old:
fs_getfilep, fs_putfilep, fs_reffilep
new:
file_get, file_put, file_ref

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1 2025-06-07 14:30:28 +08:00 committed by Xiang Xiao
parent 9ca5c1d9c6
commit a12d21e830
49 changed files with 148 additions and 148 deletions

View file

@ -590,7 +590,7 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{ {
audinfo("AUDIOIOC_REGISTERMQ\n"); audinfo("AUDIOIOC_REGISTERMQ\n");
ret = fs_getfilep((mqd_t)arg, &upper->usermq); ret = file_get((mqd_t)arg, &upper->usermq);
} }
break; break;
@ -603,7 +603,7 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{ {
audinfo("AUDIOIOC_UNREGISTERMQ\n"); audinfo("AUDIOIOC_UNREGISTERMQ\n");
fs_putfilep(upper->usermq); file_put(upper->usermq);
upper->usermq = NULL; upper->usermq = NULL;
ret = OK; ret = OK;
} }

View file

@ -539,14 +539,14 @@ static int optee_close(FAR struct file *filep)
idr_for_each_entry(priv->shms, shm, id) idr_for_each_entry(priv->shms, shm, id)
{ {
if (shm->fd > -1 && fs_getfilep(shm->fd, &shm_filep) >= 0) if (shm->fd > -1 && fs_get(shm->fd, &shm_filep) >= 0)
{ {
/* The user did not call close(), prevent vfs auto-close from /* The user did not call close(), prevent vfs auto-close from
* double-freeing our SHM * double-freeing our SHM
*/ */
shm_filep->f_priv = NULL; shm_filep->f_priv = NULL;
fs_putfilep(shm_filep); fs_put(shm_filep);
} }
optee_shm_free(shm); optee_shm_free(shm);

View file

@ -943,7 +943,7 @@ static int telnet_session(FAR struct telnet_session_s *session)
} }
ret = psock_dup2(psock, &priv->td_psock); ret = psock_dup2(psock, &priv->td_psock);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: psock_dup2 failed: %d\n", ret); nerr("ERROR: psock_dup2 failed: %d\n", ret);

View file

@ -70,7 +70,7 @@ FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(aiocbp->aio_fildes, &filep); ret = file_get(aiocbp->aio_fildes, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -115,7 +115,7 @@ FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp)
return aioc; return aioc;
err_putfilep: err_putfilep:
fs_putfilep(filep); file_put(filep);
errout: errout:
set_errno(-ret); set_errno(-ret);
return NULL; return NULL;
@ -155,7 +155,7 @@ FAR struct aiocb *aioc_decant(FAR struct aio_container_s *aioc)
*/ */
aiocbp = aioc->aioc_aiocbp; aiocbp = aioc->aioc_aiocbp;
fs_putfilep(aioc->aioc_filep); file_put(aioc->aioc_filep);
aioc_free(aioc); aioc_free(aioc);
aio_unlock(); aio_unlock();

View file

@ -227,7 +227,7 @@ static void task_fssync(FAR struct tcb_s *tcb, FAR void *arg)
ctcb = nxsched_get_tcb(pid); ctcb = nxsched_get_tcb(pid);
if (ctcb != NULL && ctcb->group != NULL && ctcb == tcb) if (ctcb != NULL && ctcb->group != NULL && ctcb == tcb)
{ {
fs_putfilep(filep); file_put(filep);
} }
} }
} }
@ -310,13 +310,13 @@ int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2, int flags)
/* Perform the dup3 operation */ /* Perform the dup3 operation */
ret = file_dup3(filep1, filep, flags); ret = file_dup3(filep1, filep, flags);
fs_putfilep(filep1); file_put(filep1);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
if (new) if (new)
{ {
fs_putfilep(filep); file_put(filep);
} }
return ret; return ret;
@ -413,7 +413,7 @@ void files_dumplist(FAR struct filelist *list)
, buf , buf
#endif #endif
); );
fs_putfilep(filep); file_put(filep);
} }
lib_put_pathbuffer(path); lib_put_pathbuffer(path);
@ -666,20 +666,20 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist,
#endif #endif
if (!spawn_file_is_duplicateable(actions, fd, fcloexec)) if (!spawn_file_is_duplicateable(actions, fd, fcloexec))
{ {
fs_putfilep(filep); file_put(filep);
continue; continue;
} }
} }
else if (fcloexec) else if (fcloexec)
{ {
fs_putfilep(filep); file_put(filep);
continue; continue;
} }
ret = files_extend(clist, i + 1); ret = files_extend(clist, i + 1);
if (ret < 0) if (ret < 0)
{ {
fs_putfilep(filep); file_put(filep);
return ret; return ret;
} }
@ -687,13 +687,13 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist,
filep2 = files_fget_by_index(clist, i, j, &new); filep2 = files_fget_by_index(clist, i, j, &new);
ret = file_dup2(filep, filep2); ret = file_dup2(filep, filep2);
fs_putfilep(filep2); file_put(filep2);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
if (new) if (new)
{ {
fs_putfilep(filep2); file_put(filep2);
} }
return ret; return ret;
@ -705,7 +705,7 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist,
} }
/**************************************************************************** /****************************************************************************
* Name: fs_getfilep * Name: file_get
* *
* Description: * Description:
* Given a file descriptor, return the corresponding instance of struct * Given a file descriptor, return the corresponding instance of struct
@ -721,7 +721,7 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist,
* *
****************************************************************************/ ****************************************************************************/
int fs_getfilep(int fd, FAR struct file **filep) int file_get(int fd, FAR struct file **filep)
{ {
FAR struct filelist *list; FAR struct filelist *list;
@ -767,7 +767,7 @@ int fs_getfilep(int fd, FAR struct file **filep)
} }
/**************************************************************************** /****************************************************************************
* Name: fs_reffilep * Name: file_ref
* *
* Description: * Description:
* To specify filep increase the reference count. * To specify filep increase the reference count.
@ -780,7 +780,7 @@ int fs_getfilep(int fd, FAR struct file **filep)
* *
****************************************************************************/ ****************************************************************************/
void fs_reffilep(FAR struct file *filep) void file_ref(FAR struct file *filep)
{ {
/* This interface is used to increase the reference count of filep */ /* This interface is used to increase the reference count of filep */
@ -789,7 +789,7 @@ void fs_reffilep(FAR struct file *filep)
} }
/**************************************************************************** /****************************************************************************
* Name: fs_putfilep * Name: file_put
* *
* Description: * Description:
* Handles reference counts for files, less than or equal to 0 and close * Handles reference counts for files, less than or equal to 0 and close
@ -800,7 +800,7 @@ void fs_reffilep(FAR struct file *filep)
* file' instance. * file' instance.
****************************************************************************/ ****************************************************************************/
int fs_putfilep(FAR struct file *filep) int file_put(FAR struct file *filep)
{ {
int ret = 0; int ret = 0;
@ -895,15 +895,15 @@ int nx_close_from_tcb(FAR struct tcb_s *tcb, int fd)
} }
/* files_fget will increase the reference count, there call fs_putfilep /* files_fget will increase the reference count, there call file_put
* reduce reference count. * reduce reference count.
*/ */
fs_putfilep(filep); file_put(filep);
/* Undo the last reference count from file_allocate_from_tcb */ /* Undo the last reference count from file_allocate_from_tcb */
return fs_putfilep(filep); return file_put(filep);
} }
/**************************************************************************** /****************************************************************************

View file

@ -279,7 +279,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
FAR void *mapped = NULL; FAR void *mapped = NULL;
int ret; int ret;
if (fd != -1 && fs_getfilep(fd, &filep) < 0) if (fd != -1 && file_get(fd, &filep) < 0)
{ {
ferr("ERROR: fd:%d referred file whose type is not supported\n", fd); ferr("ERROR: fd:%d referred file whose type is not supported\n", fd);
ret = -ENODEV; ret = -ENODEV;
@ -290,7 +290,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
prot, flags, offset, MAP_USER, &mapped); prot, flags, offset, MAP_USER, &mapped);
if (filep) if (filep)
{ {
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -175,7 +175,7 @@ static int unmap_rammap(FAR struct task_group_s *group,
kumm_free(entry->vaddr); kumm_free(entry->vaddr);
} }
fs_putfilep(filep); file_put(filep);
/* Then remove the mapping from the list */ /* Then remove the mapping from the list */
@ -332,7 +332,7 @@ int rammap(FAR struct file *filep, FAR struct mm_map_entry_s *entry,
/* Add the buffer to the list of regions */ /* Add the buffer to the list of regions */
out: out:
fs_reffilep(filep); file_ref(filep);
entry->priv.p = (FAR void *)((uintptr_t)filep | type); entry->priv.p = (FAR void *)((uintptr_t)filep | type);
entry->munmap = unmap_rammap; entry->munmap = unmap_rammap;
entry->msync = msync_rammap; entry->msync = msync_rammap;

View file

@ -605,14 +605,14 @@ static int inotify_close(FAR struct file *filep)
static FAR struct inotify_device_s * static FAR struct inotify_device_s *
inotify_get_device_from_fd(int fd, FAR struct file **filep) inotify_get_device_from_fd(int fd, FAR struct file **filep)
{ {
if (fs_getfilep(fd, filep) < 0) if (file_get(fd, filep) < 0)
{ {
return NULL; return NULL;
} }
if ((*filep)->f_inode != &g_inotify_inode) if ((*filep)->f_inode != &g_inotify_inode)
{ {
fs_putfilep(*filep); file_put(*filep);
return NULL; return NULL;
} }
@ -1083,7 +1083,7 @@ int inotify_add_watch(int fd, FAR const char *pathname, uint32_t mask)
abspath = lib_realpath(pathname, NULL, mask & IN_DONT_FOLLOW); abspath = lib_realpath(pathname, NULL, mask & IN_DONT_FOLLOW);
if (abspath == NULL) if (abspath == NULL)
{ {
fs_putfilep(filep); file_put(filep);
return ERROR; return ERROR;
} }
@ -1154,7 +1154,7 @@ out:
nxmutex_unlock(&g_inotify.lock); nxmutex_unlock(&g_inotify.lock);
out_free: out_free:
fs_putfilep(filep); file_put(filep);
fs_heap_free(abspath); fs_heap_free(abspath);
if (ret < 0) if (ret < 0)
{ {
@ -1202,7 +1202,7 @@ int inotify_rm_watch(int fd, int wd)
{ {
nxmutex_unlock(&dev->lock); nxmutex_unlock(&dev->lock);
nxmutex_unlock(&g_inotify.lock); nxmutex_unlock(&g_inotify.lock);
fs_putfilep(filep); file_put(filep);
set_errno(EINVAL); set_errno(EINVAL);
return ERROR; return ERROR;
} }
@ -1210,7 +1210,7 @@ int inotify_rm_watch(int fd, int wd)
inotify_remove_watch(dev, watch); inotify_remove_watch(dev, watch);
nxmutex_unlock(&dev->lock); nxmutex_unlock(&dev->lock);
nxmutex_unlock(&g_inotify.lock); nxmutex_unlock(&g_inotify.lock);
fs_putfilep(filep); file_put(filep);
return OK; return OK;
} }

View file

@ -1333,7 +1333,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
procfile->line[linesize - 2] = '\n'; procfile->line[linesize - 2] = '\n';
} }
fs_putfilep(filep); file_put(filep);
copysize = procfs_memcpy(procfile->line, linesize, copysize = procfs_memcpy(procfile->line, linesize,
buffer, remaining, &offset); buffer, remaining, &offset);

View file

@ -264,7 +264,7 @@ int accept4(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen,
goto errout_with_psock; goto errout_with_psock;
} }
fs_putfilep(filep); file_put(filep);
#ifdef CONFIG_MM_KMAP #ifdef CONFIG_MM_KMAP
kmm_unmap(kaddr); kmm_unmap(kaddr);
@ -281,7 +281,7 @@ errout_with_alloc:
fs_heap_free(newsock); fs_heap_free(newsock);
errout_with_filep: errout_with_filep:
fs_putfilep(filep); file_put(filep);
errout_with_kmap: errout_with_kmap:
#ifdef CONFIG_MM_KMAP #ifdef CONFIG_MM_KMAP

View file

@ -206,7 +206,7 @@ FAR struct socket *file_socket(FAR struct file *filep)
int sockfd_socket(int sockfd, FAR struct file **filep, int sockfd_socket(int sockfd, FAR struct file **filep,
FAR struct socket **socketp) FAR struct socket **socketp)
{ {
if (fs_getfilep(sockfd, filep) < 0) if (file_get(sockfd, filep) < 0)
{ {
*socketp = NULL; *socketp = NULL;
return -EBADF; return -EBADF;
@ -215,7 +215,7 @@ int sockfd_socket(int sockfd, FAR struct file **filep,
*socketp = file_socket(*filep); *socketp = file_socket(*filep);
if (*socketp == NULL) if (*socketp == NULL)
{ {
fs_putfilep(*filep); file_put(*filep);
} }
return *socketp != NULL ? OK : -ENOTSOCK; return *socketp != NULL ? OK : -ENOTSOCK;

View file

@ -67,18 +67,18 @@ int file_dup(FAR struct file *filep, int minfd, int flags)
return fd2; return fd2;
} }
ret = fs_getfilep(fd2, &filep2); ret = file_get(fd2, &filep2);
DEBUGASSERT(ret >= 0); DEBUGASSERT(ret >= 0);
ret = file_dup3(filep, filep2, flags); ret = file_dup3(filep, filep2, flags);
fs_putfilep(filep2); file_put(filep2);
if (ret >= 0) if (ret >= 0)
{ {
return fd2; return fd2;
} }
fs_putfilep(filep2); file_put(filep2);
return ret; return ret;
} }
@ -97,7 +97,7 @@ int dup(int fd)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto err; goto err;
@ -106,7 +106,7 @@ int dup(int fd)
/* Let file_dup() do the real work */ /* Let file_dup() do the real work */
ret = file_dup(filep, 0, 0); ret = file_dup(filep, 0, 0);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
goto err; goto err;

View file

@ -144,7 +144,7 @@ static FAR epoll_head_t *epoll_head_from_fd(int fd, FAR struct file **filep)
/* Get file pointer by file descriptor */ /* Get file pointer by file descriptor */
ret = fs_getfilep(fd, filep); ret = file_get(fd, filep);
if (ret < 0) if (ret < 0)
{ {
set_errno(-ret); set_errno(-ret);
@ -155,7 +155,7 @@ static FAR epoll_head_t *epoll_head_from_fd(int fd, FAR struct file **filep)
if ((*filep)->f_inode->u.i_ops != &g_epoll_ops) if ((*filep)->f_inode->u.i_ops != &g_epoll_ops)
{ {
fs_putfilep(*filep); file_put(*filep);
set_errno(EBADF); set_errno(EBADF);
return NULL; return NULL;
} }
@ -200,7 +200,7 @@ static int epoll_do_close(FAR struct file *filep)
list_for_every_entry(&eph->setup, epn, epoll_node_t, node) list_for_every_entry(&eph->setup, epn, epoll_node_t, node)
{ {
file_poll(epn->filep, &epn->pfd, false); file_poll(epn->filep, &epn->pfd, false);
fs_putfilep(epn->filep); file_put(epn->filep);
} }
list_for_every_entry_safe(&eph->extend, epn, tmp, epoll_node_t, node) list_for_every_entry_safe(&eph->extend, epn, tmp, epoll_node_t, node)
@ -568,7 +568,7 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
epn->pfd.cb = epoll_default_cb; epn->pfd.cb = epoll_default_cb;
epn->pfd.revents = 0; epn->pfd.revents = 0;
ret = fs_getfilep(fd, &epn->filep); ret = file_get(fd, &epn->filep);
if (ret < 0) if (ret < 0)
{ {
list_add_tail(&eph->free, &epn->node); list_add_tail(&eph->free, &epn->node);
@ -578,7 +578,7 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
ret = file_poll(epn->filep, &epn->pfd, true); ret = file_poll(epn->filep, &epn->pfd, true);
if (ret < 0) if (ret < 0)
{ {
fs_putfilep(epn->filep); file_put(epn->filep);
list_add_tail(&eph->free, &epn->node); list_add_tail(&eph->free, &epn->node);
goto err; goto err;
} }
@ -593,7 +593,7 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
if (epn->pfd.fd == fd) if (epn->pfd.fd == fd)
{ {
file_poll(epn->filep, &epn->pfd, false); file_poll(epn->filep, &epn->pfd, false);
fs_putfilep(epn->filep); file_put(epn->filep);
list_delete(&epn->node); list_delete(&epn->node);
list_add_tail(&eph->free, &epn->node); list_add_tail(&eph->free, &epn->node);
goto out; goto out;
@ -604,7 +604,7 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
{ {
if (epn->pfd.fd == fd) if (epn->pfd.fd == fd)
{ {
fs_putfilep(epn->filep); file_put(epn->filep);
list_delete(&epn->node); list_delete(&epn->node);
list_add_tail(&eph->free, &epn->node); list_add_tail(&eph->free, &epn->node);
goto out; goto out;
@ -615,7 +615,7 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
{ {
if (epn->pfd.fd == fd) if (epn->pfd.fd == fd)
{ {
fs_putfilep(epn->filep); file_put(epn->filep);
list_delete(&epn->node); list_delete(&epn->node);
list_add_tail(&eph->free, &epn->node); list_add_tail(&eph->free, &epn->node);
goto out; goto out;
@ -705,12 +705,12 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
out: out:
nxmutex_unlock(&eph->lock); nxmutex_unlock(&eph->lock);
fs_putfilep(filep); file_put(filep);
return OK; return OK;
err: err:
nxmutex_unlock(&eph->lock); nxmutex_unlock(&eph->lock);
err_without_lock: err_without_lock:
fs_putfilep(filep); file_put(filep);
set_errno(-ret); set_errno(-ret);
return ERROR; return ERROR;
} }
@ -773,11 +773,11 @@ retry:
ret = num; ret = num;
} }
fs_putfilep(filep); file_put(filep);
return ret; return ret;
err: err:
fs_putfilep(filep); file_put(filep);
set_errno(-ret); set_errno(-ret);
out: out:
ferr("epoll wait failed:%d, timeout:%d\n", errno, timeout); ferr("epoll wait failed:%d, timeout:%d\n", errno, timeout);
@ -845,11 +845,11 @@ retry:
ret = num; ret = num;
} }
fs_putfilep(filep); file_put(filep);
return ret; return ret;
err: err:
fs_putfilep(filep); file_put(filep);
set_errno(-ret); set_errno(-ret);
out: out:
ferr("epoll wait failed:%d, timeout:%d\n", errno, timeout); ferr("epoll wait failed:%d, timeout:%d\n", errno, timeout);

View file

@ -50,10 +50,10 @@ static int fchstat(int fd, FAR struct stat *buf, int flags)
int ret; int ret;
/* First, get the file structure. Note that on failure, /* First, get the file structure. Note that on failure,
* fs_getfilep() will return the errno. * file_get() will return the errno.
*/ */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -62,7 +62,7 @@ static int fchstat(int fd, FAR struct stat *buf, int flags)
/* Perform the fchstat operation */ /* Perform the fchstat operation */
ret = file_fchstat(filep, buf, flags); ret = file_fchstat(filep, buf, flags);
fs_putfilep(filep); file_put(filep);
if (ret >= 0) if (ret >= 0)
{ {
/* Successfully fchstat'ed the file */ /* Successfully fchstat'ed the file */

View file

@ -349,7 +349,7 @@ int fcntl(int fd, int cmd, ...)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret >= 0) if (ret >= 0)
{ {
/* Let file_vfcntl() do the real work. The errno is not set on /* Let file_vfcntl() do the real work. The errno is not set on
@ -357,7 +357,7 @@ int fcntl(int fd, int cmd, ...)
*/ */
ret = file_vfcntl(filep, cmd, ap); ret = file_vfcntl(filep, cmd, ap);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -231,16 +231,16 @@ int nx_fstat(int fd, FAR struct stat *buf)
int ret; int ret;
/* First, get the file structure. Note that on failure, /* First, get the file structure. Note that on failure,
* fs_getfilep() will return the errno. * file_get() will return the errno.
*/ */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret >= 0) if (ret >= 0)
{ {
/* Perform the fstat operation */ /* Perform the fstat operation */
ret = file_fstat(filep, buf); ret = file_fstat(filep, buf);
fs_putfilep(filep); file_put(filep);
} }
return ret; return ret;

View file

@ -67,10 +67,10 @@ int fstatfs(int fd, FAR struct statfs *buf)
DEBUGASSERT(buf != NULL); DEBUGASSERT(buf != NULL);
/* First, get the file structure. Note that on failure, /* First, get the file structure. Note that on failure,
* fs_getfilep() will return the errno. * file_get() will return the errno.
*/ */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -113,7 +113,7 @@ int fstatfs(int fd, FAR struct statfs *buf)
/* Check if the fstat operation was successful */ /* Check if the fstat operation was successful */
fs_putfilep(filep); file_put(filep);
if (ret >= 0) if (ret >= 0)
{ {
/* Successfully statfs'ed the file */ /* Successfully statfs'ed the file */

View file

@ -106,7 +106,7 @@ int fsync(int fd)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -115,7 +115,7 @@ int fsync(int fd)
/* Perform the fsync operation */ /* Perform the fsync operation */
ret = file_fsync(filep); ret = file_fsync(filep);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;

View file

@ -266,7 +266,7 @@ int ioctl(int fd, int req, ...)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto err; goto err;
@ -278,7 +278,7 @@ int ioctl(int fd, int req, ...)
ret = file_vioctl(filep, req, ap); ret = file_vioctl(filep, req, ap);
va_end(ap); va_end(ap);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
goto err; goto err;

View file

@ -127,7 +127,7 @@ off_t nx_seek(int fd, off_t offset, int whence)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
@ -136,7 +136,7 @@ off_t nx_seek(int fd, off_t offset, int whence)
/* Then let file_seek do the real work */ /* Then let file_seek do the real work */
ret = file_seek(filep, offset, whence); ret = file_seek(filep, offset, whence);
fs_putfilep(filep); file_put(filep);
return ret; return ret;
} }

View file

@ -82,7 +82,7 @@ static inline void poll_teardown(FAR struct pollfd *fds, nfds_t nfds,
FAR struct file *filep; FAR struct file *filep;
int ret; int ret;
ret = fs_getfilep(fds[i].fd, &filep); ret = file_get(fds[i].fd, &filep);
if (ret >= 0) if (ret >= 0)
{ {
ret = file_poll(filep, &fds[i], false); ret = file_poll(filep, &fds[i], false);
@ -92,8 +92,8 @@ static inline void poll_teardown(FAR struct pollfd *fds, nfds_t nfds,
* before the poll. * before the poll.
*/ */
fs_putfilep(filep); file_put(filep);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)
@ -163,7 +163,7 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds,
FAR struct file *filep; FAR struct file *filep;
int num = i; int num = i;
ret = fs_getfilep(fds[i].fd, &filep); ret = file_get(fds[i].fd, &filep);
if (ret < 0) if (ret < 0)
{ {
num -= 1; num -= 1;

View file

@ -134,7 +134,7 @@ ssize_t pread(int fd, FAR void *buf, size_t nbytes, off_t offset)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = (ssize_t)fs_getfilep(fd, &filep); ret = (ssize_t)file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -143,7 +143,7 @@ ssize_t pread(int fd, FAR void *buf, size_t nbytes, off_t offset)
/* Let file_pread do the real work */ /* Let file_pread do the real work */
ret = file_pread(filep, buf, nbytes, offset); ret = file_pread(filep, buf, nbytes, offset);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;

View file

@ -137,7 +137,7 @@ ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = (ssize_t)fs_getfilep(fd, &filep); ret = (ssize_t)file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -146,7 +146,7 @@ ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset)
/* Let file_pwrite do the real work */ /* Let file_pwrite do the real work */
ret = file_pwrite(filep, buf, nbytes, offset); ret = file_pwrite(filep, buf, nbytes, offset);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;

View file

@ -293,17 +293,17 @@ ssize_t nx_readv(int fd, FAR const struct iovec *iov, int iovcnt)
ssize_t ret; ssize_t ret;
/* First, get the file structure. Note that on failure, /* First, get the file structure. Note that on failure,
* fs_getfilep() will return the errno. * file_get() will return the errno.
*/ */
ret = (ssize_t)fs_getfilep(fd, &filep); ret = (ssize_t)file_get(fd, &filep);
if (ret >= 0) if (ret >= 0)
{ {
/* Then let file_readv do all of the work. */ /* Then let file_readv do all of the work. */
ret = file_readv(filep, iov, iovcnt); ret = file_readv(filep, iov, iovcnt);
fs_putfilep(filep); file_put(filep);
} }
return ret; return ret;

View file

@ -337,22 +337,22 @@ ssize_t sendfile(int outfd, int infd, FAR off_t *offset, size_t count)
FAR struct file *infile; FAR struct file *infile;
int ret; int ret;
ret = fs_getfilep(outfd, &outfile); ret = file_get(outfd, &outfile);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
} }
ret = fs_getfilep(infd, &infile); ret = file_get(infd, &infile);
if (ret < 0) if (ret < 0)
{ {
fs_putfilep(outfile); file_put(outfile);
goto errout; goto errout;
} }
ret = file_sendfile(outfile, infile, offset, count); ret = file_sendfile(outfile, infile, offset, count);
fs_putfilep(outfile); file_put(outfile);
fs_putfilep(infile); file_put(infile);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;

View file

@ -364,7 +364,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
} }
else else
{ {
if (fs_getfilep(fd, &filep) < 0) if (file_get(fd, &filep) < 0)
{ {
ret = EBADF; ret = EBADF;
goto errout; goto errout;
@ -372,7 +372,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
if (filep->f_inode->u.i_ops != &g_signalfd_fileops) if (filep->f_inode->u.i_ops != &g_signalfd_fileops)
{ {
fs_putfilep(filep); file_put(filep);
goto errout; goto errout;
} }
@ -402,7 +402,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
if (filep != NULL) if (filep != NULL)
{ {
fs_putfilep(filep); file_put(filep);
} }
return fd; return fd;

View file

@ -84,11 +84,11 @@ int syncfs(int fd)
enter_cancellation_point(); enter_cancellation_point();
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret == OK) if (ret == OK)
{ {
ret = file_syncfs(filep); ret = file_syncfs(filep);
fs_putfilep(filep); file_put(filep);
} }
leave_cancellation_point(); leave_cancellation_point();

View file

@ -509,7 +509,7 @@ int timerfd_settime(int fd, int flags,
/* Get file pointer by file descriptor */ /* Get file pointer by file descriptor */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -557,7 +557,7 @@ int timerfd_settime(int fd, int flags,
if (new_value->it_value.tv_sec <= 0 && new_value->it_value.tv_nsec <= 0) if (new_value->it_value.tv_sec <= 0 && new_value->it_value.tv_nsec <= 0)
{ {
leave_critical_section(intflags); leave_critical_section(intflags);
fs_putfilep(filep); file_put(filep);
return OK; return OK;
} }
@ -607,11 +607,11 @@ int timerfd_settime(int fd, int flags,
} }
leave_critical_section(intflags); leave_critical_section(intflags);
fs_putfilep(filep); file_put(filep);
return OK; return OK;
errout_with_filep: errout_with_filep:
fs_putfilep(filep); file_put(filep);
errout: errout:
set_errno(-ret); set_errno(-ret);
return ERROR; return ERROR;
@ -634,7 +634,7 @@ int timerfd_gettime(int fd, FAR struct itimerspec *curr_value)
/* Get file pointer by file descriptor */ /* Get file pointer by file descriptor */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
goto errout; goto errout;
@ -642,7 +642,7 @@ int timerfd_gettime(int fd, FAR struct itimerspec *curr_value)
if (filep->f_inode->u.i_ops != &g_timerfd_fops) if (filep->f_inode->u.i_ops != &g_timerfd_fops)
{ {
fs_putfilep(filep); file_put(filep);
goto errout; goto errout;
} }
@ -656,7 +656,7 @@ int timerfd_gettime(int fd, FAR struct itimerspec *curr_value)
clock_ticks2time(&curr_value->it_value, ticks); clock_ticks2time(&curr_value->it_value, ticks);
clock_ticks2time(&curr_value->it_interval, dev->delay); clock_ticks2time(&curr_value->it_interval, dev->delay);
fs_putfilep(filep); file_put(filep);
return OK; return OK;
errout: errout:

View file

@ -170,7 +170,7 @@ int ftruncate(int fd, off_t length)
/* Get the file structure corresponding to the file descriptor. */ /* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(fd, &filep); ret = file_get(fd, &filep);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: Could no get file structure: %d\n", ret); ferr("ERROR: Could no get file structure: %d\n", ret);
@ -180,7 +180,7 @@ int ftruncate(int fd, off_t length)
/* Perform the truncate operation */ /* Perform the truncate operation */
ret = file_truncate(filep, length); ret = file_truncate(filep, length);
fs_putfilep(filep); file_put(filep);
if (ret >= 0) if (ret >= 0)
{ {
#ifdef CONFIG_FS_NOTIFY #ifdef CONFIG_FS_NOTIFY

View file

@ -276,10 +276,10 @@ ssize_t nx_writev(int fd, FAR const struct iovec *iov, int iovcnt)
ssize_t ret; ssize_t ret;
/* First, get the file structure. /* First, get the file structure.
* Note that fs_getfilep() will return the errno on failure. * Note that file_get() will return the errno on failure.
*/ */
ret = (ssize_t)fs_getfilep(fd, &filep); ret = (ssize_t)file_get(fd, &filep);
if (ret >= 0) if (ret >= 0)
{ {
/* Perform the write operation using the file descriptor as an /* Perform the write operation using the file descriptor as an
@ -288,7 +288,7 @@ ssize_t nx_writev(int fd, FAR const struct iovec *iov, int iovcnt)
ret = file_writev(filep, iov, iovcnt); ret = file_writev(filep, iov, iovcnt);
fs_putfilep(filep); file_put(filep);
} }
return ret; return ret;

View file

@ -1171,7 +1171,7 @@ int nx_open_from_tcb(FAR struct tcb_s *tcb,
int nx_open(FAR const char *path, int oflags, ...); int nx_open(FAR const char *path, int oflags, ...);
/**************************************************************************** /****************************************************************************
* Name: fs_getfilep * Name: file_get
* *
* Description: * Description:
* Given a file descriptor, return the corresponding instance of struct * Given a file descriptor, return the corresponding instance of struct
@ -1188,10 +1188,10 @@ int nx_open(FAR const char *path, int oflags, ...);
* *
****************************************************************************/ ****************************************************************************/
int fs_getfilep(int fd, FAR struct file **filep); int file_get(int fd, FAR struct file **filep);
/**************************************************************************** /****************************************************************************
* Name: fs_reffilep * Name: file_ref
* *
* Description: * Description:
* To specify filep increase the reference count. * To specify filep increase the reference count.
@ -1204,10 +1204,10 @@ int fs_getfilep(int fd, FAR struct file **filep);
* *
****************************************************************************/ ****************************************************************************/
void fs_reffilep(FAR struct file *filep); void file_ref(FAR struct file *filep);
/**************************************************************************** /****************************************************************************
* Name: fs_putfilep * Name: file_put
* *
* Description: * Description:
* Release reference counts for files, less than or equal to 0 and close * Release reference counts for files, less than or equal to 0 and close
@ -1219,7 +1219,7 @@ void fs_reffilep(FAR struct file *filep);
* *
****************************************************************************/ ****************************************************************************/
int fs_putfilep(FAR struct file *filep); int file_put(FAR struct file *filep);
/**************************************************************************** /****************************************************************************
* Name: file_close * Name: file_close

View file

@ -111,7 +111,7 @@ static int local_sendctl(FAR struct local_conn_s *conn,
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
ret = fs_getfilep(fds[i], &filep); ret = file_get(fds[i], &filep);
if (ret < 0) if (ret < 0)
{ {
goto fail; goto fail;
@ -120,13 +120,13 @@ static int local_sendctl(FAR struct local_conn_s *conn,
filep2 = kmm_zalloc(sizeof(*filep2)); filep2 = kmm_zalloc(sizeof(*filep2));
if (!filep2) if (!filep2)
{ {
fs_putfilep(filep); file_put(filep);
ret = -ENOMEM; ret = -ENOMEM;
goto fail; goto fail;
} }
ret = file_dup2(filep, filep2); ret = file_dup2(filep, filep2);
fs_putfilep(filep); file_put(filep);
if (ret < 0) if (ret < 0)
{ {
kmm_free(filep2); kmm_free(filep2);

View file

@ -164,7 +164,7 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
if (ret == OK) if (ret == OK)
{ {
ret = psock_bind(psock, addr, addrlen); ret = psock_bind(psock, addr, addrlen);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -241,7 +241,7 @@ int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen)
if (ret == OK) if (ret == OK)
{ {
ret = psock_connect(psock, addr, addrlen); ret = psock_connect(psock, addr, addrlen);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -160,7 +160,7 @@ int getpeername(int sockfd, FAR struct sockaddr *addr,
if (ret == OK) if (ret == OK)
{ {
ret = psock_getpeername(psock, addr, addrlen); ret = psock_getpeername(psock, addr, addrlen);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -158,7 +158,7 @@ int getsockname(int sockfd, FAR struct sockaddr *addr,
if (ret == OK) if (ret == OK)
{ {
ret = psock_getsockname(psock, addr, addrlen); ret = psock_getsockname(psock, addr, addrlen);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -365,7 +365,7 @@ int getsockopt(int sockfd, int level, int option,
if (ret == OK) if (ret == OK)
{ {
ret = psock_getsockopt(psock, level, option, value, value_len); ret = psock_getsockopt(psock, level, option, value, value_len);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -154,7 +154,7 @@ int listen(int sockfd, int backlog)
if (ret == OK) if (ret == OK)
{ {
ret = psock_listen(psock, backlog); ret = psock_listen(psock, backlog);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -200,7 +200,7 @@ ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags,
if (ret == OK) if (ret == OK)
{ {
ret = psock_recvfrom(psock, buf, len, flags, from, fromlen); ret = psock_recvfrom(psock, buf, len, flags, from, fromlen);
fs_putfilep(filep); file_put(filep);
} }
#ifdef CONFIG_BUILD_KERNEL #ifdef CONFIG_BUILD_KERNEL

View file

@ -179,7 +179,7 @@ ssize_t recvmsg(int sockfd, FAR struct msghdr *msg, int flags)
if (ret == OK) if (ret == OK)
{ {
ret = psock_recvmsg(psock, msg, flags); ret = psock_recvmsg(psock, msg, flags);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -158,7 +158,7 @@ ssize_t sendmsg(int sockfd, FAR struct msghdr *msg, int flags)
if (ret == OK) if (ret == OK)
{ {
ret = psock_sendmsg(psock, msg, flags); ret = psock_sendmsg(psock, msg, flags);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -245,7 +245,7 @@ ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags,
if (ret == OK) if (ret == OK)
{ {
ret = psock_sendto(psock, buf, len, flags, to, tolen); ret = psock_sendto(psock, buf, len, flags, to, tolen);
fs_putfilep(filep); file_put(filep);
} }
#ifdef CONFIG_BUILD_KERNEL #ifdef CONFIG_BUILD_KERNEL

View file

@ -401,7 +401,7 @@ int setsockopt(int sockfd, int level, int option, const void *value,
if (ret == OK) if (ret == OK)
{ {
ret = psock_setsockopt(psock, level, option, value, value_len); ret = psock_setsockopt(psock, level, option, value, value_len);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -141,7 +141,7 @@ int shutdown(int sockfd, int how)
if (ret == OK) if (ret == OK)
{ {
ret = psock_shutdown(psock, how); ret = psock_shutdown(psock, how);
fs_putfilep(filep); file_put(filep);
} }
if (ret < 0) if (ret < 0)

View file

@ -105,11 +105,11 @@ int mq_getattr(mqd_t mqdes, struct mq_attr *mq_stat)
FAR struct file *filep; FAR struct file *filep;
int ret; int ret;
ret = fs_getfilep(mqdes, &filep); ret = file_get(mqdes, &filep);
if (ret >= 0) if (ret >= 0)
{ {
ret = file_mq_getattr(filep, mq_stat); ret = file_mq_getattr(filep, mq_stat);
fs_putfilep(filep); file_put(filep);
if (ret >= 0) if (ret >= 0)
{ {
return OK; return OK;

View file

@ -104,7 +104,7 @@ int mq_notify(mqd_t mqdes, FAR const struct sigevent *notification)
irqstate_t flags; irqstate_t flags;
int errval; int errval;
errval = fs_getfilep(mqdes, &filep); errval = file_get(mqdes, &filep);
if (errval < 0) if (errval < 0)
{ {
errval = -errval; errval = -errval;
@ -184,14 +184,14 @@ int mq_notify(mqd_t mqdes, FAR const struct sigevent *notification)
} }
leave_critical_section(flags); leave_critical_section(flags);
fs_putfilep(filep); file_put(filep);
return OK; return OK;
errout: errout:
leave_critical_section(flags); leave_critical_section(flags);
errout_with_filep: errout_with_filep:
fs_putfilep(filep); file_put(filep);
errout_without_lock: errout_without_lock:
set_errno(errval); set_errno(errval);

View file

@ -371,14 +371,14 @@ ssize_t nxmq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
FAR struct file *filep; FAR struct file *filep;
ssize_t ret; ssize_t ret;
ret = fs_getfilep(mqdes, &filep); ret = file_get(mqdes, &filep);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
} }
ret = file_mq_timedreceive_internal(filep, msg, msglen, prio, abstime, -1); ret = file_mq_timedreceive_internal(filep, msg, msglen, prio, abstime, -1);
fs_putfilep(filep); file_put(filep);
return ret; return ret;
} }
@ -521,14 +521,14 @@ ssize_t nxmq_receive(mqd_t mqdes, FAR char *msg, size_t msglen,
FAR struct file *filep; FAR struct file *filep;
ssize_t ret; ssize_t ret;
ret = fs_getfilep(mqdes, &filep); ret = file_get(mqdes, &filep);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
} }
ret = file_mq_receive(filep, msg, msglen, prio); ret = file_mq_receive(filep, msg, msglen, prio);
fs_putfilep(filep); file_put(filep);
return ret; return ret;
} }

View file

@ -519,14 +519,14 @@ int nxmq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen,
FAR struct file *filep; FAR struct file *filep;
int ret; int ret;
ret = fs_getfilep(mqdes, &filep); ret = file_get(mqdes, &filep);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
} }
ret = file_mq_timedsend_internal(filep, msg, msglen, prio, abstime, -1); ret = file_mq_timedsend_internal(filep, msg, msglen, prio, abstime, -1);
fs_putfilep(filep); file_put(filep);
return ret; return ret;
} }
@ -671,14 +671,14 @@ int nxmq_send(mqd_t mqdes, FAR const char *msg, size_t msglen,
FAR struct file *filep; FAR struct file *filep;
int ret; int ret;
ret = fs_getfilep(mqdes, &filep); ret = file_get(mqdes, &filep);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
} }
ret = file_mq_timedsend_internal(filep, msg, msglen, prio, NULL, -1); ret = file_mq_timedsend_internal(filep, msg, msglen, prio, NULL, -1);
fs_putfilep(filep); file_put(filep);
return ret; return ret;
} }

View file

@ -117,11 +117,11 @@ int mq_setattr(mqd_t mqdes, const struct mq_attr *mq_stat,
FAR struct file *filep; FAR struct file *filep;
int ret; int ret;
ret = fs_getfilep(mqdes, &filep); ret = file_get(mqdes, &filep);
if (ret >= 0) if (ret >= 0)
{ {
ret = file_mq_setattr(filep, mq_stat, oldstat); ret = file_mq_setattr(filep, mq_stat, oldstat);
fs_putfilep(filep); file_put(filep);
if (ret >= 0) if (ret >= 0)
{ {
return OK; return OK;