@@ -333,6 +333,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
case F_DUPFD_CLOEXEC:
err = f_dupfd(arg, filp, O_CLOEXEC);
break;
+ case F_DUPFD_CLOFORK:
+ err = f_dupfd(arg, filp, O_CLOFORK);
+ break;
case F_GETFD:
err = get_close_on_exec(fd) ? FD_CLOEXEC : 0;
err |= get_close_on_fork(fd) ? FD_CLOFORK : 0;
@@ -439,6 +442,7 @@ static int check_fcntl_cmd(unsigned cmd)
switch (cmd) {
case F_DUPFD:
case F_DUPFD_CLOEXEC:
+ case F_DUPFD_CLOFORK:
case F_GETFD:
case F_SETFD:
case F_GETFL:
@@ -55,6 +55,9 @@
#define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13)
#define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14)
+/* Create a file descriptor with FD_CLOFORK set. */
+#define F_DUPFD_CLOFORK (F_LINUX_SPECIFIC_BASE + 15)
+
/*
* Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be
* used to clear any hints previously set.
@@ -55,6 +55,9 @@
#define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13)
#define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14)
+/* Create a file descriptor with FD_CLOFORK set. */
+#define F_DUPFD_CLOFORK (F_LINUX_SPECIFIC_BASE + 15)
+
/*
* Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be
* used to clear any hints previously set.
Implement functionality for duplicating a file descriptor and having the close-on-fork flag automatically set in the new file descriptor. Signed-off-by: Nate Karstens <nate.karstens@garmin.com> --- fs/fcntl.c | 4 ++++ include/uapi/linux/fcntl.h | 3 +++ tools/include/uapi/linux/fcntl.h | 3 +++ 3 files changed, 10 insertions(+)