Skip to contentSkip to conversation

NFSv4 ACLs on ext3

RFC PATCH New Andreas Gruenbacher 1 participant 4 messages Sep 6, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover NFSv4 ACLs on ext3

I would like to propose the following patches, which implement NFSv4 Access Control Lists on Ext3 filesystems:

[patch 1/3] Pass MAY_APPEND through to permission inode operations
that understand it

[patch 2/3] Add match_string() for mount option parsing

[patch 3/3] NFSv4 ACLs on ext3

The kernel patches and the nfs4acl user-space utility are hosted here, together with an extensive design document, and small bits of user documentation:

http://www.suse.de/~agruen/nfs4acl/

Linux currently supports POSIX (draft) ACLs [1]. The NFSv4 protocol defines its own Access Control List model, which is more powerful but incompatible with POSIX ACLs, and close to the CIFS (Windows) ACL model.

This leads to problems both for Samba/CIFS and NFSv4, which need to map between NFSv4 ACLs and POSIX ACLs. A perfect mapping between the two models is not possible, and information will always be lost along the way. One of the results is that users are confronted with awkward behavior.

POSIX ACLs are not the only ACL model which can be implemented in a POSIX [2] compliant way: NFSv4 ACLs can also be extended to offer perfect POSIX semantics.

The implementation allows to choose which ACL model to use on a per-filesystem basis. This allows administrators to enable NFSv4 ACLs on a part or all of the filesystem hierarchy. As long as NFSv4 ACLs are not used, the filesystem will have the traditional POSIX file permission behavior.

Project Goal

My high-level goal for this project is to make Linux a much better file server in UNIX, Windows, and mixed environments. This will take away the excuses why Linux cannot be used as the server platform of choice even with lots of Windows clients. It will allow POSIX applications to be used for automating things in the traditional UNIX way, even for Windows clients, which is one of the areas where UNIX truly excels.

Benefits

* POSIX applications will experience perfect POSIX semantics on an NFSv4 enabled file system when interacting with other POSIX applications.

* NFSv4 applications (NFSv4, CIFS, Samba) will experience perfect NFSv4 ACL semantics when interacting with other NFSv4 applications.

* The losses in interactions between POSIX and NFSv4 applications are kept to a minimum, without exposing "weird" file permission bits or NFSv4 ACLs to applications.

* In a POSIX + CIFS / NFSv4 environment, a lot less complicated mapping between two different ACL models will be necessary, which will lead to fewer losses and less awkward behavior.

* With native NFSv4 ACLs, Linux will become much better suited as a file server in multi-protocol environments. POSIX and NFSv4 ACLs are fully integrated, so even alternating accesses to data from multiple platforms will become much less painful.

Drawbacks

* User-space that is aware of ACLs will be confronted with two different ACL models and may want to map between the two in some cases, so mapping between NFSv4 ACLs and POSIX ACLs will not go away completely. Note that we already have this problem with the NFSv4 client, which already exposes NFSv4 ACLs to user-space.

* The NFSv4 daemon will likely also continue to map NFSv4 ACLs to POSIX ACLs as best as it can for compatibility with POSIX ACL filesystems. Ideally, this mapping would go away at least from the kernel, but as long as compatibility with POSIX ACL filesystems is a goal, it can't.

Open Issues

* The kernel patches currently only support NFSv4 ACLs on Ext3.

* As of the time of this writing, Samba does not include native NFSv4 ACL support. From what I have heard, the Samba team is supporting the native NFSv4 ACL effort though, so this is expected to change soon.

* NFSv4 protocol support for native NFSv4 ACLs has not been implemented, yet. The POSIX ACL <=> NFSv4 ACL mapping code in version 4 of nfsd is based on different data structures for storing ACLs. Hooking NFSv4 ACLs up to the NFSv4 client and server shouldn't be much work, but fully integrating the two will be a little more difficult.

