vfs/file: add reference counting to prevent accidental close during reading writing...

Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
This commit is contained in:
Shoukui Zhang
2024-09-17 12:01:53 +08:00
committed by Xiang Xiao
parent f2fd0bc148
commit 43223124ec
50 changed files with 335 additions and 146 deletions
+4 -1
View File
@@ -32,6 +32,7 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/fs/fs.h>
#include <nuttx/net/net.h>
#include "socket/socket.h"
@@ -151,17 +152,19 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
FAR struct socket *psock;
FAR struct file *filep;
int ret;
/* Get the underlying socket structure */
ret = sockfd_socket(sockfd, &psock);
ret = sockfd_socket(sockfd, &filep, &psock);
/* Then let psock_bind do all of the work */
if (ret == OK)
{
ret = psock_bind(psock, addr, addrlen);
fs_putfilep(filep);
}
if (ret < 0)