From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nate Karstens Subject: [PATCH v2 3/4] fs: Add F_DUPFD_CLOFORK to fcntl(2) Date: Fri, 15 May 2020 10:23:20 -0500 Message-ID: <20200515152321.9280-4-nate.karstens@garmin.com> References: <20200515152321.9280-1-nate.karstens@garmin.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garmin.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QQjMj+RVOA3gQhcB59BEGhR0ZVZ+DwBiLoZN26WeP4M=; b=k1K/A5BFIPA6wU8Lo48HDz6BHwBdHsIzMjinzCgUvwl59wiBoMpEdaOSCoPcVbWz+RlxH/7gERj2HhmZzRZkaY6ocb7r+sDlQSfKgxWSWSl3h7fLlvtCQFxLdD7HsrsqRHc6xtJZA8HEF6l6wsroBJ74SPTXiWteBV0iRVJk6Sg8Ppti0agvIW38+cQ4UocVmyqbWEfn5+sWOuH3381MGNYWUGUpvVmw2Npe/WOm3AQJZawO3dT7+j8iLloMCe+SWM0/r+sSw0GxgG/yj4lSnRP+PYxFOP4K8GkxRitL0xHgd8BsdxJz5V1Rs0razZB5ytjBZ1cRiJ9eco9FkYea9Q== In-Reply-To: <20200515152321.9280-1-nate.karstens@garmin.com> Sender: linux-arch-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Alexander Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , Richard Henderson , Ivan Kokshaysky , Matt Turner , "James E.J. Bottomley" , Helge Deller , "David S. Miller" , Jakub Kicinski , Eric Dumazet , David Laight , 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 , Nate Karstens 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 --- 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 40af2a48702b..e15cdd77b1df 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 = f_getfd(fd); break; @@ -437,6 +440,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