Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp365829imm; Wed, 3 Oct 2018 18:04:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV60Gqr3LY62aiwPqZDIbmsc7T0tiTsmK0FEToOVsfiJZqHzAbl4sH0EqgXXtcAUB49aLGKfg X-Received: by 2002:a63:cc51:: with SMTP id q17-v6mr3524808pgi.291.1538615073443; Wed, 03 Oct 2018 18:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538615073; cv=none; d=google.com; s=arc-20160816; b=a+yxmKi8lyO6k1EoldEIsAJzxu6bx3sCBhItTImLerEBsDUwPW8+jUPaYz1dvqZ/HI ww25aqLbnWkmcf7w+hG25UP8vWT77Jc/c0slYNKLNd0dksPjbTuGxw7Iaur7NNbL8bwD ywJwwtU17K6q6zXEhGqxmEPGwxfp8ywyEYoO4qB2Fo0tdlXx5Sn+Eh1diN3uxwRnNFZD wyJdoDVyOPX9X0abe9R+V0CS29UfSCCAk5qKMTVez3GRdEENRU88eapItgIfShCPxuwG /7h9BtXquvzaJe9y9PMH6AGR8J0c0OivCsF4i3PfT8Zt/XAEs0SwWDaVR+6DcOOlyEaK r1Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from; bh=/JKrDEou9MGW2iCZ5yHt1ZTH2EUPmjhvpfMS6wBJvHA=; b=rHcj9YzPgsYfqJoED8a87xhJ1kS7kIKrSb47o3wojzZfhcRWtsBWcK3nQTZAxDmEP0 bPO6q3ppLFUo0vcP+udBGFD/f/1rhhpKAfOMTc2Xrhtlvzt8O4eSalA1Bx/St3gDecou odi+7Z7N17m+hos/Y/x4z8F87qRF2puu2PzJSimZSfgrQVlXW2DkRzRbLqrIO36zqkXq Q5l/CBREXvK1/BrfH4+mniqazqcKMs9wZsWhKvnT84YshvzXdcNAIypPO53LCPBu9/b9 m4SgG5QdHRMMO2pZcR0Zgm5qOZl4yzGkkKf87dQw5nXQ+QxhbOtzdQMBLxzPEti4qMUp P6ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6-v6si3285170pfb.161.2018.10.03.18.04.18; Wed, 03 Oct 2018 18:04:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbeJDHyW (ORCPT + 99 others); Thu, 4 Oct 2018 03:54:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:56078 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726277AbeJDHyW (ORCPT ); Thu, 4 Oct 2018 03:54:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0150BAFFF; Thu, 4 Oct 2018 01:03:32 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Anna Schumaker , Alexander Viro , Trond Myklebust Date: Thu, 04 Oct 2018 11:02:43 +1000 Subject: [PATCH 2/3] VFS: allow MAY_ flags to be easily extended. 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 Message-ID: <153861496332.30373.4846710512713338280.stgit@noble> In-Reply-To: <153861471803.30373.6184444014227748848.stgit@noble> References: <153861471803.30373.6184444014227748848.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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..b0076cb0f738 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 0x00000100 + /* * 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()