This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a12d21e830c132d4027b26c050f6e2ae16d56bab Author: dongjiuzhu1 <dongjiuz...@xiaomi.com> AuthorDate: Sat Jun 7 14:30:28 2025 +0800 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 <dongjiuz...@xiaomi.com> --- audio/audio.c | 4 ++-- drivers/misc/optee.c | 4 ++-- drivers/net/telnet.c | 2 +- fs/aio/aioc_contain.c | 6 +++--- fs/inode/fs_files.c | 40 ++++++++++++++++++++-------------------- fs/mmap/fs_mmap.c | 4 ++-- fs/mmap/fs_rammap.c | 4 ++-- fs/notify/inotify.c | 12 ++++++------ fs/procfs/fs_procfsproc.c | 2 +- fs/socket/accept.c | 4 ++-- fs/socket/socket.c | 4 ++-- fs/vfs/fs_dup.c | 10 +++++----- fs/vfs/fs_epoll.c | 28 ++++++++++++++-------------- fs/vfs/fs_fchstat.c | 6 +++--- fs/vfs/fs_fcntl.c | 4 ++-- fs/vfs/fs_fstat.c | 6 +++--- fs/vfs/fs_fstatfs.c | 6 +++--- fs/vfs/fs_fsync.c | 4 ++-- fs/vfs/fs_ioctl.c | 4 ++-- fs/vfs/fs_lseek.c | 4 ++-- fs/vfs/fs_poll.c | 8 ++++---- fs/vfs/fs_pread.c | 4 ++-- fs/vfs/fs_pwrite.c | 4 ++-- fs/vfs/fs_read.c | 6 +++--- fs/vfs/fs_sendfile.c | 10 +++++----- fs/vfs/fs_signalfd.c | 6 +++--- fs/vfs/fs_syncfs.c | 4 ++-- fs/vfs/fs_timerfd.c | 14 +++++++------- fs/vfs/fs_truncate.c | 4 ++-- fs/vfs/fs_write.c | 6 +++--- include/nuttx/fs/fs.h | 12 ++++++------ net/local/local_sendmsg.c | 6 +++--- net/socket/bind.c | 2 +- net/socket/connect.c | 2 +- net/socket/getpeername.c | 2 +- net/socket/getsockname.c | 2 +- net/socket/getsockopt.c | 2 +- net/socket/listen.c | 2 +- net/socket/recvfrom.c | 2 +- net/socket/recvmsg.c | 2 +- net/socket/sendmsg.c | 2 +- net/socket/sendto.c | 2 +- net/socket/setsockopt.c | 2 +- net/socket/shutdown.c | 2 +- sched/mqueue/mq_getattr.c | 4 ++-- sched/mqueue/mq_notify.c | 6 +++--- sched/mqueue/mq_receive.c | 8 ++++---- sched/mqueue/mq_send.c | 8 ++++---- sched/mqueue/mq_setattr.c | 4 ++-- 49 files changed, 148 insertions(+), 148 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 36d087efa0..154b8f5f41 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -590,7 +590,7 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { audinfo("AUDIOIOC_REGISTERMQ\n"); - ret = fs_getfilep((mqd_t)arg, &upper->usermq); + ret = file_get((mqd_t)arg, &upper->usermq); } break; @@ -603,7 +603,7 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { audinfo("AUDIOIOC_UNREGISTERMQ\n"); - fs_putfilep(upper->usermq); + file_put(upper->usermq); upper->usermq = NULL; ret = OK; } diff --git a/drivers/misc/optee.c b/drivers/misc/optee.c index 4803dd9542..0415318566 100644 --- a/drivers/misc/optee.c +++ b/drivers/misc/optee.c @@ -539,14 +539,14 @@ static int optee_close(FAR struct file *filep) 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 * double-freeing our SHM */ shm_filep->f_priv = NULL; - fs_putfilep(shm_filep); + fs_put(shm_filep); } optee_shm_free(shm); diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c index 7575754179..e492517f34 100644 --- a/drivers/net/telnet.c +++ b/drivers/net/telnet.c @@ -943,7 +943,7 @@ static int telnet_session(FAR struct telnet_session_s *session) } ret = psock_dup2(psock, &priv->td_psock); - fs_putfilep(filep); + file_put(filep); if (ret < 0) { nerr("ERROR: psock_dup2 failed: %d\n", ret); diff --git a/fs/aio/aioc_contain.c b/fs/aio/aioc_contain.c index 283d5b01c5..55447972ca 100644 --- a/fs/aio/aioc_contain.c +++ b/fs/aio/aioc_contain.c @@ -70,7 +70,7 @@ FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp) /* 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) { goto errout; @@ -115,7 +115,7 @@ FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp) return aioc; err_putfilep: - fs_putfilep(filep); + file_put(filep); errout: set_errno(-ret); return NULL; @@ -155,7 +155,7 @@ FAR struct aiocb *aioc_decant(FAR struct aio_container_s *aioc) */ aiocbp = aioc->aioc_aiocbp; - fs_putfilep(aioc->aioc_filep); + file_put(aioc->aioc_filep); aioc_free(aioc); aio_unlock(); diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index cc3a02a2da..3b17194f86 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -227,7 +227,7 @@ static void task_fssync(FAR struct tcb_s *tcb, FAR void *arg) ctcb = nxsched_get_tcb(pid); 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 */ ret = file_dup3(filep1, filep, flags); - fs_putfilep(filep1); - fs_putfilep(filep); + file_put(filep1); + file_put(filep); if (ret < 0) { if (new) { - fs_putfilep(filep); + file_put(filep); } return ret; @@ -413,7 +413,7 @@ void files_dumplist(FAR struct filelist *list) , buf #endif ); - fs_putfilep(filep); + file_put(filep); } lib_put_pathbuffer(path); @@ -666,20 +666,20 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist, #endif if (!spawn_file_is_duplicateable(actions, fd, fcloexec)) { - fs_putfilep(filep); + file_put(filep); continue; } } else if (fcloexec) { - fs_putfilep(filep); + file_put(filep); continue; } ret = files_extend(clist, i + 1); if (ret < 0) { - fs_putfilep(filep); + file_put(filep); 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); ret = file_dup2(filep, filep2); - fs_putfilep(filep2); - fs_putfilep(filep); + file_put(filep2); + file_put(filep); if (ret < 0) { if (new) { - fs_putfilep(filep2); + file_put(filep2); } return ret; @@ -705,7 +705,7 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist, } /**************************************************************************** - * Name: fs_getfilep + * Name: file_get * * Description: * 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; @@ -767,7 +767,7 @@ int fs_getfilep(int fd, FAR struct file **filep) } /**************************************************************************** - * Name: fs_reffilep + * Name: file_ref * * Description: * 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 */ @@ -789,7 +789,7 @@ void fs_reffilep(FAR struct file *filep) } /**************************************************************************** - * Name: fs_putfilep + * Name: file_put * * Description: * 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. ****************************************************************************/ -int fs_putfilep(FAR struct file *filep) +int file_put(FAR struct file *filep) { 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. */ - fs_putfilep(filep); + file_put(filep); /* Undo the last reference count from file_allocate_from_tcb */ - return fs_putfilep(filep); + return file_put(filep); } /**************************************************************************** diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c index 9b8263c953..ed0c847acf 100644 --- a/fs/mmap/fs_mmap.c +++ b/fs/mmap/fs_mmap.c @@ -279,7 +279,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags, FAR void *mapped = NULL; 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); 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); if (filep) { - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c index f91f6b9599..ae7c1959ca 100644 --- a/fs/mmap/fs_rammap.c +++ b/fs/mmap/fs_rammap.c @@ -175,7 +175,7 @@ static int unmap_rammap(FAR struct task_group_s *group, kumm_free(entry->vaddr); } - fs_putfilep(filep); + file_put(filep); /* 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 */ out: - fs_reffilep(filep); + file_ref(filep); entry->priv.p = (FAR void *)((uintptr_t)filep | type); entry->munmap = unmap_rammap; entry->msync = msync_rammap; diff --git a/fs/notify/inotify.c b/fs/notify/inotify.c index 97924e3821..ced0d5467e 100644 --- a/fs/notify/inotify.c +++ b/fs/notify/inotify.c @@ -605,14 +605,14 @@ static int inotify_close(FAR struct file *filep) static FAR struct inotify_device_s * 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; } if ((*filep)->f_inode != &g_inotify_inode) { - fs_putfilep(*filep); + file_put(*filep); 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); if (abspath == NULL) { - fs_putfilep(filep); + file_put(filep); return ERROR; } @@ -1154,7 +1154,7 @@ out: nxmutex_unlock(&g_inotify.lock); out_free: - fs_putfilep(filep); + file_put(filep); fs_heap_free(abspath); if (ret < 0) { @@ -1202,7 +1202,7 @@ int inotify_rm_watch(int fd, int wd) { nxmutex_unlock(&dev->lock); nxmutex_unlock(&g_inotify.lock); - fs_putfilep(filep); + file_put(filep); set_errno(EINVAL); return ERROR; } @@ -1210,7 +1210,7 @@ int inotify_rm_watch(int fd, int wd) inotify_remove_watch(dev, watch); nxmutex_unlock(&dev->lock); nxmutex_unlock(&g_inotify.lock); - fs_putfilep(filep); + file_put(filep); return OK; } diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index 366dba3094..db29825c9c 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -1333,7 +1333,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile, procfile->line[linesize - 2] = '\n'; } - fs_putfilep(filep); + file_put(filep); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); diff --git a/fs/socket/accept.c b/fs/socket/accept.c index 45f79bec72..98a658d494 100644 --- a/fs/socket/accept.c +++ b/fs/socket/accept.c @@ -264,7 +264,7 @@ int accept4(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen, goto errout_with_psock; } - fs_putfilep(filep); + file_put(filep); #ifdef CONFIG_MM_KMAP kmm_unmap(kaddr); @@ -281,7 +281,7 @@ errout_with_alloc: fs_heap_free(newsock); errout_with_filep: - fs_putfilep(filep); + file_put(filep); errout_with_kmap: #ifdef CONFIG_MM_KMAP diff --git a/fs/socket/socket.c b/fs/socket/socket.c index e3875f7bed..125bed1109 100644 --- a/fs/socket/socket.c +++ b/fs/socket/socket.c @@ -206,7 +206,7 @@ FAR struct socket *file_socket(FAR struct file *filep) int sockfd_socket(int sockfd, FAR struct file **filep, FAR struct socket **socketp) { - if (fs_getfilep(sockfd, filep) < 0) + if (file_get(sockfd, filep) < 0) { *socketp = NULL; return -EBADF; @@ -215,7 +215,7 @@ int sockfd_socket(int sockfd, FAR struct file **filep, *socketp = file_socket(*filep); if (*socketp == NULL) { - fs_putfilep(*filep); + file_put(*filep); } return *socketp != NULL ? OK : -ENOTSOCK; diff --git a/fs/vfs/fs_dup.c b/fs/vfs/fs_dup.c index 7de1ec845f..f00abd412c 100644 --- a/fs/vfs/fs_dup.c +++ b/fs/vfs/fs_dup.c @@ -67,18 +67,18 @@ int file_dup(FAR struct file *filep, int minfd, int flags) return fd2; } - ret = fs_getfilep(fd2, &filep2); + ret = file_get(fd2, &filep2); DEBUGASSERT(ret >= 0); ret = file_dup3(filep, filep2, flags); - fs_putfilep(filep2); + file_put(filep2); if (ret >= 0) { return fd2; } - fs_putfilep(filep2); + file_put(filep2); return ret; } @@ -97,7 +97,7 @@ int dup(int fd) /* Get the file structure corresponding to the file descriptor. */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret < 0) { goto err; @@ -106,7 +106,7 @@ int dup(int fd) /* Let file_dup() do the real work */ ret = file_dup(filep, 0, 0); - fs_putfilep(filep); + file_put(filep); if (ret < 0) { goto err; diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index f61cf9f631..5efbece61c 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -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 */ - ret = fs_getfilep(fd, filep); + ret = file_get(fd, filep); if (ret < 0) { 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) { - fs_putfilep(*filep); + file_put(*filep); set_errno(EBADF); 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) { 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) @@ -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.revents = 0; - ret = fs_getfilep(fd, &epn->filep); + ret = file_get(fd, &epn->filep); if (ret < 0) { 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); if (ret < 0) { - fs_putfilep(epn->filep); + file_put(epn->filep); list_add_tail(&eph->free, &epn->node); 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) { file_poll(epn->filep, &epn->pfd, false); - fs_putfilep(epn->filep); + file_put(epn->filep); list_delete(&epn->node); list_add_tail(&eph->free, &epn->node); 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) { - fs_putfilep(epn->filep); + file_put(epn->filep); list_delete(&epn->node); list_add_tail(&eph->free, &epn->node); 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) { - fs_putfilep(epn->filep); + file_put(epn->filep); list_delete(&epn->node); list_add_tail(&eph->free, &epn->node); goto out; @@ -705,12 +705,12 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev) out: nxmutex_unlock(&eph->lock); - fs_putfilep(filep); + file_put(filep); return OK; err: nxmutex_unlock(&eph->lock); err_without_lock: - fs_putfilep(filep); + file_put(filep); set_errno(-ret); return ERROR; } @@ -773,11 +773,11 @@ retry: ret = num; } - fs_putfilep(filep); + file_put(filep); return ret; err: - fs_putfilep(filep); + file_put(filep); set_errno(-ret); out: ferr("epoll wait failed:%d, timeout:%d\n", errno, timeout); @@ -845,11 +845,11 @@ retry: ret = num; } - fs_putfilep(filep); + file_put(filep); return ret; err: - fs_putfilep(filep); + file_put(filep); set_errno(-ret); out: ferr("epoll wait failed:%d, timeout:%d\n", errno, timeout); diff --git a/fs/vfs/fs_fchstat.c b/fs/vfs/fs_fchstat.c index bedf562019..00b54625b4 100644 --- a/fs/vfs/fs_fchstat.c +++ b/fs/vfs/fs_fchstat.c @@ -50,10 +50,10 @@ static int fchstat(int fd, FAR struct stat *buf, int flags) int ret; /* 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) { goto errout; @@ -62,7 +62,7 @@ static int fchstat(int fd, FAR struct stat *buf, int flags) /* Perform the fchstat operation */ ret = file_fchstat(filep, buf, flags); - fs_putfilep(filep); + file_put(filep); if (ret >= 0) { /* Successfully fchstat'ed the file */ diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c index 3df8171559..b923f5fd8f 100644 --- a/fs/vfs/fs_fcntl.c +++ b/fs/vfs/fs_fcntl.c @@ -349,7 +349,7 @@ int fcntl(int fd, int cmd, ...) /* Get the file structure corresponding to the file descriptor. */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret >= 0) { /* 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); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/fs/vfs/fs_fstat.c b/fs/vfs/fs_fstat.c index c4585a79ac..182c3fe59e 100644 --- a/fs/vfs/fs_fstat.c +++ b/fs/vfs/fs_fstat.c @@ -231,16 +231,16 @@ int nx_fstat(int fd, FAR struct stat *buf) int ret; /* 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) { /* Perform the fstat operation */ ret = file_fstat(filep, buf); - fs_putfilep(filep); + file_put(filep); } return ret; diff --git a/fs/vfs/fs_fstatfs.c b/fs/vfs/fs_fstatfs.c index 94acd04799..d6879efb93 100644 --- a/fs/vfs/fs_fstatfs.c +++ b/fs/vfs/fs_fstatfs.c @@ -67,10 +67,10 @@ int fstatfs(int fd, FAR struct statfs *buf) DEBUGASSERT(buf != NULL); /* 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) { goto errout; @@ -113,7 +113,7 @@ int fstatfs(int fd, FAR struct statfs *buf) /* Check if the fstat operation was successful */ - fs_putfilep(filep); + file_put(filep); if (ret >= 0) { /* Successfully statfs'ed the file */ diff --git a/fs/vfs/fs_fsync.c b/fs/vfs/fs_fsync.c index 8a1915c654..caf38b3fa0 100644 --- a/fs/vfs/fs_fsync.c +++ b/fs/vfs/fs_fsync.c @@ -106,7 +106,7 @@ int fsync(int fd) /* Get the file structure corresponding to the file descriptor. */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret < 0) { goto errout; @@ -115,7 +115,7 @@ int fsync(int fd) /* Perform the fsync operation */ ret = file_fsync(filep); - fs_putfilep(filep); + file_put(filep); if (ret < 0) { goto errout; diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index 7bab9a39ba..7df9733799 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -266,7 +266,7 @@ int ioctl(int fd, int req, ...) /* Get the file structure corresponding to the file descriptor. */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret < 0) { goto err; @@ -278,7 +278,7 @@ int ioctl(int fd, int req, ...) ret = file_vioctl(filep, req, ap); va_end(ap); - fs_putfilep(filep); + file_put(filep); if (ret < 0) { goto err; diff --git a/fs/vfs/fs_lseek.c b/fs/vfs/fs_lseek.c index 5cf85868b7..2d1ceeb549 100644 --- a/fs/vfs/fs_lseek.c +++ b/fs/vfs/fs_lseek.c @@ -127,7 +127,7 @@ off_t nx_seek(int fd, off_t offset, int whence) /* Get the file structure corresponding to the file descriptor. */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret < 0) { 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 */ ret = file_seek(filep, offset, whence); - fs_putfilep(filep); + file_put(filep); return ret; } diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index f53f560981..d6999af5da 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -82,7 +82,7 @@ static inline void poll_teardown(FAR struct pollfd *fds, nfds_t nfds, FAR struct file *filep; int ret; - ret = fs_getfilep(fds[i].fd, &filep); + ret = file_get(fds[i].fd, &filep); if (ret >= 0) { 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. */ - fs_putfilep(filep); - fs_putfilep(filep); + file_put(filep); + file_put(filep); } if (ret < 0) @@ -163,7 +163,7 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, FAR struct file *filep; int num = i; - ret = fs_getfilep(fds[i].fd, &filep); + ret = file_get(fds[i].fd, &filep); if (ret < 0) { num -= 1; diff --git a/fs/vfs/fs_pread.c b/fs/vfs/fs_pread.c index 05209285e7..992935028b 100644 --- a/fs/vfs/fs_pread.c +++ b/fs/vfs/fs_pread.c @@ -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. */ - ret = (ssize_t)fs_getfilep(fd, &filep); + ret = (ssize_t)file_get(fd, &filep); if (ret < 0) { 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 */ ret = file_pread(filep, buf, nbytes, offset); - fs_putfilep(filep); + file_put(filep); if (ret < 0) { goto errout; diff --git a/fs/vfs/fs_pwrite.c b/fs/vfs/fs_pwrite.c index 1d2cee7163..02c4c4b504 100644 --- a/fs/vfs/fs_pwrite.c +++ b/fs/vfs/fs_pwrite.c @@ -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. */ - ret = (ssize_t)fs_getfilep(fd, &filep); + ret = (ssize_t)file_get(fd, &filep); if (ret < 0) { 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 */ ret = file_pwrite(filep, buf, nbytes, offset); - fs_putfilep(filep); + file_put(filep); if (ret < 0) { goto errout; diff --git a/fs/vfs/fs_read.c b/fs/vfs/fs_read.c index 14f825fd6c..51d1ce48fb 100644 --- a/fs/vfs/fs_read.c +++ b/fs/vfs/fs_read.c @@ -293,17 +293,17 @@ ssize_t nx_readv(int fd, FAR const struct iovec *iov, int iovcnt) ssize_t ret; /* 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) { /* Then let file_readv do all of the work. */ ret = file_readv(filep, iov, iovcnt); - fs_putfilep(filep); + file_put(filep); } return ret; diff --git a/fs/vfs/fs_sendfile.c b/fs/vfs/fs_sendfile.c index 28825c8255..697bbd8d9c 100644 --- a/fs/vfs/fs_sendfile.c +++ b/fs/vfs/fs_sendfile.c @@ -337,22 +337,22 @@ ssize_t sendfile(int outfd, int infd, FAR off_t *offset, size_t count) FAR struct file *infile; int ret; - ret = fs_getfilep(outfd, &outfile); + ret = file_get(outfd, &outfile); if (ret < 0) { goto errout; } - ret = fs_getfilep(infd, &infile); + ret = file_get(infd, &infile); if (ret < 0) { - fs_putfilep(outfile); + file_put(outfile); goto errout; } ret = file_sendfile(outfile, infile, offset, count); - fs_putfilep(outfile); - fs_putfilep(infile); + file_put(outfile); + file_put(infile); if (ret < 0) { goto errout; diff --git a/fs/vfs/fs_signalfd.c b/fs/vfs/fs_signalfd.c index 4ebffc58f1..dedc3c3cc0 100644 --- a/fs/vfs/fs_signalfd.c +++ b/fs/vfs/fs_signalfd.c @@ -364,7 +364,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags) } else { - if (fs_getfilep(fd, &filep) < 0) + if (file_get(fd, &filep) < 0) { ret = EBADF; 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) { - fs_putfilep(filep); + file_put(filep); goto errout; } @@ -402,7 +402,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags) if (filep != NULL) { - fs_putfilep(filep); + file_put(filep); } return fd; diff --git a/fs/vfs/fs_syncfs.c b/fs/vfs/fs_syncfs.c index 33284b9177..349684b7b3 100644 --- a/fs/vfs/fs_syncfs.c +++ b/fs/vfs/fs_syncfs.c @@ -84,11 +84,11 @@ int syncfs(int fd) enter_cancellation_point(); - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret == OK) { ret = file_syncfs(filep); - fs_putfilep(filep); + file_put(filep); } leave_cancellation_point(); diff --git a/fs/vfs/fs_timerfd.c b/fs/vfs/fs_timerfd.c index 5b67fdfc13..5760da3eb5 100644 --- a/fs/vfs/fs_timerfd.c +++ b/fs/vfs/fs_timerfd.c @@ -509,7 +509,7 @@ int timerfd_settime(int fd, int flags, /* Get file pointer by file descriptor */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret < 0) { 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) { leave_critical_section(intflags); - fs_putfilep(filep); + file_put(filep); return OK; } @@ -607,11 +607,11 @@ int timerfd_settime(int fd, int flags, } leave_critical_section(intflags); - fs_putfilep(filep); + file_put(filep); return OK; errout_with_filep: - fs_putfilep(filep); + file_put(filep); errout: set_errno(-ret); return ERROR; @@ -634,7 +634,7 @@ int timerfd_gettime(int fd, FAR struct itimerspec *curr_value) /* Get file pointer by file descriptor */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret < 0) { 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) { - fs_putfilep(filep); + file_put(filep); 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_interval, dev->delay); - fs_putfilep(filep); + file_put(filep); return OK; errout: diff --git a/fs/vfs/fs_truncate.c b/fs/vfs/fs_truncate.c index d27d30e02a..0be857e2ff 100644 --- a/fs/vfs/fs_truncate.c +++ b/fs/vfs/fs_truncate.c @@ -170,7 +170,7 @@ int ftruncate(int fd, off_t length) /* Get the file structure corresponding to the file descriptor. */ - ret = fs_getfilep(fd, &filep); + ret = file_get(fd, &filep); if (ret < 0) { 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 */ ret = file_truncate(filep, length); - fs_putfilep(filep); + file_put(filep); if (ret >= 0) { #ifdef CONFIG_FS_NOTIFY diff --git a/fs/vfs/fs_write.c b/fs/vfs/fs_write.c index a18727a9c9..303b0be76a 100644 --- a/fs/vfs/fs_write.c +++ b/fs/vfs/fs_write.c @@ -276,10 +276,10 @@ ssize_t nx_writev(int fd, FAR const struct iovec *iov, int iovcnt) ssize_t ret; /* 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) { /* 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); - fs_putfilep(filep); + file_put(filep); } return ret; diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 4d4d45d0bf..016fbc0618 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -1171,7 +1171,7 @@ int nx_open_from_tcb(FAR struct tcb_s *tcb, int nx_open(FAR const char *path, int oflags, ...); /**************************************************************************** - * Name: fs_getfilep + * Name: file_get * * Description: * 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: * 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: * 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 diff --git a/net/local/local_sendmsg.c b/net/local/local_sendmsg.c index b64bdf5b3b..d743ed80d1 100644 --- a/net/local/local_sendmsg.c +++ b/net/local/local_sendmsg.c @@ -111,7 +111,7 @@ static int local_sendctl(FAR struct local_conn_s *conn, for (i = 0; i < count; i++) { - ret = fs_getfilep(fds[i], &filep); + ret = file_get(fds[i], &filep); if (ret < 0) { goto fail; @@ -120,13 +120,13 @@ static int local_sendctl(FAR struct local_conn_s *conn, filep2 = kmm_zalloc(sizeof(*filep2)); if (!filep2) { - fs_putfilep(filep); + file_put(filep); ret = -ENOMEM; goto fail; } ret = file_dup2(filep, filep2); - fs_putfilep(filep); + file_put(filep); if (ret < 0) { kmm_free(filep2); diff --git a/net/socket/bind.c b/net/socket/bind.c index 80bbdbd4fb..a1943b2cba 100644 --- a/net/socket/bind.c +++ b/net/socket/bind.c @@ -164,7 +164,7 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) if (ret == OK) { ret = psock_bind(psock, addr, addrlen); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/connect.c b/net/socket/connect.c index 5fa85a2ad8..104ca1e380 100644 --- a/net/socket/connect.c +++ b/net/socket/connect.c @@ -241,7 +241,7 @@ int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen) if (ret == OK) { ret = psock_connect(psock, addr, addrlen); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/getpeername.c b/net/socket/getpeername.c index d405560cf2..5f6877c4fd 100644 --- a/net/socket/getpeername.c +++ b/net/socket/getpeername.c @@ -160,7 +160,7 @@ int getpeername(int sockfd, FAR struct sockaddr *addr, if (ret == OK) { ret = psock_getpeername(psock, addr, addrlen); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/getsockname.c b/net/socket/getsockname.c index edc2afb1c2..b112b548ba 100644 --- a/net/socket/getsockname.c +++ b/net/socket/getsockname.c @@ -158,7 +158,7 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, if (ret == OK) { ret = psock_getsockname(psock, addr, addrlen); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/getsockopt.c b/net/socket/getsockopt.c index df4fdd61e7..2f01f39e48 100644 --- a/net/socket/getsockopt.c +++ b/net/socket/getsockopt.c @@ -365,7 +365,7 @@ int getsockopt(int sockfd, int level, int option, if (ret == OK) { ret = psock_getsockopt(psock, level, option, value, value_len); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/listen.c b/net/socket/listen.c index 1ad095def7..8f8f2c0615 100644 --- a/net/socket/listen.c +++ b/net/socket/listen.c @@ -154,7 +154,7 @@ int listen(int sockfd, int backlog) if (ret == OK) { ret = psock_listen(psock, backlog); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index 0695499401..c4462bfdb7 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -200,7 +200,7 @@ ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, if (ret == OK) { ret = psock_recvfrom(psock, buf, len, flags, from, fromlen); - fs_putfilep(filep); + file_put(filep); } #ifdef CONFIG_BUILD_KERNEL diff --git a/net/socket/recvmsg.c b/net/socket/recvmsg.c index 408fdf2749..9543c6b6f6 100644 --- a/net/socket/recvmsg.c +++ b/net/socket/recvmsg.c @@ -179,7 +179,7 @@ ssize_t recvmsg(int sockfd, FAR struct msghdr *msg, int flags) if (ret == OK) { ret = psock_recvmsg(psock, msg, flags); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/sendmsg.c b/net/socket/sendmsg.c index d22aaa1d1f..cbcc647ebb 100644 --- a/net/socket/sendmsg.c +++ b/net/socket/sendmsg.c @@ -158,7 +158,7 @@ ssize_t sendmsg(int sockfd, FAR struct msghdr *msg, int flags) if (ret == OK) { ret = psock_sendmsg(psock, msg, flags); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/sendto.c b/net/socket/sendto.c index d83e5f5b55..16f4ddb31d 100644 --- a/net/socket/sendto.c +++ b/net/socket/sendto.c @@ -245,7 +245,7 @@ ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags, if (ret == OK) { ret = psock_sendto(psock, buf, len, flags, to, tolen); - fs_putfilep(filep); + file_put(filep); } #ifdef CONFIG_BUILD_KERNEL diff --git a/net/socket/setsockopt.c b/net/socket/setsockopt.c index d4ec83c26b..5e3a59157a 100644 --- a/net/socket/setsockopt.c +++ b/net/socket/setsockopt.c @@ -401,7 +401,7 @@ int setsockopt(int sockfd, int level, int option, const void *value, if (ret == OK) { ret = psock_setsockopt(psock, level, option, value, value_len); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/net/socket/shutdown.c b/net/socket/shutdown.c index f160b25156..fa8d875544 100644 --- a/net/socket/shutdown.c +++ b/net/socket/shutdown.c @@ -141,7 +141,7 @@ int shutdown(int sockfd, int how) if (ret == OK) { ret = psock_shutdown(psock, how); - fs_putfilep(filep); + file_put(filep); } if (ret < 0) diff --git a/sched/mqueue/mq_getattr.c b/sched/mqueue/mq_getattr.c index 09fce68af2..3b6c507fc2 100644 --- a/sched/mqueue/mq_getattr.c +++ b/sched/mqueue/mq_getattr.c @@ -105,11 +105,11 @@ int mq_getattr(mqd_t mqdes, struct mq_attr *mq_stat) FAR struct file *filep; int ret; - ret = fs_getfilep(mqdes, &filep); + ret = file_get(mqdes, &filep); if (ret >= 0) { ret = file_mq_getattr(filep, mq_stat); - fs_putfilep(filep); + file_put(filep); if (ret >= 0) { return OK; diff --git a/sched/mqueue/mq_notify.c b/sched/mqueue/mq_notify.c index eceba33b9d..ea1f35fc27 100644 --- a/sched/mqueue/mq_notify.c +++ b/sched/mqueue/mq_notify.c @@ -104,7 +104,7 @@ int mq_notify(mqd_t mqdes, FAR const struct sigevent *notification) irqstate_t flags; int errval; - errval = fs_getfilep(mqdes, &filep); + errval = file_get(mqdes, &filep); if (errval < 0) { errval = -errval; @@ -184,14 +184,14 @@ int mq_notify(mqd_t mqdes, FAR const struct sigevent *notification) } leave_critical_section(flags); - fs_putfilep(filep); + file_put(filep); return OK; errout: leave_critical_section(flags); errout_with_filep: - fs_putfilep(filep); + file_put(filep); errout_without_lock: set_errno(errval); diff --git a/sched/mqueue/mq_receive.c b/sched/mqueue/mq_receive.c index 6fd024c69d..231b4c5d4f 100644 --- a/sched/mqueue/mq_receive.c +++ b/sched/mqueue/mq_receive.c @@ -371,14 +371,14 @@ ssize_t nxmq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen, FAR struct file *filep; ssize_t ret; - ret = fs_getfilep(mqdes, &filep); + ret = file_get(mqdes, &filep); if (ret < 0) { return ret; } ret = file_mq_timedreceive_internal(filep, msg, msglen, prio, abstime, -1); - fs_putfilep(filep); + file_put(filep); return ret; } @@ -521,14 +521,14 @@ ssize_t nxmq_receive(mqd_t mqdes, FAR char *msg, size_t msglen, FAR struct file *filep; ssize_t ret; - ret = fs_getfilep(mqdes, &filep); + ret = file_get(mqdes, &filep); if (ret < 0) { return ret; } ret = file_mq_receive(filep, msg, msglen, prio); - fs_putfilep(filep); + file_put(filep); return ret; } diff --git a/sched/mqueue/mq_send.c b/sched/mqueue/mq_send.c index b95d266d7a..ec7fde1843 100644 --- a/sched/mqueue/mq_send.c +++ b/sched/mqueue/mq_send.c @@ -519,14 +519,14 @@ int nxmq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, FAR struct file *filep; int ret; - ret = fs_getfilep(mqdes, &filep); + ret = file_get(mqdes, &filep); if (ret < 0) { return ret; } ret = file_mq_timedsend_internal(filep, msg, msglen, prio, abstime, -1); - fs_putfilep(filep); + file_put(filep); return ret; } @@ -671,14 +671,14 @@ int nxmq_send(mqd_t mqdes, FAR const char *msg, size_t msglen, FAR struct file *filep; int ret; - ret = fs_getfilep(mqdes, &filep); + ret = file_get(mqdes, &filep); if (ret < 0) { return ret; } ret = file_mq_timedsend_internal(filep, msg, msglen, prio, NULL, -1); - fs_putfilep(filep); + file_put(filep); return ret; } diff --git a/sched/mqueue/mq_setattr.c b/sched/mqueue/mq_setattr.c index 777a9c46f3..7f70984b7f 100644 --- a/sched/mqueue/mq_setattr.c +++ b/sched/mqueue/mq_setattr.c @@ -117,11 +117,11 @@ int mq_setattr(mqd_t mqdes, const struct mq_attr *mq_stat, FAR struct file *filep; int ret; - ret = fs_getfilep(mqdes, &filep); + ret = file_get(mqdes, &filep); if (ret >= 0) { ret = file_mq_setattr(filep, mq_stat, oldstat); - fs_putfilep(filep); + file_put(filep); if (ret >= 0) { return OK;