mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
fs/vfs: Add nx_dup and nx_dup2 function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
+46
-24
@@ -721,8 +721,7 @@ void files_releaselist(FAR struct filelist *list);
|
||||
*
|
||||
* Description:
|
||||
* Equivalent to the non-standard fs_dupfd() function except that it
|
||||
* accepts a struct file instance instead of a file descriptor and does
|
||||
* not set the errno variable.
|
||||
* accepts a struct file instance instead of a file descriptor.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
@@ -733,27 +732,41 @@ void files_releaselist(FAR struct filelist *list);
|
||||
int file_dup(FAR struct file *filep, int minfd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fs_dupfd OR dup
|
||||
* Name: fs_dupfd
|
||||
*
|
||||
* Description:
|
||||
* Clone a file descriptor 'fd' to an arbitrary descriptor number (any
|
||||
* value greater than or equal to 'minfd'). If socket descriptors are
|
||||
* implemented, then this is called by dup() for the case of file
|
||||
* descriptors. If socket descriptors are not implemented, then this
|
||||
* function IS dup().
|
||||
* value greater than or equal to 'minfd').
|
||||
*
|
||||
* This alternative naming is used when dup could operate on both file and
|
||||
* socket descriptors to avoid drawing unused socket support into the link.
|
||||
*
|
||||
* Returned Value:
|
||||
* fs_dupfd is sometimes an OS internal function and sometimes is a direct
|
||||
* substitute for dup(). So it must return an errno value as though it
|
||||
* were dup().
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int fs_dupfd(int fd, int minfd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_dup
|
||||
*
|
||||
* Description:
|
||||
* nx_dup() is similar to the standard 'dup' interface except that is
|
||||
* not a cancellation point and it does not modify the errno variable.
|
||||
*
|
||||
* nx_dup() is an internal NuttX interface and should not be called from
|
||||
* applications.
|
||||
*
|
||||
* Returned Value:
|
||||
* The new file descriptor is returned on success; a negated errno value is
|
||||
* returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_dup(int fd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_dup2
|
||||
*
|
||||
@@ -762,8 +775,7 @@ int fs_dupfd(int fd, int minfd);
|
||||
* dup2.
|
||||
*
|
||||
* Equivalent to the non-standard fs_dupfd2() function except that it
|
||||
* accepts struct file instances instead of file descriptors and it does
|
||||
* not set the errno variable.
|
||||
* accepts struct file instances instead of file descriptors.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is return on
|
||||
@@ -774,29 +786,39 @@ int fs_dupfd(int fd, int minfd);
|
||||
int file_dup2(FAR struct file *filep1, FAR struct file *filep2);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fs_dupfd2 OR dup2
|
||||
* Name: fs_dupfd2
|
||||
*
|
||||
* Description:
|
||||
* Clone a file descriptor to a specific descriptor number. If socket
|
||||
* descriptors are implemented, then this is called by dup2() for the
|
||||
* case of file descriptors. If socket descriptors are not implemented,
|
||||
* then this function IS dup2().
|
||||
* Clone a file descriptor to a specific descriptor number.
|
||||
*
|
||||
* This alternative naming is used when dup2 could operate on both file and
|
||||
* socket descriptors to avoid drawing unused socket support into the link.
|
||||
*
|
||||
* Returned Value:
|
||||
* fs_dupfd2 is sometimes an OS internal function and sometimes is a direct
|
||||
* substitute for dup2(). So it must return an errno value as though it
|
||||
* were dup2().
|
||||
* Zero (OK) is returned on success; a negated errno value is return on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
int fs_dupfd2(int fd1, int fd2);
|
||||
#else
|
||||
# define fs_dupfd2(fd1, fd2) dup2(fd1, fd2)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_dup2
|
||||
*
|
||||
* Description:
|
||||
* nx_dup2() is similar to the standard 'dup2' interface except that is
|
||||
* not a cancellation point and it does not modify the errno variable.
|
||||
*
|
||||
* nx_dup2() is an internal NuttX interface and should not be called from
|
||||
* applications.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is return on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_dup2(int fd1, int fd2);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_open
|
||||
|
||||
+9
-18
@@ -1341,14 +1341,11 @@ int net_poll(int sockfd, struct pollfd *fds, bool setup);
|
||||
* Name: psock_dup
|
||||
*
|
||||
* Description:
|
||||
* Clone a socket descriptor to an arbitrary descriptor number. If file
|
||||
* descriptors are implemented, then this is called by dup() for the case
|
||||
* of socket file descriptors. If file descriptors are not implemented,
|
||||
* then this function IS dup().
|
||||
* Clone a socket descriptor to an arbitrary descriptor number.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On any error,
|
||||
* a negated errno value is returned:.
|
||||
* On success, returns the number of new socket. On any error,
|
||||
* a negated errno value is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -1358,14 +1355,11 @@ int psock_dup(FAR struct socket *psock, int minsd);
|
||||
* Name: net_dup
|
||||
*
|
||||
* Description:
|
||||
* Clone a socket descriptor to an arbitrary descriptor number. If file
|
||||
* descriptors are implemented, then this is called by dup() for the case
|
||||
* of socket file descriptors. If file descriptors are not implemented,
|
||||
* then this function IS dup().
|
||||
* Clone a socket descriptor to an arbitrary descriptor number.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On any error,
|
||||
* a negated errno value is returned:.
|
||||
* On success, returns the number of new socket. On any error,
|
||||
* a negated errno value is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -1385,14 +1379,11 @@ int psock_dup2(FAR struct socket *psock1, FAR struct socket *psock2);
|
||||
* Name: net_dup2
|
||||
*
|
||||
* Description:
|
||||
* Clone a socket descriptor to an arbitrary descriptor number. If file
|
||||
* descriptors are implemented, then this is called by dup2() for the case
|
||||
* of socket file descriptors. If file descriptors are not implemented,
|
||||
* then this function IS dup2().
|
||||
* Clone a socket descriptor to an arbitrary descriptor number.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On any error,
|
||||
* a negated errno value is returned:.
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user