From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: sfrench@us.ibm.com, ffilz@us.ibm.com, agruen@suse.de,
adilger@sun.com, sandeen@redhat.com, tytso@mit.edu,
staubach@redhat.com, bfields@citi.umich.edu, jlayton@redhat.com
Cc: aneesh.kumar@linux.vnet.ibm.com, linux-fsdevel@vger.kernel.org,
nfsv4@linux-nfs.org, linux-ext4@vger.kernel.org
Subject: [PATCH 10/23] richacl: Add separate file and dir acl masks
Date: Mon, 1 Feb 2010 11:04:52 +0530 [thread overview]
Message-ID: <1265002505-8387-11-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1265002505-8387-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
fs/richacl_base.c | 54 +++++++++++++++++++++++++++--------------------
fs/richacl_posix.c | 27 ++++++++++++-----------
include/linux/richacl.h | 2 +-
3 files changed, 46 insertions(+), 37 deletions(-)
diff --git a/fs/richacl_base.c b/fs/richacl_base.c
index a176399..0d8953c 100644
--- a/fs/richacl_base.c
+++ b/fs/richacl_base.c
@@ -76,23 +76,23 @@ richacl_clone(const struct richacl *acl)
* make sure that we do not mask them if they are set, so that users who
* rely on these flags won't get confused.
*/
-#define ACE4_POSIX_MODE_READ ( \
- ACE4_READ_DATA | ACE4_LIST_DIRECTORY)
-#define ACE4_POSIX_MODE_WRITE ( \
- ACE4_WRITE_DATA | ACE4_ADD_FILE | \
- ACE4_APPEND_DATA | ACE4_ADD_SUBDIRECTORY | \
+#define ACE4_POSIX_MODE_FILE_READ ACE4_READ_DATA
+#define ACE4_POSIX_MODE_FILE_WRITE ( \
+ ACE4_WRITE_DATA | ACE4_APPEND_DATA)
+#define ACE4_POSIX_MODE_DIR_READ ACE4_LIST_DIRECTORY
+#define ACE4_POSIX_MODE_DIR_WRITE ( \
+ ACE4_ADD_FILE | ACE4_ADD_SUBDIRECTORY | \
ACE4_DELETE_CHILD)
-#define ACE4_POSIX_MODE_EXEC ( \
- ACE4_EXECUTE)
+#define ACE4_POSIX_MODE_EXEC ACE4_EXECUTE
static int
richacl_mask_to_mode(unsigned int mask)
{
int mode = 0;
- if (mask & ACE4_POSIX_MODE_READ)
+ if (mask & (ACE4_POSIX_MODE_FILE_READ | ACE4_POSIX_MODE_DIR_READ))
mode |= MAY_READ;
- if (mask & ACE4_POSIX_MODE_WRITE)
+ if (mask & (ACE4_POSIX_MODE_FILE_WRITE | ACE4_POSIX_MODE_DIR_WRITE))
mode |= MAY_WRITE;
if (mask & ACE4_POSIX_MODE_EXEC)
mode |= MAY_EXEC;
@@ -115,14 +115,21 @@ richacl_masks_to_mode(const struct richacl *acl)
EXPORT_SYMBOL_GPL(richacl_masks_to_mode);
unsigned int
-richacl_mode_to_mask(mode_t mode)
+richacl_mode_to_mask(mode_t mode, int is_dir)
{
unsigned int mask = ACE4_POSIX_ALWAYS_ALLOWED;
- if (mode & MAY_READ)
- mask |= ACE4_POSIX_MODE_READ;
- if (mode & MAY_WRITE)
- mask |= ACE4_POSIX_MODE_WRITE;
+ if (is_dir) {
+ if (mode & MAY_READ)
+ mask |= ACE4_POSIX_MODE_DIR_READ;
+ if (mode & MAY_WRITE)
+ mask |= ACE4_POSIX_MODE_DIR_WRITE;
+ } else {
+ if (mode & MAY_READ)
+ mask |= ACE4_POSIX_MODE_FILE_READ;
+ if (mode & MAY_WRITE)
+ mask |= ACE4_POSIX_MODE_FILE_WRITE;
+ }
if (mode & MAY_EXEC)
mask |= ACE4_POSIX_MODE_EXEC;
@@ -141,12 +148,13 @@ richacl_mode_to_mask(mode_t mode)
struct richacl *
richacl_chmod(struct richacl *acl, mode_t mode)
{
+ int is_dir = S_ISDIR(mode);
unsigned int owner_mask, group_mask, other_mask;
struct richacl *clone;
- owner_mask = richacl_mode_to_mask(mode >> 6);
- group_mask = richacl_mode_to_mask(mode >> 3);
- other_mask = richacl_mode_to_mask(mode);
+ owner_mask = richacl_mode_to_mask(mode >> 6, is_dir);
+ group_mask = richacl_mode_to_mask(mode >> 3, is_dir);
+ other_mask = richacl_mode_to_mask(mode, is_dir);
if (acl->a_owner_mask == owner_mask &&
acl->a_group_mask == group_mask &&
@@ -352,7 +360,7 @@ int richacl_generic_permission(struct inode *inode, unsigned int mask)
mode >>= 6;
else if (in_group_p(inode->i_gid))
mode >>= 3;
- if (!(mask & ~richacl_mode_to_mask(mode)))
+ if (!(mask & ~richacl_mode_to_mask(mode, S_ISDIR(inode->i_mode))))
return 0;
return richacl_capability_check(inode, mask);
}
@@ -497,9 +505,9 @@ richacl_inherit(const struct richacl *dir_acl, mode_t mode)
const struct richace *dir_ace;
struct richacl *acl;
struct richace *ace;
- int count = 0;
+ int count = 0, is_dir = S_ISDIR(mode);
- if (S_ISDIR(mode)) {
+ if (is_dir) {
richacl_for_each_entry(dir_ace, dir_acl) {
if (!richace_is_inheritable(dir_ace))
continue;
@@ -555,9 +563,9 @@ richacl_inherit(const struct richacl *dir_acl, mode_t mode)
richacl_compute_max_masks(acl);
/* Apply the create mode. */
- acl->a_owner_mask &= richacl_mode_to_mask(mode >> 6);
- acl->a_group_mask &= richacl_mode_to_mask(mode >> 3);
- acl->a_other_mask &= richacl_mode_to_mask(mode);
+ acl->a_owner_mask &= richacl_mode_to_mask(mode >> 6, is_dir);
+ acl->a_group_mask &= richacl_mode_to_mask(mode >> 3, is_dir);
+ acl->a_other_mask &= richacl_mode_to_mask(mode, is_dir);
if (richacl_write_through(&acl)) {
richacl_put(acl);
diff --git a/fs/richacl_posix.c b/fs/richacl_posix.c
index 3cf2124..437d3ac 100644
--- a/fs/richacl_posix.c
+++ b/fs/richacl_posix.c
@@ -20,11 +20,12 @@
static void posix_to_richacl(struct posix_acl *pacl, int type,
mode_t mode, struct richacl *acl)
{
- int eflags;
+ int eflags, is_dir;
struct richace *ace;
unsigned short deny;
struct posix_acl_entry *pa, *pe, *acl_other = NULL;
+ is_dir = S_ISDIR(mode);
if (type == ACL_TYPE_DEFAULT)
eflags = ACE4_FILE_INHERIT_ACE |
ACE4_DIRECTORY_INHERIT_ACE | ACE4_INHERIT_ONLY_ACE;
@@ -43,7 +44,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
if (deny & 0x7) {
ace->e_type = ACE4_ACCESS_DENIED_ACE_TYPE;
ace->e_flags = eflags;
- ace->e_mask = richacl_mode_to_mask(deny);
+ ace->e_mask = richacl_mode_to_mask(deny, is_dir);
richace_set_who(ace, richace_owner_who);
acl->a_count++;
ace++;
@@ -51,7 +52,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
/* Add allow entry */
ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE;
ace->e_flags = eflags;
- ace->e_mask = richacl_mode_to_mask(pa->e_perm);
+ ace->e_mask = richacl_mode_to_mask(pa->e_perm, is_dir);
ace->e_mask |= ACE4_WRITE_ATTRIBUTES | ACE4_WRITE_ACL;
richace_set_who(ace, richace_owner_who);
acl->a_count++;
@@ -65,7 +66,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
if (deny & 0x7) {
ace->e_type = ACE4_ACCESS_DENIED_ACE_TYPE;
ace->e_flags = eflags;
- ace->e_mask = richacl_mode_to_mask(deny);
+ ace->e_mask = richacl_mode_to_mask(deny, is_dir);
ace->u.e_id = pa->e_id;
acl->a_count++;
ace++;
@@ -73,7 +74,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
/* Add allow entry */
ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE;
ace->e_flags = eflags;
- ace->e_mask = richacl_mode_to_mask(pa->e_perm);
+ ace->e_mask = richacl_mode_to_mask(pa->e_perm, is_dir);
ace->u.e_id = pa->e_id;
acl->a_count++;
ace++;
@@ -88,7 +89,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
*/
ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE;
ace->e_flags = eflags;
- ace->e_mask = richacl_mode_to_mask(pa->e_perm);
+ ace->e_mask = richacl_mode_to_mask(pa->e_perm, is_dir);
richace_set_who(ace, richace_group_who);
acl->a_count++;
ace++;
@@ -100,7 +101,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
/* Add allow entries only */
ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE;
ace->e_flags = eflags | ACE4_IDENTIFIER_GROUP;
- ace->e_mask = richacl_mode_to_mask(pa->e_perm);
+ ace->e_mask = richacl_mode_to_mask(pa->e_perm, is_dir);
ace->u.e_id = pa->e_id;
acl->a_count++;
ace++;
@@ -145,7 +146,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
if (deny & 0x7) {
ace->e_type = ACE4_ACCESS_DENIED_ACE_TYPE;
ace->e_flags = eflags;
- ace->e_mask = richacl_mode_to_mask(deny);
+ ace->e_mask = richacl_mode_to_mask(deny, is_dir);
richace_set_who(ace, richace_group_who);
acl->a_count++;
ace++;
@@ -159,7 +160,7 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
if (deny & 0x7) {
ace->e_type = ACE4_ACCESS_DENIED_ACE_TYPE;
ace->e_flags = eflags | ACE4_IDENTIFIER_GROUP;
- ace->e_mask = richacl_mode_to_mask(deny);
+ ace->e_mask = richacl_mode_to_mask(deny, is_dir);
ace->u.e_id = pa->e_id;
acl->a_count++;
ace++;
@@ -172,16 +173,16 @@ static void posix_to_richacl(struct posix_acl *pacl, int type,
if (acl_other) {
ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE;
ace->e_flags = eflags;
- ace->e_mask = richacl_mode_to_mask(acl_other->e_perm);
+ ace->e_mask = richacl_mode_to_mask(acl_other->e_perm, is_dir);
richace_set_who(ace, richace_everyone_who);
acl->a_count++;
ace++;
}
/* set acl mask values */
- acl->a_owner_mask = richacl_mode_to_mask(mode >> 6);
- acl->a_group_mask = richacl_mode_to_mask(mode >> 3);
- acl->a_other_mask = richacl_mode_to_mask(mode);
+ acl->a_owner_mask = richacl_mode_to_mask(mode >> 6, is_dir);
+ acl->a_group_mask = richacl_mode_to_mask(mode >> 3, is_dir);
+ acl->a_other_mask = richacl_mode_to_mask(mode, is_dir);
/*
* Mark that the acl as mapped from posix
diff --git a/include/linux/richacl.h b/include/linux/richacl.h
index 41d93d8..b0df740 100644
--- a/include/linux/richacl.h
+++ b/include/linux/richacl.h
@@ -230,7 +230,7 @@ extern int richace_is_same_who(const struct richace *, const struct richace *);
extern int richace_set_who(struct richace *ace, const char *who);
extern struct richacl *richacl_inherit(const struct richacl *, mode_t);
extern int richacl_masks_to_mode(const struct richacl *);
-extern unsigned int richacl_mode_to_mask(mode_t mode);
+extern unsigned int richacl_mode_to_mask(mode_t, int);
extern struct richacl *richacl_chmod(struct richacl *, mode_t);
extern int richacl_apply_masks(struct richacl **acl);
extern int richacl_write_through(struct richacl **acl);
--
1.7.0.rc0.48.gdace5
next prev parent reply other threads:[~2010-02-01 5:35 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-01 5:34 [RFC PATCH] New ACL format for better NFSv4 acl interoperability Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 01/23] vfs: VFS hooks for per-filesystem permission models Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 02/23] vfs: Check for create permission during rename Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 03/23] vfs: rich ACL in-memory representation and manipulation Aneesh Kumar K.V
2010-02-01 7:28 ` Brad Boyer
2010-02-01 18:02 ` Aneesh Kumar K. V
2010-02-01 23:06 ` J. Bruce Fields
2010-02-01 23:21 ` J. Bruce Fields
2010-02-01 5:34 ` [PATCH 04/23] richacl: Add write retention and retention hold access mask Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 05/23] ext4: Implement rich acl for ext4 Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 06/23] vfs: Implement those parts of Automatic Inheritance (AI) which are safe under POSIX Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 07/23] vfs: Add Posix acl to rich acl mapping helpers Aneesh Kumar K.V
2010-02-01 23:18 ` J. Bruce Fields
2010-02-02 5:22 ` Aneesh Kumar K. V
2010-02-01 5:34 ` [PATCH 08/23] vfs: Add a flag to denote posix mapped richacl Aneesh Kumar K.V
2010-02-01 23:18 ` J. Bruce Fields
2010-02-02 5:33 ` Aneesh Kumar K. V
2010-02-02 15:18 ` J. Bruce Fields
2010-02-01 5:34 ` [PATCH 09/23] ext4: Add posix acl to rich acl mapping Aneesh Kumar K.V
2010-02-01 5:34 ` Aneesh Kumar K.V [this message]
2010-02-01 5:34 ` [PATCH 11/23] richacl: Move the xattr representation to little-endian format Aneesh Kumar K.V
2010-02-01 23:34 ` J. Bruce Fields
2010-02-02 5:35 ` Aneesh Kumar K. V
2010-02-01 5:34 ` [PATCH 12/23] richacl: Use directory specific mask values for operation on directories Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 13/23] richacl: Follow nfs4 acl delete definition Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 14/23] richacl: Disable automatic inheritance with posix mapped acls Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 15/23] richacl: Delete posix acl if present on richacl set Aneesh Kumar K.V
2010-02-01 5:34 ` [PATCH 16/23] ext4: Update richacl incompat flag value Aneesh Kumar K.V
2010-02-01 23:41 ` J. Bruce Fields
2010-02-01 5:34 ` [PATCH 17/23] vfs: Add new MS_ACL and MS_RICHACL flag Aneesh Kumar K.V
2010-02-01 5:35 ` [PATCH 18/23] richacl: Add helper function for creating richacl from mode values Aneesh Kumar K.V
2010-02-01 5:35 ` [PATCH 19/23] fs: Use the correct MS_*ACL flags in file system code Aneesh Kumar K.V
2010-02-01 5:35 ` [PATCH 20/23] nfsd: Apply NFSv4acl to posix acl mapping only if MS_POSIXACL is set Aneesh Kumar K.V
2010-02-01 5:35 ` [PATCH 21/23] richacl: Add helpers for NFSv4 acl to richacl conversion Aneesh Kumar K.V
2010-02-01 5:35 ` [PATCH 22/23] nfsd: Add support for reading rich acl from file system Aneesh Kumar K.V
2010-02-01 5:35 ` [PATCH 23/23] nfsd: Add support for saving richacl Aneesh Kumar K.V
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=1265002505-8387-11-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=adilger@sun.com \
--cc=agruen@suse.de \
--cc=bfields@citi.umich.edu \
--cc=ffilz@us.ibm.com \
--cc=jlayton@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=sandeen@redhat.com \
--cc=sfrench@us.ibm.com \
--cc=staubach@redhat.com \
--cc=tytso@mit.edu \
/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).