From patchwork Thu Oct 4 02:11:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10625479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C68E215E8 for ; Thu, 4 Oct 2018 02:11:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7FDE2916C for ; Thu, 4 Oct 2018 02:11:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 996BE2916F; Thu, 4 Oct 2018 02:11:51 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 3055B2916C for ; Thu, 4 Oct 2018 02:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbeJDJCs (ORCPT ); Thu, 4 Oct 2018 05:02:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:33952 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726268AbeJDJCs (ORCPT ); Thu, 4 Oct 2018 05:02:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 315D5B011; Thu, 4 Oct 2018 02:11:46 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Anna Schumaker , Alexander Viro , Trond Myklebust Date: Thu, 04 Oct 2018 12:11:33 +1000 Cc: Jan Harkes , linux-nfs@vger.kernel.org, Miklos Szeredi , Jeff Layton , linux-kernel@vger.kernel.org, linux-afs@lists.infradead.org, David Howells , coda@cs.cmu.edu, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: [PATCH 2/3 v2] VFS: allow MAY_ flags to be easily extended. In-Reply-To: <153861496332.30373.4846710512713338280.stgit@noble> References: <153861471803.30373.6184444014227748848.stgit@noble> <153861496332.30373.4846710512713338280.stgit@noble> Message-ID: <87ftxmtq96.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP NFSD uses permission flags similar to the MAY_* flags, with some overlap, and depends on the overlap matching. This is currently a little fragile and hard to extend. So add __MAY_UNUSED to identify the first unused flag, and have NFSD use that flag and later flags for its non-standard permissions. Signed-off-by: NeilBrown --- v1 of this patch had an obvious bug which, of course, I couldn't see until after posting. __MAY_UNUSED had the same value as MAY_ACT_AS_OWNER - so it wasn't unused! NeilBrown fs/nfsd/vfs.h | 33 ++++++++++++++++++--------------- include/linux/fs.h | 2 ++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index a7e107309f76..2b1c70d3757a 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -13,23 +13,26 @@ * Flags for nfsd_permission */ #define NFSD_MAY_NOP 0 -#define NFSD_MAY_EXEC 0x001 /* == MAY_EXEC */ -#define NFSD_MAY_WRITE 0x002 /* == MAY_WRITE */ -#define NFSD_MAY_READ 0x004 /* == MAY_READ */ -#define NFSD_MAY_SATTR 0x008 -#define NFSD_MAY_TRUNC 0x010 -#define NFSD_MAY_LOCK 0x020 -#define NFSD_MAY_MASK 0x03f +#define NFSD_MAY_EXEC MAY_EXEC +#define NFSD_MAY_WRITE MAY_WRITE +#define NFSD_MAY_READ MAY_READ +#define NFSD_MAY_SATTR (__MAY_UNUSED << 0) +#define NFSD_MAY_TRUNC (__MAY_UNUSED << 1) +#define NFSD_MAY_LOCK (__MAY_UNUSED << 2) +#define __NFSD_MAY_FIRST_HINT (__MAY_UNUSED << 3) +#define NFSD_MAY_MASK (__NFSD_MAY_FIRST_HINT - 1) /* extra hints to permission and open routines: */ -#define NFSD_MAY_OWNER_OVERRIDE 0x040 -#define NFSD_MAY_LOCAL_ACCESS 0x080 /* for device special files */ -#define NFSD_MAY_BYPASS_GSS_ON_ROOT 0x100 -#define NFSD_MAY_NOT_BREAK_LEASE 0x200 -#define NFSD_MAY_BYPASS_GSS 0x400 -#define NFSD_MAY_READ_IF_EXEC 0x800 - -#define NFSD_MAY_64BIT_COOKIE 0x1000 /* 64 bit readdir cookies for >= NFSv3 */ +#define NFSD_MAY_OWNER_OVERRIDE (__NFSD_MAY_FIRST_HINT << 0) +/* for device special files */ +#define NFSD_MAY_LOCAL_ACCESS (__NFSD_MAY_FIRST_HINT << 1) +#define NFSD_MAY_BYPASS_GSS_ON_ROOT (__NFSD_MAY_FIRST_HINT << 2) +#define NFSD_MAY_NOT_BREAK_LEASE (__NFSD_MAY_FIRST_HINT << 3) +#define NFSD_MAY_BYPASS_GSS (__NFSD_MAY_FIRST_HINT << 4) +#define NFSD_MAY_READ_IF_EXEC (__NFSD_MAY_FIRST_HINT << 5) + +/* 64 bit readdir cookies for >= NFSv3 */ +#define NFSD_MAY_64BIT_COOKIE (__NFSD_MAY_FIRST_HINT << 6) #define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE) #define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC) diff --git a/include/linux/fs.h b/include/linux/fs.h index 5a8878a88cbb..9fc914c259f9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -103,6 +103,8 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, */ #define MAY_ACT_AS_OWNER 0x00000100 +#define __MAY_UNUSED 0x00000200 + /* * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond * to O_WRONLY and O_RDWR via the strange trick in do_dentry_open()