diff options
| author | Christoph Hellwig <hch@lst.de> | 2009-11-03 10:44:44 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-16 12:16:49 -0500 |
| commit | 1c7c474c31aea6d5cb2fb35f31d9e9e91ae466b1 (patch) | |
| tree | 89a5fd1146be1744ce3ac94789542841512315b8 | |
| parent | 431547b3c4533b8c7fd150ab36980b9a3147797b (diff) | |
make generic_acl slightly more generic
Now that we cache the ACL pointers in the generic inode all the generic_acl
cruft can go away and generic_acl.c can directly implement xattr handlers
dealing with the full Posix ACL semantics for in-memory filesystems.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | fs/generic_acl.c | 158 | ||||
| -rw-r--r-- | include/linux/generic_acl.h | 41 | ||||
| -rw-r--r-- | include/linux/shmem_fs.h | 16 | ||||
| -rw-r--r-- | mm/Makefile | 1 | ||||
| -rw-r--r-- | mm/shmem.c | 17 | ||||
| -rw-r--r-- | mm/shmem_acl.c | 133 |
6 files changed, 109 insertions, 257 deletions
diff --git a/fs/generic_acl.c b/fs/generic_acl.c index e0b53aa7bbec..55458031e501 100644 --- a/fs/generic_acl.c +++ b/fs/generic_acl.c | |||
| @@ -1,62 +1,58 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * fs/generic_acl.c | ||
| 3 | * | ||
| 4 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> | 2 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> |
| 5 | * | 3 | * |
| 6 | * This file is released under the GPL. | 4 | * This file is released under the GPL. |
| 5 | * | ||
| 6 | * Generic ACL support for in-memory filesystems. | ||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
| 10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
| 11 | #include <linux/generic_acl.h> | 11 | #include <linux/generic_acl.h> |
| 12 | #include <linux/posix_acl.h> | ||
| 13 | #include <linux/posix_acl_xattr.h> | ||
| 12 | 14 | ||
| 13 | /** | 15 | |
| 14 | * generic_acl_list - Generic xattr_handler->list() operation | 16 | static size_t |
| 15 | * @ops: Filesystem specific getacl and setacl callbacks | 17 | generic_acl_list(struct dentry *dentry, char *list, size_t list_size, |
| 16 | */ | 18 | const char *name, size_t name_len, int type) |
| 17 | size_t | ||
| 18 | generic_acl_list(struct inode *inode, struct generic_acl_operations *ops, | ||
| 19 | int type, char *list, size_t list_size) | ||
| 20 | { | 19 | { |
| 21 | struct posix_acl *acl; | 20 | struct posix_acl *acl; |
| 22 | const char *name; | 21 | const char *xname; |
| 23 | size_t size; | 22 | size_t size; |
| 24 | 23 | ||
| 25 | acl = ops->getacl(inode, type); | 24 | acl = get_cached_acl(dentry->d_inode, type); |
| 26 | if (!acl) | 25 | if (!acl) |
| 27 | return 0; | 26 | return 0; |
| 28 | posix_acl_release(acl); | 27 | posix_acl_release(acl); |
| 29 | 28 | ||
| 30 | switch(type) { | 29 | switch (type) { |
| 31 | case ACL_TYPE_ACCESS: | 30 | case ACL_TYPE_ACCESS: |
| 32 | name = POSIX_ACL_XATTR_ACCESS; | 31 | xname = POSIX_ACL_XATTR_ACCESS; |
| 33 | break; | 32 | break; |
| 34 | 33 | case ACL_TYPE_DEFAULT: | |
| 35 | case ACL_TYPE_DEFAULT: | 34 | xname = POSIX_ACL_XATTR_DEFAULT; |
| 36 | name = POSIX_ACL_XATTR_DEFAULT; | 35 | break; |
| 37 | break; | 36 | default: |
| 38 | 37 | return 0; | |
| 39 | default: | ||
| 40 | return 0; | ||
| 41 | } | 38 | } |
| 42 | size = strlen(name) + 1; | 39 | size = strlen(xname) + 1; |
| 43 | if (list && size <= list_size) | 40 | if (list && size <= list_size) |
| 44 | memcpy(list, name, size); | 41 | memcpy(list, xname, size); |
| 45 | return size; | 42 | return size; |
| 46 | } | 43 | } |
| 47 | 44 | ||
| 48 | /** | 45 | static int |
| 49 | * generic_acl_get - Generic xattr_handler->get() operation | 46 | generic_acl_get(struct dentry *dentry, const char *name, void *buffer, |
| 50 | * @ops: Filesystem specific getacl and setacl callbacks | 47 | size_t size, int type) |
| 51 | */ | ||
| 52 | int | ||
| 53 | generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, | ||
| 54 | int type, void *buffer, size_t size) | ||
| 55 | { | 48 | { |
| 56 | struct posix_acl *acl; | 49 | struct posix_acl *acl; |
| 57 | int error; | 50 | int error; |
| 58 | 51 | ||
| 59 | acl = ops->getacl(inode, type); | 52 | if (strcmp(name, "") != 0) |
| 53 | return -EINVAL; | ||
| 54 | |||
| 55 | acl = get_cached_acl(dentry->d_inode, type); | ||
| 60 | if (!acl) | 56 | if (!acl) |
| 61 | return -ENODATA; | 57 | return -ENODATA; |
| 62 | error = posix_acl_to_xattr(acl, buffer, size); | 58 | error = posix_acl_to_xattr(acl, buffer, size); |
| @@ -65,17 +61,16 @@ generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, | |||
| 65 | return error; | 61 | return error; |
| 66 | } | 62 | } |
| 67 | 63 | ||
| 68 | /** | 64 | static int |
| 69 | * generic_acl_set - Generic xattr_handler->set() operation | 65 | generic_acl_set(struct dentry *dentry, const char *name, const void *value, |
| 70 | * @ops: Filesystem specific getacl and setacl callbacks | 66 | size_t size, int flags, int type) |
| 71 | */ | ||
| 72 | int | ||
| 73 | generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, | ||
| 74 | int type, const void *value, size_t size) | ||
| 75 | { | 67 | { |
| 68 | struct inode *inode = dentry->d_inode; | ||
| 76 | struct posix_acl *acl = NULL; | 69 | struct posix_acl *acl = NULL; |
| 77 | int error; | 70 | int error; |
| 78 | 71 | ||
| 72 | if (strcmp(name, "") != 0) | ||
| 73 | return -EINVAL; | ||
| 79 | if (S_ISLNK(inode->i_mode)) | 74 | if (S_ISLNK(inode->i_mode)) |
| 80 | return -EOPNOTSUPP; | 75 | return -EOPNOTSUPP; |
| 81 | if (!is_owner_or_cap(inode)) | 76 | if (!is_owner_or_cap(inode)) |
| @@ -91,28 +86,27 @@ generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, | |||
| 91 | error = posix_acl_valid(acl); | 86 | error = posix_acl_valid(acl); |
| 92 | if (error) | 87 | if (error) |
| 93 | goto failed; | 88 | goto failed; |
| 94 | switch(type) { | 89 | switch (type) { |
| 95 | case ACL_TYPE_ACCESS: | 90 | case ACL_TYPE_ACCESS: |
| 96 | mode = inode->i_mode; | 91 | mode = inode->i_mode; |
| 97 | error = posix_acl_equiv_mode(acl, &mode); | 92 | error = posix_acl_equiv_mode(acl, &mode); |
| 98 | if (error < 0) | 93 | if (error < 0) |
| 99 | goto failed; | 94 | goto failed; |
| 100 | inode->i_mode = mode; | 95 | inode->i_mode = mode; |
| 101 | if (error == 0) { | 96 | if (error == 0) { |
| 102 | posix_acl_release(acl); | 97 | posix_acl_release(acl); |
| 103 | acl = NULL; | 98 | acl = NULL; |
| 104 | } | 99 | } |
| 105 | break; | 100 | break; |
| 106 | 101 | case ACL_TYPE_DEFAULT: | |
| 107 | case ACL_TYPE_DEFAULT: | 102 | if (!S_ISDIR(inode->i_mode)) { |
| 108 | if (!S_ISDIR(inode->i_mode)) { | 103 | error = -EINVAL; |
| 109 | error = -EINVAL; | 104 | goto failed; |
| 110 | goto failed; | 105 | } |
| 111 | } | 106 | break; |
| 112 | break; | ||
| 113 | } | 107 | } |
| 114 | } | 108 | } |
| 115 | ops->setacl(inode, type, acl); | 109 | set_cached_acl(inode, type, acl); |
| 116 | error = 0; | 110 | error = 0; |
| 117 | failed: | 111 | failed: |
| 118 | posix_acl_release(acl); | 112 | posix_acl_release(acl); |
| @@ -121,14 +115,12 @@ failed: | |||
| 121 | 115 | ||
| 122 | /** | 116 | /** |
| 123 | * generic_acl_init - Take care of acl inheritance at @inode create time | 117 | * generic_acl_init - Take care of acl inheritance at @inode create time |
| 124 | * @ops: Filesystem specific getacl and setacl callbacks | ||
| 125 | * | 118 | * |
| 126 | * Files created inside a directory with a default ACL inherit the | 119 | * Files created inside a directory with a default ACL inherit the |
| 127 | * directory's default ACL. | 120 | * directory's default ACL. |
| 128 | */ | 121 | */ |
| 129 | int | 122 | int |
| 130 | generic_acl_init(struct inode *inode, struct inode *dir, | 123 | generic_acl_init(struct inode *inode, struct inode *dir) |
| 131 | struct generic_acl_operations *ops) | ||
| 132 | { | 124 | { |
| 133 | struct posix_acl *acl = NULL; | 125 | struct posix_acl *acl = NULL; |
| 134 | mode_t mode = inode->i_mode; | 126 | mode_t mode = inode->i_mode; |
| @@ -136,7 +128,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
| 136 | 128 | ||
| 137 | inode->i_mode = mode & ~current_umask(); | 129 | inode->i_mode = mode & ~current_umask(); |
| 138 | if (!S_ISLNK(inode->i_mode)) | 130 | if (!S_ISLNK(inode->i_mode)) |
| 139 | acl = ops->getacl(dir, ACL_TYPE_DEFAULT); | 131 | acl = get_cached_acl(dir, ACL_TYPE_DEFAULT); |
| 140 | if (acl) { | 132 | if (acl) { |
| 141 | struct posix_acl *clone; | 133 | struct posix_acl *clone; |
| 142 | 134 | ||
| @@ -145,7 +137,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
| 145 | error = -ENOMEM; | 137 | error = -ENOMEM; |
| 146 | if (!clone) | 138 | if (!clone) |
| 147 | goto cleanup; | 139 | goto cleanup; |
| 148 | ops->setacl(inode, ACL_TYPE_DEFAULT, clone); | 140 | set_cached_acl(inode, ACL_TYPE_DEFAULT, clone); |
| 149 | posix_acl_release(clone); | 141 | posix_acl_release(clone); |
| 150 | } | 142 | } |
| 151 | clone = posix_acl_clone(acl, GFP_KERNEL); | 143 | clone = posix_acl_clone(acl, GFP_KERNEL); |
| @@ -156,7 +148,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
| 156 | if (error >= 0) { | 148 | if (error >= 0) { |
| 157 | inode->i_mode = mode; | 149 | inode->i_mode = mode; |
| 158 | if (error > 0) | 150 | if (error > 0) |
| 159 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | 151 | set_cached_acl(inode, ACL_TYPE_ACCESS, clone); |
| 160 | } | 152 | } |
| 161 | posix_acl_release(clone); | 153 | posix_acl_release(clone); |
| 162 | } | 154 | } |
| @@ -169,20 +161,19 @@ cleanup: | |||
| 169 | 161 | ||
| 170 | /** | 162 | /** |
| 171 | * generic_acl_chmod - change the access acl of @inode upon chmod() | 163 | * generic_acl_chmod - change the access acl of @inode upon chmod() |
| 172 | * @ops: FIlesystem specific getacl and setacl callbacks | ||
| 173 | * | 164 | * |
| 174 | * A chmod also changes the permissions of the owner, group/mask, and | 165 | * A chmod also changes the permissions of the owner, group/mask, and |
| 175 | * other ACL entries. | 166 | * other ACL entries. |
| 176 | */ | 167 | */ |
| 177 | int | 168 | int |
| 178 | generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) | 169 | generic_acl_chmod(struct inode *inode) |
| 179 | { | 170 | { |
| 180 | struct posix_acl *acl, *clone; | 171 | struct posix_acl *acl, *clone; |
| 181 | int error = 0; | 172 | int error = 0; |
| 182 | 173 | ||
| 183 | if (S_ISLNK(inode->i_mode)) | 174 | if (S_ISLNK(inode->i_mode)) |
| 184 | return -EOPNOTSUPP; | 175 | return -EOPNOTSUPP; |
| 185 | acl = ops->getacl(inode, ACL_TYPE_ACCESS); | 176 | acl = get_cached_acl(inode, ACL_TYPE_ACCESS); |
| 186 | if (acl) { | 177 | if (acl) { |
| 187 | clone = posix_acl_clone(acl, GFP_KERNEL); | 178 | clone = posix_acl_clone(acl, GFP_KERNEL); |
| 188 | posix_acl_release(acl); | 179 | posix_acl_release(acl); |
| @@ -190,8 +181,37 @@ generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) | |||
| 190 | return -ENOMEM; | 181 | return -ENOMEM; |
| 191 | error = posix_acl_chmod_masq(clone, inode->i_mode); | 182 | error = posix_acl_chmod_masq(clone, inode->i_mode); |
| 192 | if (!error) | 183 | if (!error) |
| 193 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | 184 | set_cached_acl(inode, ACL_TYPE_ACCESS, clone); |
| 194 | posix_acl_release(clone); | 185 | posix_acl_release(clone); |
| 195 | } | 186 | } |
| 196 | return error; | 187 | return error; |
| 197 | } | 188 | } |
| 189 | |||
| 190 | int | ||
| 191 | generic_check_acl(struct inode *inode, int mask) | ||
| 192 | { | ||
| 193 | struct posix_acl *acl = get_cached_acl(inode, ACL_TYPE_ACCESS); | ||
| 194 | |||
| 195 | if (acl) { | ||
| 196 | int error = posix_acl_permission(inode, acl, mask); | ||
| 197 | posix_acl_release(acl); | ||
| 198 | return error; | ||
| 199 | } | ||
| 200 | return -EAGAIN; | ||
| 201 | } | ||
| 202 | |||
| 203 | struct xattr_handler generic_acl_access_handler = { | ||
| 204 | .prefix = POSIX_ACL_XATTR_ACCESS, | ||
| 205 | .flags = ACL_TYPE_ACCESS, | ||
| 206 | .list = generic_acl_list, | ||
| 207 | .get = generic_acl_get, | ||
| 208 | .set = generic_acl_set, | ||
| 209 | }; | ||
| 210 | |||
| 211 | struct xattr_handler generic_acl_default_handler = { | ||
| 212 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
| 213 | .flags = ACL_TYPE_DEFAULT, | ||
| 214 | .list = generic_acl_list, | ||
| 215 | .get = generic_acl_get, | ||
| 216 | .set = generic_acl_set, | ||
| 217 | }; | ||
diff --git a/include/linux/generic_acl.h b/include/linux/generic_acl.h index 886f5faa08cb..ca666d18ed67 100644 --- a/include/linux/generic_acl.h +++ b/include/linux/generic_acl.h | |||
| @@ -1,36 +1,15 @@ | |||
| 1 | /* | 1 | #ifndef LINUX_GENERIC_ACL_H |
| 2 | * include/linux/generic_acl.h | 2 | #define LINUX_GENERIC_ACL_H |
| 3 | * | ||
| 4 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> | ||
| 5 | * | ||
| 6 | * This file is released under the GPL. | ||
| 7 | */ | ||
| 8 | 3 | ||
| 9 | #ifndef GENERIC_ACL_H | 4 | #include <linux/xattr.h> |
| 10 | #define GENERIC_ACL_H | ||
| 11 | 5 | ||
| 12 | #include <linux/posix_acl.h> | 6 | struct inode; |
| 13 | #include <linux/posix_acl_xattr.h> | ||
| 14 | 7 | ||
| 15 | /** | 8 | extern struct xattr_handler generic_acl_access_handler; |
| 16 | * struct generic_acl_operations - filesystem operations | 9 | extern struct xattr_handler generic_acl_default_handler; |
| 17 | * | ||
| 18 | * Filesystems must make these operations available to the generic | ||
| 19 | * operations. | ||
| 20 | */ | ||
| 21 | struct generic_acl_operations { | ||
| 22 | struct posix_acl *(*getacl)(struct inode *, int); | ||
| 23 | void (*setacl)(struct inode *, int, struct posix_acl *); | ||
| 24 | }; | ||
| 25 | 10 | ||
| 26 | size_t generic_acl_list(struct inode *, struct generic_acl_operations *, int, | 11 | int generic_acl_init(struct inode *, struct inode *); |
| 27 | char *, size_t); | 12 | int generic_acl_chmod(struct inode *); |
| 28 | int generic_acl_get(struct inode *, struct generic_acl_operations *, int, | 13 | int generic_check_acl(struct inode *inode, int mask); |
| 29 | void *, size_t); | ||
| 30 | int generic_acl_set(struct inode *, struct generic_acl_operations *, int, | ||
| 31 | const void *, size_t); | ||
| 32 | int generic_acl_init(struct inode *, struct inode *, | ||
| 33 | struct generic_acl_operations *); | ||
| 34 | int generic_acl_chmod(struct inode *, struct generic_acl_operations *); | ||
| 35 | 14 | ||
| 36 | #endif | 15 | #endif /* LINUX_GENERIC_ACL_H */ |
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index deee7afd8d66..e164291fb3e7 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h | |||
| @@ -41,20 +41,4 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) | |||
| 41 | extern int init_tmpfs(void); | 41 | extern int init_tmpfs(void); |
| 42 | extern int shmem_fill_super(struct super_block *sb, void *data, int silent); | 42 | extern int shmem_fill_super(struct super_block *sb, void *data, int silent); |
| 43 | 43 | ||
| 44 | #ifdef CONFIG_TMPFS_POSIX_ACL | ||
| 45 | int shmem_check_acl(struct inode *, int); | ||
| 46 | int shmem_acl_init(struct inode *, struct inode *); | ||
| 47 | |||
| 48 | extern struct xattr_handler shmem_xattr_acl_access_handler; | ||
| 49 | extern struct xattr_handler shmem_xattr_acl_default_handler; | ||
| 50 | |||
| 51 | extern struct generic_acl_operations shmem_acl_ops; | ||
| 52 | |||
| 53 | #else | ||
| 54 | static inline int shmem_acl_init(struct inode *inode, struct inode *dir) | ||
| 55 | { | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | #endif /* CONFIG_TMPFS_POSIX_ACL */ | ||
| 59 | |||
| 60 | #endif | 44 | #endif |
diff --git a/mm/Makefile b/mm/Makefile index 82131d0f8d85..7a68d2ab5560 100644 --- a/mm/Makefile +++ b/mm/Makefile | |||
| @@ -22,7 +22,6 @@ obj-$(CONFIG_HUGETLBFS) += hugetlb.o | |||
| 22 | obj-$(CONFIG_NUMA) += mempolicy.o | 22 | obj-$(CONFIG_NUMA) += mempolicy.o |
| 23 | obj-$(CONFIG_SPARSEMEM) += sparse.o | 23 | obj-$(CONFIG_SPARSEMEM) += sparse.o |
| 24 | obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o | 24 | obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o |
| 25 | obj-$(CONFIG_TMPFS_POSIX_ACL) += shmem_acl.o | ||
| 26 | obj-$(CONFIG_SLOB) += slob.o | 25 | obj-$(CONFIG_SLOB) += slob.o |
| 27 | obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o | 26 | obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o |
| 28 | obj-$(CONFIG_KSM) += ksm.o | 27 | obj-$(CONFIG_KSM) += ksm.o |
diff --git a/mm/shmem.c b/mm/shmem.c index 3cd32c2ea0a0..f8485062f3ba 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
| @@ -41,6 +41,7 @@ static struct vfsmount *shm_mnt; | |||
| 41 | 41 | ||
| 42 | #include <linux/xattr.h> | 42 | #include <linux/xattr.h> |
| 43 | #include <linux/exportfs.h> | 43 | #include <linux/exportfs.h> |
| 44 | #include <linux/posix_acl.h> | ||
| 44 | #include <linux/generic_acl.h> | 45 | #include <linux/generic_acl.h> |
| 45 | #include <linux/mman.h> | 46 | #include <linux/mman.h> |
| 46 | #include <linux/string.h> | 47 | #include <linux/string.h> |
| @@ -809,7 +810,7 @@ static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) | |||
| 809 | error = inode_setattr(inode, attr); | 810 | error = inode_setattr(inode, attr); |
| 810 | #ifdef CONFIG_TMPFS_POSIX_ACL | 811 | #ifdef CONFIG_TMPFS_POSIX_ACL |
| 811 | if (!error && (attr->ia_valid & ATTR_MODE)) | 812 | if (!error && (attr->ia_valid & ATTR_MODE)) |
| 812 | error = generic_acl_chmod(inode, &shmem_acl_ops); | 813 | error = generic_acl_chmod(inode); |
| 813 | #endif | 814 | #endif |
| 814 | if (page) | 815 | if (page) |
| 815 | page_cache_release(page); | 816 | page_cache_release(page); |
| @@ -1823,11 +1824,13 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
| 1823 | return error; | 1824 | return error; |
| 1824 | } | 1825 | } |
| 1825 | } | 1826 | } |
| 1826 | error = shmem_acl_init(inode, dir); | 1827 | #ifdef CONFIG_TMPFS_POSIX_ACL |
| 1828 | error = generic_acl_init(inode, dir); | ||
| 1827 | if (error) { | 1829 | if (error) { |
| 1828 | iput(inode); | 1830 | iput(inode); |
| 1829 | return error; | 1831 | return error; |
| 1830 | } | 1832 | } |
| 1833 | #endif | ||
| 1831 | if (dir->i_mode & S_ISGID) { | 1834 | if (dir->i_mode & S_ISGID) { |
| 1832 | inode->i_gid = dir->i_gid; | 1835 | inode->i_gid = dir->i_gid; |
| 1833 | if (S_ISDIR(mode)) | 1836 | if (S_ISDIR(mode)) |
| @@ -2074,8 +2077,8 @@ static struct xattr_handler shmem_xattr_security_handler = { | |||
| 2074 | }; | 2077 | }; |
| 2075 | 2078 | ||
| 2076 | static struct xattr_handler *shmem_xattr_handlers[] = { | 2079 | static struct xattr_handler *shmem_xattr_handlers[] = { |
| 2077 | &shmem_xattr_acl_access_handler, | 2080 | &generic_acl_access_handler, |
| 2078 | &shmem_xattr_acl_default_handler, | 2081 | &generic_acl_default_handler, |
| 2079 | &shmem_xattr_security_handler, | 2082 | &shmem_xattr_security_handler, |
| 2080 | NULL | 2083 | NULL |
| 2081 | }; | 2084 | }; |
| @@ -2454,7 +2457,7 @@ static const struct inode_operations shmem_inode_operations = { | |||
| 2454 | .getxattr = generic_getxattr, | 2457 | .getxattr = generic_getxattr, |
| 2455 | .listxattr = generic_listxattr, | 2458 | .listxattr = generic_listxattr, |
| 2456 | .removexattr = generic_removexattr, | 2459 | .removexattr = generic_removexattr, |
| 2457 | .check_acl = shmem_check_acl, | 2460 | .check_acl = generic_check_acl, |
| 2458 | #endif | 2461 | #endif |
| 2459 | 2462 | ||
| 2460 | }; | 2463 | }; |
| @@ -2477,7 +2480,7 @@ static const struct inode_operations shmem_dir_inode_operations = { | |||
| 2477 | .getxattr = generic_getxattr, | 2480 | .getxattr = generic_getxattr, |
| 2478 | .listxattr = generic_listxattr, | 2481 | .listxattr = generic_listxattr, |
| 2479 | .removexattr = generic_removexattr, | 2482 | .removexattr = generic_removexattr, |
| 2480 | .check_acl = shmem_check_acl, | 2483 | .check_acl = generic_check_acl, |
| 2481 | #endif | 2484 | #endif |
| 2482 | }; | 2485 | }; |
| 2483 | 2486 | ||
| @@ -2488,7 +2491,7 @@ static const struct inode_operations shmem_special_inode_operations = { | |||
| 2488 | .getxattr = generic_getxattr, | 2491 | .getxattr = generic_getxattr, |
| 2489 | .listxattr = generic_listxattr, | 2492 | .listxattr = generic_listxattr, |
| 2490 | .removexattr = generic_removexattr, | 2493 | .removexattr = generic_removexattr, |
| 2491 | .check_acl = shmem_check_acl, | 2494 | .check_acl = generic_check_acl, |
| 2492 | #endif | 2495 | #endif |
| 2493 | }; | 2496 | }; |
| 2494 | 2497 | ||
diff --git a/mm/shmem_acl.c b/mm/shmem_acl.c deleted file mode 100644 index f8d5330ec0d7..000000000000 --- a/mm/shmem_acl.c +++ /dev/null | |||
| @@ -1,133 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * mm/shmem_acl.c | ||
| 3 | * | ||
| 4 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> | ||
| 5 | * | ||
| 6 | * This file is released under the GPL. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include <linux/fs.h> | ||
| 10 | #include <linux/shmem_fs.h> | ||
| 11 | #include <linux/xattr.h> | ||
| 12 | #include <linux/generic_acl.h> | ||
| 13 | |||
| 14 | /** | ||
| 15 | * shmem_get_acl - generic_acl_operations->getacl() operation | ||
| 16 | */ | ||
| 17 | static struct posix_acl * | ||
| 18 | shmem_get_acl(struct inode *inode, int type) | ||
| 19 | { | ||
| 20 | struct posix_acl *acl = NULL; | ||
| 21 | |||
| 22 | spin_lock(&inode->i_lock); | ||
| 23 | switch(type) { | ||
| 24 | case ACL_TYPE_ACCESS: | ||
| 25 | acl = posix_acl_dup(inode->i_acl); | ||
| 26 | break; | ||
| 27 | |||
| 28 | case ACL_TYPE_DEFAULT: | ||
| 29 | acl = posix_acl_dup(inode->i_default_acl); | ||
| 30 | break; | ||
| 31 | } | ||
| 32 | spin_unlock(&inode->i_lock); | ||
| 33 | |||
| 34 | return acl; | ||
| 35 | } | ||
| 36 | |||
| 37 | /** | ||
| 38 | * shmem_set_acl - generic_acl_operations->setacl() operation | ||
| 39 | */ | ||
| 40 | static void | ||
| 41 | shmem_set_acl(struct inode *inode, int type, struct posix_acl *acl) | ||
| 42 | { | ||
| 43 | struct posix_acl *free = NULL; | ||
| 44 | |||
| 45 | spin_lock(&inode->i_lock); | ||
| 46 | switch(type) { | ||
| 47 | case ACL_TYPE_ACCESS: | ||
| 48 | free = inode->i_acl; | ||
| 49 | inode->i_acl = posix_acl_dup(acl); | ||
| 50 | break; | ||
| 51 | |||
| 52 | case ACL_TYPE_DEFAULT: | ||
| 53 | free = inode->i_default_acl; | ||
| 54 | inode->i_default_acl = posix_acl_dup(acl); | ||
| 55 | break; | ||
| 56 | } | ||
| 57 | spin_unlock(&inode->i_lock); | ||
| 58 | posix_acl_release(free); | ||
| 59 | } | ||
| 60 | |||
| 61 | struct generic_acl_operations shmem_acl_ops = { | ||
| 62 | .getacl = shmem_get_acl, | ||
| 63 | .setacl = shmem_set_acl, | ||
| 64 | }; | ||
| 65 | |||
| 66 | static size_t | ||
| 67 | shmem_xattr_list_acl(struct dentry *dentry, char *list, size_t list_size, | ||
| 68 | const char *name, size_t name_len, int type) | ||
| 69 | { | ||
| 70 | return generic_acl_list(dentry->d_inode, &shmem_acl_ops, | ||
| 71 | type, list, list_size); | ||
| 72 | } | ||
| 73 | |||
| 74 | static int | ||
| 75 | shmem_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, | ||
| 76 | size_t size, int type) | ||
| 77 | { | ||
| 78 | if (strcmp(name, "") != 0) | ||
| 79 | return -EINVAL; | ||
| 80 | return generic_acl_get(dentry->d_inode, &shmem_acl_ops, type, | ||
| 81 | buffer, size); | ||
| 82 | } | ||
| 83 | |||
| 84 | static int | ||
| 85 | shmem_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, | ||
| 86 | size_t size, int flags, int type) | ||
| 87 | { | ||
| 88 | if (strcmp(name, "") != 0) | ||
| 89 | return -EINVAL; | ||
| 90 | return generic_acl_set(dentry->d_inode, &shmem_acl_ops, type, | ||
| 91 | value, size); | ||
| 92 | } | ||
| 93 | |||
| 94 | struct xattr_handler shmem_xattr_acl_access_handler = { | ||
| 95 | .prefix = POSIX_ACL_XATTR_ACCESS, | ||
| 96 | .flags = ACL_TYPE_ACCESS, | ||
| 97 | .list = shmem_xattr_list_acl, | ||
| 98 | .get = shmem_xattr_get_acl, | ||
| 99 | .set = shmem_xattr_set_acl, | ||
| 100 | }; | ||
| 101 | |||
| 102 | struct xattr_handler shmem_xattr_acl_default_handler = { | ||
| 103 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
| 104 | .flags = ACL_TYPE_DEFAULT, | ||
| 105 | .list = shmem_xattr_list_acl, | ||
| 106 | .get = shmem_xattr_get_acl, | ||
| 107 | .set = shmem_xattr_set_acl, | ||
| 108 | }; | ||
| 109 | |||
| 110 | /** | ||
| 111 | * shmem_acl_init - Inizialize the acl(s) of a new inode | ||
| 112 | */ | ||
| 113 | int | ||
| 114 | shmem_acl_init(struct inode *inode, struct inode *dir) | ||
| 115 | { | ||
| 116 | return generic_acl_init(inode, dir, &shmem_acl_ops); | ||
| 117 | } | ||
| 118 | |||
| 119 | /** | ||
| 120 | * shmem_check_acl - check_acl() callback for generic_permission() | ||
| 121 | */ | ||
| 122 | int | ||
| 123 | shmem_check_acl(struct inode *inode, int mask) | ||
| 124 | { | ||
| 125 | struct posix_acl *acl = shmem_get_acl(inode, ACL_TYPE_ACCESS); | ||
| 126 | |||
| 127 | if (acl) { | ||
| 128 | int error = posix_acl_permission(inode, acl, mask); | ||
| 129 | posix_acl_release(acl); | ||
| 130 | return error; | ||
| 131 | } | ||
| 132 | return -EAGAIN; | ||
| 133 | } | ||
