fs/dup3: impletement dup3/nx_dup3_from_tcb function

refs: https://man7.org/linux/man-pages/man2/dup.2.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2023-10-22 16:53:58 +08:00
committed by Xiang Xiao
parent dc2dac2377
commit 73dc8f84cc
7 changed files with 184 additions and 86 deletions
+19 -1
View File
@@ -911,7 +911,7 @@ int file_allocate(FAR struct inode *inode, int oflags, off_t pos,
*
****************************************************************************/
int file_dup(FAR struct file *filep, int minfd, bool cloexec);
int file_dup(FAR struct file *filep, int minfd, int flags);
/****************************************************************************
* Name: file_dup2
@@ -970,6 +970,24 @@ int nx_dup2_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2);
int nx_dup2(int fd1, int fd2);
/****************************************************************************
* Name: file_dup3
*
* Description:
* Assign an inode to a specific files structure. This is the heart of
* dup3.
*
* Equivalent to the non-standard dup3() function except that it
* accepts struct file instances instead of file descriptors.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is return on
* any failure.
*
****************************************************************************/
int file_dup3(FAR struct file *filep1, FAR struct file *filep2, int flags);
/****************************************************************************
* Name: file_open
*
+1
View File
@@ -328,6 +328,7 @@ int daemon(int nochdir, int noclose);
int close(int fd);
int dup(int fd);
int dup2(int fd1, int fd2);
int dup3(int fd1, int fd2, int flags);
int fsync(int fd);
off_t lseek(int fd, off_t offset, int whence);
ssize_t read(int fd, FAR void *buf, size_t nbytes);