* While NFSv4 ACLs support permissions such as WRITE_ACL and WRITE_OWNER, the VFS does not ask filesystems whether a process is allowed such accesses. Instead, it asks filesystems in terms of MAY_READ, MAY_WRITE, MAY_APPEND, and MAY_EXEC. Therefore, filesystems cannot allow processes such permissions at the moment. This could be fixed, but even without extending the VFS, native NFSv4 ACLs already offer much better interoperability with NFSv4 and CIFS than POSIX ACLs do.

References

[1] IEEE 1003.1e Draft 17: Draft Standard for Information Technology - Portable Operating System Interface (POSIX) - System Application Program Interface, October 1997. http://wt.xpilot.org/publications/posix.1e/

[2] Institute of Electrical and Electronics Engineers, "Information Technology - Portable Operating System Interface (POSIX)", IEEE Standard 1003.1, December 2004. http://www.unix.org/version3/

Regards,
Andreas

--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX Products GmbH / Novell Inc.

#1 lore raw

PATCH 1/3 Pass MAY_APPEND through to permission inode operations that understand it

Introduce a mount flag with which filesystems can idicate that they support permissions beyond MAY_READ, MAY_WRITE, and MAY_EXEC. If that flag is set, pass MAY_APPEND through to the filesystems' permission inode operation.

