Skip to contentSkip to conversation

ACL support for ext2/3

RFC PATCH In review [email protected] 3 participants 3 messages Oct 10, 2002 VFS

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/5 ACL support for ext2/3

This patch (as well as the following one) implements core ACL support which is needed for XFS as well as ext2/3 ACL support. Parts of this were patch was posted by Nathan Scott 2 or 3 days ago. (Although apparently XFS doesn't need the library functions provided by fs/posix_acl.c.)

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
#

# fs/Config.help            |   13 +
# fs/Config.in              |    2 
# fs/Makefile               |    3 
# fs/posix_acl.c            |  465 ++++++++++++++++++++++++++++++++++++++++++++++
# include/linux/fs.h        |    5 
# include/linux/posix_acl.h |   87 ++++++++

# 6 files changed, 574 insertions(+), 1 deletion(-) #
# --------------------------------------------
# 02/10/05 [email protected] 1.669
# Ported 0.8.50 acl patch to 2.5.
# -------------------------------------------- #

fs/Config.help +13 -0
diff -Nru a/fs/Config.help b/fs/Config.help
@@ -1,3 +1,16 @@
+CONFIG_FS_POSIX_ACL
+  Posix Access Control Lists (ACLs) support permissions for users and
+  groups beyond the owner/group/world scheme.
+
+  To learn more about Access Control Lists, visit the Posix ACLs for
+  Linux website <http://acl.bestbits.at/>.
+
+  If you plan to use Access Control Lists, you may also need the
+  getfacl and setfacl utilities, along with some additional patches
+  from the website.
+
+  If you don't know what Access Control Lists are, say N.
+
 CONFIG_QUOTA
   If you say Y here, you will be able to set per user limits for disk
   usage (also called disk quotas). Currently, it works for the
fs/Config.in +2 -0
diff -Nru a/fs/Config.in b/fs/Config.in
@@ -4,6 +4,8 @@
 mainmenu_option next_comment
 comment 'File systems'
 
+bool 'POSIX Access Control Lists' CONFIG_FS_POSIX_ACL
+
 bool 'Quota support' CONFIG_QUOTA
 dep_tristate '  Old quota format support' CONFIG_QFMT_V1 $CONFIG_QUOTA
 dep_tristate '  Quota format v2 support' CONFIG_QFMT_V2 $CONFIG_QUOTA
fs/Makefile +2 -1
diff -Nru a/fs/Makefile b/fs/Makefile
@@ -6,7 +6,7 @@
 # 
 
 export-objs :=	open.o dcache.o buffer.o bio.o inode.o dquot.o mpage.o aio.o \
-                fcntl.o mbcache.o
+                fcntl.o mbcache.o posix_acl.o
 
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \
 		bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \
@@ -31,6 +31,7 @@
 obj-$(CONFIG_BINFMT_ELF)	+= binfmt_elf.o
 
 obj-$(CONFIG_FS_MBCACHE)	+= mbcache.o
+obj-$(CONFIG_FS_POSIX_ACL)	+= posix_acl.o
 
 obj-$(CONFIG_QUOTA)		+= dquot.o
 obj-$(CONFIG_QFMT_V1)		+= quota_v1.o
fs/posix_acl.c new file +465 -0

465 lines not on this page · raw message

include/linux/fs.h +5 -0
diff -Nru a/include/linux/fs.h b/include/linux/fs.h
@@ -770,6 +770,9 @@
 	unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 };
 
+/* posix_acl.h */
+struct posix_acl;
+
 struct inode_operations {
 	int (*create) (struct inode *,struct dentry *,int);
 	struct dentry * (*lookup) (struct inode *,struct dentry *);
@@ -791,6 +794,8 @@
 	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 	ssize_t (*listxattr) (struct dentry *, char *, size_t);
 	int (*removexattr) (struct dentry *, const char *);
+	struct posix_acl *(*get_posix_acl) (struct inode *, int);
+	int (*set_posix_acl) (struct inode *, int, struct posix_acl *);
 };
 
 struct seq_file;
include/linux/posix_acl.h new file +87 -0

87 lines not on this page · raw message

#1 lore raw
Quoted 1 line

+#include <linux/version.h>

shouldn't be needed

