From patchwork Thu Mar 30 16:33:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9654777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F08BD60113 for ; Thu, 30 Mar 2017 16:34:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E198B285BC for ; Thu, 30 Mar 2017 16:34:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D493B285C4; Thu, 30 Mar 2017 16:34:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E1C7285BC for ; Thu, 30 Mar 2017 16:34:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933522AbdC3Qdj (ORCPT ); Thu, 30 Mar 2017 12:33:39 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:44697 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933474AbdC3Qdh (ORCPT ); Thu, 30 Mar 2017 12:33:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=m8UU2bM+5EYPEmAPtM7pIBKIXcbS7OdfgVE54JxuPMo=; b=NEXYPUxFo4awRV8bi+Zdvu5Ue Gt10hiNbWiTRKmdj0Y23qbfaASbfGeW/9jdEHd/zNnOJf2KUEyqKhazyh/1xHczcoxMzPNN17lWMG 3bZMSG+zT36ouZpPq8zS3bxRo0z+UAt7kDmYMGOUwyL+ZBrfl4ycMzKotB/wMNe3LjtzrA9sSplCW EkMk1g0y9kAQGzMNsGl8g3L4nrQcy37cjMwCEyL8xu318pU9HqfEBasEQZ1f8DsiWdnjJRUE6ZqbR 4Y69u4+plebmEoBkfyeVyEzm9QeyMuH45AYE/dpXG0t11HqW91WuctdJnd/RXrSHmedwE0oqivWbC IGktDeZWA==; Received: from pat.hitachigst.com ([199.255.44.5] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1ctd0w-00085H-Mv; Thu, 30 Mar 2017 16:33:35 +0000 From: Christoph Hellwig To: Linus Torvalds , Alexander Viro Cc: linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, libc-alpha@sourceware.org Subject: [PATCH 1/2] fs: add a VALID_OPEN_FLAGS Date: Thu, 30 Mar 2017 18:33:26 +0200 Message-Id: <20170330163327.23920-2-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170330163327.23920-1-hch@lst.de> References: <20170330163327.23920-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a central define for all valid open flags, and use it in the uniqueness check. Signed-off-by: Christoph Hellwig --- fs/fcntl.c | 14 ++++---------- include/linux/fcntl.h | 6 ++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index be8fbe289087..de1b16bb6a29 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -742,16 +742,10 @@ static int __init fcntl_init(void) * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY * is defined as O_NONBLOCK on some platforms and not on others. */ - BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32( - O_RDONLY | O_WRONLY | O_RDWR | - O_CREAT | O_EXCL | O_NOCTTY | - O_TRUNC | O_APPEND | /* O_NONBLOCK | */ - __O_SYNC | O_DSYNC | FASYNC | - O_DIRECT | O_LARGEFILE | O_DIRECTORY | - O_NOFOLLOW | O_NOATIME | O_CLOEXEC | - __FMODE_EXEC | O_PATH | __O_TMPFILE | - __FMODE_NONOTIFY - )); + BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ != + HWEIGHT32( + (VALID_OPEN_FLAGS & ~(O_NONBLOCK | O_NDELAY)) | + __FMODE_EXEC | __FMODE_NONOTIFY)); fasync_cache = kmem_cache_create("fasync_cache", sizeof(struct fasync_struct), 0, SLAB_PANIC, NULL); diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h index 76ce329e656d..1b48d9c9a561 100644 --- a/include/linux/fcntl.h +++ b/include/linux/fcntl.h @@ -3,6 +3,12 @@ #include +/* list of all valid flags for the open/openat flags argument: */ +#define VALID_OPEN_FLAGS \ + (O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC | \ + O_APPEND | O_NDELAY | O_NONBLOCK | O_NDELAY | __O_SYNC | O_DSYNC | \ + FASYNC | O_DIRECT | O_LARGEFILE | O_DIRECTORY | O_NOFOLLOW | \ + O_NOATIME | O_CLOEXEC | O_PATH | __O_TMPFILE) #ifndef force_o_largefile #define force_o_largefile() (BITS_PER_LONG != 32)