From: Nate Karstens <nate.karstens@garmin.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Jeff Layton <jlayton@kernel.org>,
"J. Bruce Fields" <bfields@fieldses.org>,
Arnd Bergmann <arnd@arndb.de>,
Richard Henderson <rth@twiddle.net>,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
Matt Turner <mattst88@gmail.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Helge Deller <deller@gmx.de>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, <linux-fsdevel@vger.kernel.org>,
<linux-arch@vger.kernel.org>, <linux-alpha@vger.kernel.org>,
<linux-parisc@vger.kernel.org>, <sparclinux@vger.kernel.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Changli Gao <xiaosuo@gmail.com>,
Nate Karstens <nate.karstens@garmin.com>
Subject: [PATCH 3/4] fs: Add F_DUPFD_CLOFORK to fcntl(2)
Date: Mon, 20 Apr 2020 02:15:47 -0500 [thread overview]
Message-ID: <20200420071548.62112-4-nate.karstens@garmin.com> (raw)
In-Reply-To: <20200420071548.62112-1-nate.karstens@garmin.com>
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(+)
diff --git a/fs/fcntl.c b/fs/fcntl.c
index b59b27c3a338..43ca3e3dacc5 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -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:
diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index ca88b7bce553..9e1069ff3a22 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -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.
diff --git a/tools/include/uapi/linux/fcntl.h b/tools/include/uapi/linux/fcntl.h
index ca88b7bce553..9e1069ff3a22 100644
--- a/tools/include/uapi/linux/fcntl.h
+++ b/tools/include/uapi/linux/fcntl.h
@@ -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.
--
2.26.1
next prev parent reply other threads:[~2020-04-20 7:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 7:15 Implement close-on-fork Nate Karstens
2020-04-20 7:15 ` [PATCH 1/4] fs: " Nate Karstens
2020-04-20 10:25 ` Eric Dumazet
2020-04-22 3:38 ` Changli Gao
2020-04-22 3:41 ` Changli Gao
2020-04-22 8:35 ` David Laight
2020-05-01 14:45 ` Karstens, Nate
2020-05-01 15:23 ` Matthew Wilcox
2020-05-03 13:52 ` David Laight
2020-04-22 15:36 ` Karstens, Nate
2020-04-22 15:43 ` Matthew Wilcox
2020-04-22 16:02 ` Karstens, Nate
2020-04-22 16:31 ` Bernd Petrovitsch
2020-04-22 16:55 ` David Laight
2020-04-23 12:34 ` Bernd Petrovitsch
2020-04-20 7:15 ` [PATCH 2/4] fs: Add O_CLOFORK flag for open(2) and dup3(2) Nate Karstens
2020-04-20 7:15 ` Nate Karstens [this message]
2020-04-20 7:15 ` [PATCH 4/4] net: Add SOCK_CLOFORK Nate Karstens
2020-04-22 14:32 ` Implement close-on-fork James Bottomley
2020-04-22 15:01 ` Al Viro
2020-04-22 15:18 ` Matthew Wilcox
2020-04-22 15:34 ` James Bottomley
2020-04-22 16:00 ` Al Viro
2020-04-22 16:13 ` Al Viro
2020-05-04 13:46 ` Karstens, Nate
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200420071548.62112-4-nate.karstens@garmin.com \
--to=nate.karstens@garmin.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=arnd@arndb.de \
--cc=bfields@fieldses.org \
--cc=davem@davemloft.net \
--cc=deller@gmx.de \
--cc=ink@jurassic.park.msu.ru \
--cc=jlayton@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=rth@twiddle.net \
--cc=sparclinux@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xiaosuo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).