fs/posix_acl.c line 23

Quoted 8 lines
fs/posix_acl.c new file +8 -0
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <asm/atomic.h>
+#include <linux/fs.h>
+#include <linux/posix_acl.h>
+#include <linux/module.h>
+
+#include <linux/smp_lock.h>

not needed

fs/posix_acl.c line 28

Quoted 3 lines
fs/posix_acl.c new file +3 -0
+MODULE_AUTHOR("Andreas Gruenbacher <[email protected]>");
+MODULE_DESCRIPTION("Generic Posix Access Control List (ACL) Manipulation");
+MODULE_LICENSE("GPL");

looks pretty pointless as this can't be a module.. :)

Quoted 44 lines
fs/posix_acl.c new file +30 -0
+struct posix_acl *
+get_posix_acl(struct inode *inode, int type)
+{
+	struct posix_acl *acl;
+
+	if (!inode->i_op->get_posix_acl)
+		return ERR_PTR(-EOPNOTSUPP);
+	down(&inode->i_sem);
+	acl = inode->i_op->get_posix_acl(inode, type);
+	up(&inode->i_sem);
+
+	return acl;
+}
+
+/*
+ * Set the POSIX ACL of an inode.
+ */
+int
+set_posix_acl(struct inode *inode, int type, struct posix_acl *acl)
+{
+	int error;
+
+	if (!inode->i_op->set_posix_acl)
+		return -EOPNOTSUPP;
+	down(&inode->i_sem);
+	error = inode->i_op->set_posix_acl(inode, type, acl);
+	up(&inode->i_sem);
+
+	return error;
+}

diff -Nru a/include/linux/fs.h b/include/linux/fs.h

include/linux/fs.h +3 -0
@@ -770,6 +770,9 @@
 	unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 };
 
+/* posix_acl.h */
+struct posix_acl;
+
 struct inode_operations {
 	int (*create) (struct inode *,struct dentry *,int);
 	struct dentry * (*lookup) (struct inode *,struct dentry *);

include/linux/fs.h line 798

Quoted 5 lines
include/linux/fs.h +2 -0
@@ -791,6 +794,8 @@
 	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 	ssize_t (*listxattr) (struct dentry *, char *, size_t);
 	int (*removexattr) (struct dentry *, const char *);
+	struct posix_acl *(*get_posix_acl) (struct inode *, int);
+	int (*set_posix_acl) (struct inode *, int, struct posix_acl *);

Either you make all setting/retrieving of ACLs go through this interface or just rip it. We don't need more than one way to fiddle with ACLs.

Also they should take dentries..

#2 lore raw
Quoted 8 lines · Christoph Hellwig

[...]

Quoted 7 lines

diff -Nru a/include/linux/fs.h b/include/linux/fs.h

include/linux/fs.h +0 -0
@@ -770,6 +770,9 @@
 	unsigned long (*get_unmapped_area)(struct file *, unsigned long,
 unsigned long, unsigned long, unsigned long); };
 
Quoted 15 lines

include/linux/fs.h line 798

Quoted 12 lines
include/linux/fs.h +5 -0
+/* posix_acl.h */
+struct posix_acl;
+
 struct inode_operations {
 	int (*create) (struct inode *,struct dentry *,int);
 	struct dentry * (*lookup) (struct inode *,struct dentry *);
@@ -791,6 +794,8 @@
 	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 	ssize_t (*listxattr) (struct dentry *, char *, size_t);
 	int (*removexattr) (struct dentry *, const char *);
+	struct posix_acl *(*get_posix_acl) (struct inode *, int);
+	int (*set_posix_acl) (struct inode *, int, struct posix_acl *);

Either you make all setting/retrieving of ACLs go through this interface or just rip it. We don't need more than one way to fiddle with ACLs.

This is an open design problem. Going through the xattr interface is too slow for the nfs_permission_mode hack (which if enabled masks off permissions before sending them to old clients to be on the safe side). On the other hand, always going through the inode operations is also quirky as we would need to dispatch xattr names and decode values both in the VFS and in the FS. A clean solution to this would be very welcome.

Quoted 1 line

Also they should take dentries.

They will once permission() also takes dentries. Before that they can't.

--Andreas.