fs/namei.c +3 -3
Index: linux-2.6.18-rc6/fs/namei.c
===================================================================
@@ -228,7 +228,7 @@ int generic_permission(struct inode *ino
 int permission(struct inode *inode, int mask, struct nameidata *nd)
 {
 	umode_t mode = inode->i_mode;
-	int retval, submask;
+	int retval, submask = mask;
 
 	if (mask & MAY_WRITE) {
 
@@ -254,8 +254,8 @@ int permission(struct inode *inode, int 
 	if ((mask & MAY_EXEC) && S_ISREG(mode) && !(mode & S_IXUGO))
 		return -EACCES;
 
-	/* Ordinary permission routines do not understand MAY_APPEND. */
-	submask = mask & ~MAY_APPEND;
+	if (!IS_XPERM(inode))
+		submask &= (MAY_READ | MAY_WRITE | MAY_EXEC);
 	if (inode->i_op && inode->i_op->permission)
 		retval = inode->i_op->permission(inode, submask, nd);
 	else
include/linux/fs.h +3 -0
Index: linux-2.6.18-rc6/include/linux/fs.h
===================================================================
@@ -119,6 +119,8 @@ extern int dir_notify_enable;
 #define MS_PRIVATE	(1<<18)	/* change to private */
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
+#define MS_XPERM	(1<<21) /* permission function understands more than
+				   MAY_{READ,WRITE,EXEC} */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
@@ -172,6 +174,7 @@ extern int dir_notify_enable;
 #define IS_APPEND(inode)	((inode)->i_flags & S_APPEND)
 #define IS_IMMUTABLE(inode)	((inode)->i_flags & S_IMMUTABLE)
 #define IS_POSIXACL(inode)	__IS_FLG(inode, MS_POSIXACL)
+#define IS_XPERM(inode)		__IS_FLG(inode, MS_XPERM)
 
 #define IS_DEADDIR(inode)	((inode)->i_flags & S_DEAD)
 #define IS_NOCMTIME(inode)	((inode)->i_flags & S_NOCMTIME)

--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX Products GmbH / Novell Inc.

#2 lore raw

PATCH 2/3 Add match_string() for mount option parsing

In reply to Andreas Gruenbacher

The match_string() function allows to parse string constants in mount options.

include/linux/parser.h +1 -0
Index: linux-2.6.18-rc6/include/linux/parser.h
===================================================================
@@ -26,6 +26,7 @@ typedef struct {
 } substring_t;
 
 int match_token(char *, match_table_t table, substring_t args[]);
+int match_string(substring_t *s, const char *str);
 int match_int(substring_t *, int *result);
 int match_octal(substring_t *, int *result);
 int match_hex(substring_t *, int *result);
lib/parser.c +14 -0
Index: linux-2.6.18-rc6/lib/parser.c
===================================================================
@@ -111,6 +111,19 @@ int match_token(char *s, match_table_t t
 }
 
 /**
+ * match_string: check for a particular parameter
+ * @s: substring to be scanned
+ * @str: string to scan for
+ *
+ * Description: Return if a &substring_t is equal to string @str.
+ */
+int match_string(substring_t *s, const char *str)
+{
+	return strlen(str) == s->to - s->from &&
+	       !memcmp(str, s->from, s->to - s->from);
+}
+
+/**
  * match_number: scan a number in the given base from a substring_t
  * @s: substring to be scanned
  * @result: resulting integer on success
@@ -213,6 +226,7 @@ char *match_strdup(substring_t *s)
 }
 
 EXPORT_SYMBOL(match_token);
+EXPORT_SYMBOL(match_string);
 EXPORT_SYMBOL(match_int);
 EXPORT_SYMBOL(match_octal);
 EXPORT_SYMBOL(match_hex);

--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX Products GmbH / Novell Inc.

#3 lore raw

PATCH 3/3 NFSv4 ACLs on ext3

In reply to Andreas Gruenbacher

This patch implements NFSv4 ACLs on the ext3 filesystem. When an ext3 filesystem is mounted with -o acl=nfs4 or -o acl=nfs4+max, the filesystem will support NFSv4 ACLs instead of POSIX ACLs.

---
 fs/Kconfig                    |   12 
 fs/Makefile                   |    4 
 fs/ext3/Makefile              |    3 
 fs/ext3/acl.c                 |    8 
 fs/ext3/acl.h                 |    4 
 fs/ext3/file.c                |    1 
 fs/ext3/ialloc.c              |    6 
 fs/ext3/inode.c               |    9 
 fs/ext3/namei.c               |   11 
 fs/ext3/namei.h               |    1 
 fs/ext3/nfs4acl.c             |  281 +++++++++++++++
 fs/ext3/nfs4acl.h             |   26 +
 fs/ext3/super.c               |   54 ++-
 fs/ext3/xattr.c               |    9 
 fs/ext3/xattr.h               |    5 
 fs/nfs4acl_base.c             |  532 ++++++++++++++++++++++++++++++
 fs/nfs4acl_compat.c           |  743 ++++++++++++++++++++++++++++++++++++++++++
 fs/nfs4acl_xattr.c            |  153 ++++++++
 include/linux/ext3_fs.h       |    2 
 include/linux/nfs4acl.h       |  181 ++++++++++
 include/linux/nfs4acl_xattr.h |   31 +
 21 files changed, 2051 insertions(+), 25 deletions(-)
include/linux/nfs4acl.h new file +181 -0
Index: linux-2.6.18-rc6/include/linux/nfs4acl.h
===================================================================
@@ -0,0 +1,181 @@
+#ifndef __NFS4ACL_H
+#define __NFS4ACL_H
+
+struct nfs4ace {
+	unsigned short	e_type;
+	unsigned short	e_flags;
+	unsigned int	e_mask;
+	union {
+		unsigned int	e_id;
+		const char	*e_who;
+	} u;
+};
+
+struct nfs4acl {
+	unsigned int	a_owner_mask;
+	unsigned int	a_group_mask;
+	unsigned int	a_other_mask;
+	unsigned int	a_count;
+	struct nfs4ace	a_entries[0];
+};
+
+#define nfs4acl_for_each_entry(_ace, _acl) \
+	for (_ace = _acl->a_entries; \
+	     _ace != _acl->a_entries + _acl->a_count; \
+	     _ace++)
+
+#define nfs4acl_for_each_entry_reverse(_ace, _acl) \
+	for (_ace = _acl->a_entries + _acl->a_count - 1; \
+	     _ace != _acl->a_entries - 1; \
+	     _ace--)
+
+/* e_type values */
+#define ACE4_ACCESS_ALLOWED_ACE_TYPE	0x0000
+#define ACE4_ACCESS_DENIED_ACE_TYPE	0x0001
+/*#define ACE4_SYSTEM_AUDIT_ACE_TYPE	0x0002*/
+/*#define ACE4_SYSTEM_ALARM_ACE_TYPE	0x0003*/
+
+/* e_flags bitflags */
+#define ACE4_FILE_INHERIT_ACE		0x0001
+#define ACE4_DIRECTORY_INHERIT_ACE	0x0002
+#define ACE4_NO_PROPAGATE_INHERIT_ACE	0x0004
+#define ACE4_INHERIT_ONLY_ACE		0x0008
+/*#define ACE4_SUCCESSFUL_ACCESS_ACE_FLAG	0x0010*/
+/*#define ACE4_FAILED_ACCESS_ACE_FLAG	0x0020*/
+#define ACE4_IDENTIFIER_GROUP		0x0040
+#define ACE4_SPECIAL_WHO		0x4000  /* in-kernel only */
+
+#define ACE4_VALID_FLAGS ( \
+	ACE4_FILE_INHERIT_ACE | \
+	ACE4_DIRECTORY_INHERIT_ACE | \
+	ACE4_NO_PROPAGATE_INHERIT_ACE | \
+	ACE4_INHERIT_ONLY_ACE | \
+	ACE4_IDENTIFIER_GROUP )
+
+/* e_mask bitflags */
+#define ACE4_READ_DATA			0x00000001
+#define ACE4_LIST_DIRECTORY		0x00000001
+#define ACE4_WRITE_DATA			0x00000002
+#define ACE4_ADD_FILE			0x00000002
+#define ACE4_APPEND_DATA		0x00000004
+#define ACE4_ADD_SUBDIRECTORY		0x00000004
+#define ACE4_READ_NAMED_ATTRS		0x00000008
+#define ACE4_WRITE_NAMED_ATTRS		0x00000010
+#define ACE4_EXECUTE			0x00000020
+#define ACE4_DELETE_CHILD		0x00000040
+#define ACE4_READ_ATTRIBUTES		0x00000080
+#define ACE4_WRITE_ATTRIBUTES		0x00000100
+#define ACE4_DELETE			0x00010000
+#define ACE4_READ_ACL			0x00020000
+#define ACE4_WRITE_ACL			0x00040000
+#define ACE4_WRITE_OWNER		0x00080000
+#define ACE4_SYNCHRONIZE		0x00100000
+
+#define ACE4_VALID_MASK ( \
+	ACE4_READ_DATA | \
+	ACE4_LIST_DIRECTORY | \
+	ACE4_WRITE_DATA | \
+	ACE4_ADD_FILE | \
+	ACE4_APPEND_DATA | \
+	ACE4_ADD_SUBDIRECTORY | \
+	ACE4_READ_NAMED_ATTRS | \
+	ACE4_WRITE_NAMED_ATTRS | \
+	ACE4_EXECUTE | \
+	ACE4_DELETE_CHILD | \
+	ACE4_READ_ATTRIBUTES | \
+	ACE4_WRITE_ATTRIBUTES | \
+	ACE4_DELETE | \
+	ACE4_READ_ACL | \
+	ACE4_WRITE_ACL | \
+	ACE4_WRITE_OWNER | \
+	ACE4_SYNCHRONIZE )
+
+/* Special e_who identifiers: we use these pointer values in comparisons
+   instead of strcmp for efficiency. */
+
+extern const char *nfs4ace_owner_who;
+extern const char *nfs4ace_group_who;
+extern const char *nfs4ace_everyone_who;
+
+static inline int
+nfs4ace_is_owner(struct nfs4ace *ace)
+{
+	return (ace->e_flags & ACE4_SPECIAL_WHO) &&
+	       ace->u.e_who == nfs4ace_owner_who;
+}
+
+static inline int
+nfs4ace_is_group(struct nfs4ace *ace)
+{
+	return (ace->e_flags & ACE4_SPECIAL_WHO) &&
+	       ace->u.e_who == nfs4ace_group_who;
+}
+
+static inline int
+nfs4ace_is_everyone(struct nfs4ace *ace)
+{
+	return (ace->e_flags & ACE4_SPECIAL_WHO) &&
+	       ace->u.e_who == nfs4ace_everyone_who;
+}
+
+static inline int
+nfs4ace_is_unix_id(struct nfs4ace *ace)
+{
+	return !(ace->e_flags & ACE4_SPECIAL_WHO);
+}
+
+static inline int
+nfs4ace_is_inherit_only(struct nfs4ace *ace)
+{
+	return ace->e_flags & ACE4_INHERIT_ONLY_ACE;
+}
+
+static inline int
+nfs4ace_is_inheritable(struct nfs4ace *ace)
+{
+	return ace->e_flags & (ACE4_FILE_INHERIT_ACE |
+			       ACE4_DIRECTORY_INHERIT_ACE);
+}
+
+static inline void
+nfs4ace_clear_inheritance_flags(struct nfs4ace *ace)
+{
+	ace->e_flags &= ~(ACE4_FILE_INHERIT_ACE |
+			  ACE4_DIRECTORY_INHERIT_ACE |
+			  ACE4_NO_PROPAGATE_INHERIT_ACE |
+			  ACE4_INHERIT_ONLY_ACE);
+}
+
+static inline int
+nfs4ace_is_allow(struct nfs4ace *ace)
+{
+	return ace->e_type == ACE4_ACCESS_ALLOWED_ACE_TYPE;
+}
+
+static inline int
+nfs4ace_is_deny(struct nfs4ace *ace)
+{
+	return ace->e_type == ACE4_ACCESS_DENIED_ACE_TYPE;
+}
+
+extern int nfs4ace_dup(struct nfs4ace *, struct nfs4ace *);
+extern void nfs4ace_free(struct nfs4ace *);
+
+extern struct nfs4acl *nfs4acl_alloc(int count);
+extern struct nfs4acl *nfs4acl_clone(struct nfs4acl *acl);
+extern void __nfs4acl_free(struct nfs4acl *);
+
+static inline void
+nfs4acl_free(struct nfs4acl *acl)
+{
+	kfree(acl);
+}
+
+extern int nfs4acl_permission(struct inode *, const struct nfs4acl *, int, int);
+extern int nfs4ace_is_same_who(struct nfs4ace *, struct nfs4ace *);
+extern struct nfs4acl *nfs4acl_inherit(struct nfs4acl *, mode_t, int);
+extern int nfs4acl_masks_to_mode(struct nfs4acl *);
+extern void nfs4acl_chmod(struct nfs4acl *, mode_t);
+extern int nfs4acl_apply_masks(struct nfs4acl **acl, int);
+
+#endif /* __NFS4ACL_H */
include/linux/nfs4acl_xattr.h new file +31 -0
Index: linux-2.6.18-rc6/include/linux/nfs4acl_xattr.h
===================================================================
@@ -0,0 +1,31 @@
+#ifndef __NFS4ACL_XATTR_H
+#define __NFS4ACL_XATTR_H
+
+#include <linux/nfs4acl.h>
+
+#define NFS4ACL_XATTR "system.nfs4acl"
+
+struct nfs4ace_xattr {
+	__be16		e_type;
+	__be16		e_flags;
+	__be32		e_mask;
+	__be32		e_id;
+	char		e_who[0];
+};
+
+struct nfs4acl_xattr {
+	unsigned char	a_version;
+	unsigned char	a_flags;
+	__be16		a_count;
+	__be32		a_owner_mask;
+	__be32		a_group_mask;
+	__be32		a_other_mask;
+};
+
+#define ACL4_XATTR_VERSION	0
+#define ACL4_XATTR_MAX_COUNT	1024
+
+extern struct nfs4acl *nfs4acl_from_xattr(const void *, size_t);
+extern void *nfs4acl_to_xattr(const struct nfs4acl *, size_t *);
+
+#endif /* __NFS4ACL_XATTR_H */
fs/nfs4acl_xattr.c new file +153 -0

153 lines not on this page · raw message

fs/Kconfig +12 -0
Index: linux-2.6.18-rc6/fs/Kconfig
===================================================================
@@ -126,6 +126,14 @@ config EXT3_FS_POSIX_ACL
 
 	  If you don't know what Access Control Lists are, say N
 
+config EXT3_FS_NFS4ACL
+	bool "Native NFSv4 ACLs (EXPERIMENTAL)"
+	depends on EXT3_FS_XATTR && EXPERIMENTAL
+	select FS_NFS4ACL
+	help
+	  Allow to use NFSv4 ACLs instead of POSIX ACLs. This may become
+	  useful for filesystems exported over NFSv4 or Samba.
+
 config EXT3_FS_SECURITY
 	bool "Ext3 Security Labels"
 	depends on EXT3_FS_XATTR
@@ -322,6 +330,10 @@ config FS_POSIX_ACL
 	bool
 	default n
 
+config FS_NFS4ACL
+	bool
+	default n
+
 source "fs/xfs/Kconfig"
 
 config OCFS2_FS
fs/Makefile +4 -0
Index: linux-2.6.18-rc6/fs/Makefile
===================================================================
@@ -36,6 +36,10 @@ obj-$(CONFIG_FS_MBCACHE)	+= mbcache.o
 obj-$(CONFIG_FS_POSIX_ACL)	+= posix_acl.o xattr_acl.o
 obj-$(CONFIG_NFS_COMMON)	+= nfs_common/
 
+obj-$(CONFIG_FS_NFS4ACL:y=m)	+= nfs4acl.o
+nfs4acl-y			:= nfs4acl_base.o nfs4acl_xattr.o \
+				   nfs4acl_compat.o
+
 obj-$(CONFIG_QUOTA)		+= dquot.o
 obj-$(CONFIG_QFMT_V1)		+= quota_v1.o
 obj-$(CONFIG_QFMT_V2)		+= quota_v2.o
fs/ext3/file.c +1 -0
Index: linux-2.6.18-rc6/fs/ext3/file.c
===================================================================
@@ -23,6 +23,7 @@
 #include <linux/jbd.h>
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
+#include "namei.h"
 #include "xattr.h"
 #include "acl.h"
 
fs/ext3/inode.c +7 -2
Index: linux-2.6.18-rc6/fs/ext3/inode.c
===================================================================
@@ -38,6 +38,7 @@
 #include <linux/uio.h>
 #include "xattr.h"
 #include "acl.h"
+#include "nfs4acl.h"
 
 static int ext3_writepage_trans_blocks(struct inode *inode);
 
@@ -2964,8 +2965,12 @@ int ext3_setattr(struct dentry *dentry, 
 	if (inode->i_nlink)
 		ext3_orphan_del(NULL, inode);
 
-	if (!rc && (ia_valid & ATTR_MODE))
-		rc = ext3_acl_chmod(inode);
+	if (!rc && (ia_valid & ATTR_MODE)) {
+		if (test_opt(inode->i_sb, NFS4ACL))
+			rc = ext3_nfs4acl_chmod(inode);
+		else
+			rc = ext3_acl_chmod(inode);
+	}
 
 err_out:
 	ext3_std_error(inode->i_sb, error);
fs/ext3/namei.c +11 -0
Index: linux-2.6.18-rc6/fs/ext3/namei.c
===================================================================
@@ -40,6 +40,7 @@
 #include "namei.h"
 #include "xattr.h"
 #include "acl.h"
+#include "nfs4acl.h"
 
 /*
  * define how far ahead to read directories while searching them.
@@ -2361,6 +2362,16 @@ end_rename:
 	return retval;
 }
 
+int ext3_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+#ifdef CONFIG_EXT3_FS_NFS4ACL
+	if (test_opt(inode->i_sb, NFS4ACL))
+		return ext3_nfs4acl_permission(inode, mask);
+	else
+#endif
+        return generic_permission(inode, mask, ext3_check_acl);
+}
+
 /*
  * directories can handle most operations...
  */
fs/ext3/super.c +41 -13

89 lines not on this page · raw message

fs/ext3/xattr.c +9 -0
Index: linux-2.6.18-rc6/fs/ext3/xattr.c
===================================================================
@@ -112,6 +112,9 @@ static struct xattr_handler *ext3_xattr_
 #ifdef CONFIG_EXT3_FS_SECURITY
 	[EXT3_XATTR_INDEX_SECURITY]	     = &ext3_xattr_security_handler,
 #endif
+#ifdef CONFIG_EXT3_FS_NFS4ACL
+	[EXT3_XATTR_INDEX_NFS4ACL]	     = &ext3_nfs4acl_xattr_handler,
+#endif
 };
 
 struct xattr_handler *ext3_xattr_handlers[] = {
@@ -124,6 +127,12 @@ struct xattr_handler *ext3_xattr_handler
 #ifdef CONFIG_EXT3_FS_SECURITY
 	&ext3_xattr_security_handler,
 #endif
+#ifdef CONFIG_EXT3_FS_NFS4ACL
+	&ext3_nfs4acl_xattr_handler,
+#ifdef NFS4ACL_DEBUG
+	&ext3_masked_nfs4acl_xattr_handler,
+#endif
+#endif
 	NULL
 };
 
include/linux/ext3_fs.h +2 -0
Index: linux-2.6.18-rc6/include/linux/ext3_fs.h
===================================================================
@@ -371,6 +371,8 @@ struct ext3_inode {
 #define EXT3_MOUNT_QUOTA		0x80000 /* Some quota option set */
 #define EXT3_MOUNT_USRQUOTA		0x100000 /* "old" user quota */
 #define EXT3_MOUNT_GRPQUOTA		0x200000 /* "old" group quota */
+#define EXT3_MOUNT_NFS4ACL		0x400000 /* NFS version 4 ACLs */
+#define EXT3_MOUNT_NFS4ACL_MAX		0x800000 /* "write-through" behavior */
 
 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
 #ifndef _LINUX_EXT2_FS_H
fs/ext3/xattr.h +5 -0
Index: linux-2.6.18-rc6/fs/ext3/xattr.h
===================================================================
@@ -21,6 +21,7 @@
 #define EXT3_XATTR_INDEX_TRUSTED		4
 #define	EXT3_XATTR_INDEX_LUSTRE			5
 #define EXT3_XATTR_INDEX_SECURITY	        6
+#define EXT3_XATTR_INDEX_NFS4ACL		7
 
 struct ext3_xattr_header {
 	__le32	h_magic;	/* magic number for identification */
@@ -63,6 +64,10 @@ extern struct xattr_handler ext3_xattr_t
 extern struct xattr_handler ext3_xattr_acl_access_handler;
 extern struct xattr_handler ext3_xattr_acl_default_handler;
 extern struct xattr_handler ext3_xattr_security_handler;
+extern struct xattr_handler ext3_nfs4acl_xattr_handler;
+#ifdef NFS4ACL_DEBUG
+extern struct xattr_handler ext3_masked_nfs4acl_xattr_handler;
+#endif
 
 extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
 
fs/ext3/Makefile +3 -0
Index: linux-2.6.18-rc6/fs/ext3/Makefile
===================================================================
@@ -2,6 +2,8 @@
 # Makefile for the linux ext3-filesystem routines.
 #
 
+EXTRA_CFLAGS := -DNFS4ACL_DEBUG
+
 obj-$(CONFIG_EXT3_FS) += ext3.o
 
 ext3-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
@@ -10,3 +12,4 @@ ext3-y	:= balloc.o bitmap.o dir.o file.o
 ext3-$(CONFIG_EXT3_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
 ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
 ext3-$(CONFIG_EXT3_FS_SECURITY)	 += xattr_security.o
+ext3-$(CONFIG_EXT3_FS_NFS4ACL)	 += nfs4acl.o
fs/ext3/ialloc.c +5 -1
Index: linux-2.6.18-rc6/fs/ext3/ialloc.c
===================================================================
@@ -28,6 +28,7 @@
 
 #include "xattr.h"
 #include "acl.h"
+#include "nfs4acl.h"
 
 /*
  * ialloc.c contains the inodes allocation and deallocation routines
@@ -603,7 +604,10 @@ got:
 		goto fail_drop;
 	}
 
-	err = ext3_init_acl(handle, inode, dir);
+	if (test_opt(sb, NFS4ACL))
+		err = ext3_nfs4acl_init(handle, inode, dir);
+	else
+		err = ext3_init_acl(handle, inode, dir);
 	if (err)
 		goto fail_free_drop;
 
fs/ext3/nfs4acl.c new file +281 -0

281 lines not on this page · raw message

fs/ext3/nfs4acl.h new file +26 -0
Index: linux-2.6.18-rc6/fs/ext3/nfs4acl.h
===================================================================
@@ -0,0 +1,26 @@
+#ifndef __FS_EXT3_NFS4ACL_H
+#define __FS_EXT3_NFS4ACL_H
+
+#ifdef CONFIG_EXT3_FS_NFS4ACL
+
+extern int ext3_nfs4acl_permission(struct inode *, int);
+extern int ext3_nfs4acl_init(handle_t *, struct inode *, struct inode *);
+extern int ext3_nfs4acl_chmod(struct inode *);
+
+#else  /* CONFIG_FS_EXT3_NFS4ACL */
+
+static inline int
+ext3_nfs4acl_init(handle_t *handle, struct inode *inode, struct inode *dir)
+{
+	return 0;
+}
+
+static inline int
+ext3_nfs4acl_chmod(struct inode *inode)
+{
+	return 0;
+}
+
+#endif  /* CONFIG_FS_EXT3_NFS4ACL */
+
+#endif  /* __FS_EXT3_NFS4ACL_H */
fs/ext3/acl.c +1 -7
Index: linux-2.6.18-rc6/fs/ext3/acl.c
===================================================================
@@ -282,7 +282,7 @@ ext3_set_acl(handle_t *handle, struct in
 	return error;
 }
 
-static int
+int
 ext3_check_acl(struct inode *inode, int mask)
 {
 	struct posix_acl *acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
@@ -298,12 +298,6 @@ ext3_check_acl(struct inode *inode, int 
 	return -EAGAIN;
 }
 
-int
-ext3_permission(struct inode *inode, int mask, struct nameidata *nd)
-{
-	return generic_permission(inode, mask, ext3_check_acl);
-}
-
 /*
  * Initialize the ACLs of a new inode. Called from ext3_new_inode.
  *
fs/ext3/acl.h +2 -2
Index: linux-2.6.18-rc6/fs/ext3/acl.h
===================================================================
@@ -58,13 +58,13 @@ static inline int ext3_acl_count(size_t 
 #define EXT3_ACL_NOT_CACHED ((void *)-1)
 
 /* acl.c */
-extern int ext3_permission (struct inode *, int, struct nameidata *);
+extern int ext3_check_acl(struct inode *, int);
 extern int ext3_acl_chmod (struct inode *);
 extern int ext3_init_acl (handle_t *, struct inode *, struct inode *);
 
 #else  /* CONFIG_EXT3_FS_POSIX_ACL */
 #include <linux/sched.h>
-#define ext3_permission NULL
+#define ext3_check_acl NULL
 
 static inline int
 ext3_acl_chmod(struct inode *inode)
fs/ext3/namei.h +1 -0
Index: linux-2.6.18-rc6/fs/ext3/namei.h
===================================================================
@@ -5,4 +5,5 @@
  *
 */
 
+extern int ext3_permission (struct inode *, int, struct nameidata *);
 extern struct dentry *ext3_get_parent(struct dentry *child);
fs/nfs4acl_base.c new file +532 -0

532 lines not on this page · raw message

fs/nfs4acl_compat.c new file +743 -0

743 lines not on this page · raw message

--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX Products GmbH / Novell Inc.