aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-11-13 04:52:56 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-16 12:16:49 -0500
commit431547b3c4533b8c7fd150ab36980b9a3147797b (patch)
tree807ff2790f3c13c7c91ed2afd6d833032899482d /mm
parentef26ca97e83052790940cbc444b01b0d17a813c1 (diff)
sanitize xattr handler prototypes
Add a flags argument to struct xattr_handler and pass it to all xattr handler methods. This allows using the same methods for multiple handlers, e.g. for the ACL methods which perform exactly the same action for the access and default ACLs, just using a different underlying attribute. With a little more groundwork it'll also allow sharing the methods for the regular user/trusted/secure handlers in extN, ocfs2 and jffs2 like it's already done for xfs in this patch. Also change the inode argument to the handlers to a dentry to allow using the handlers mechnism for filesystems that require it later, e.g. cifs. [with GFS2 bits updated by Steven Whitehouse <swhiteho@redhat.com>] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: James Morris <jmorris@namei.org> Acked-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm')
-rw-r--r--mm/shmem.c19
-rw-r--r--mm/shmem_acl.c78
2 files changed, 30 insertions, 67 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index adf8033afd52..3cd32c2ea0a0 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2042,27 +2042,28 @@ static const struct inode_operations shmem_symlink_inode_operations = {
2042 * filesystem level, though. 2042 * filesystem level, though.
2043 */ 2043 */
2044 2044
2045static size_t shmem_xattr_security_list(struct inode *inode, char *list, 2045static size_t shmem_xattr_security_list(struct dentry *dentry, char *list,
2046 size_t list_len, const char *name, 2046 size_t list_len, const char *name,
2047 size_t name_len) 2047 size_t name_len, int handler_flags)
2048{ 2048{
2049 return security_inode_listsecurity(inode, list, list_len); 2049 return security_inode_listsecurity(dentry->d_inode, list, list_len);
2050} 2050}
2051 2051
2052static int shmem_xattr_security_get(struct inode *inode, const char *name, 2052static int shmem_xattr_security_get(struct dentry *dentry, const char *name,
2053 void *buffer, size_t size) 2053 void *buffer, size_t size, int handler_flags)
2054{ 2054{
2055 if (strcmp(name, "") == 0) 2055 if (strcmp(name, "") == 0)
2056 return -EINVAL; 2056 return -EINVAL;
2057 return xattr_getsecurity(inode, name, buffer, size); 2057 return xattr_getsecurity(dentry->d_inode, name, buffer, size);
2058} 2058}
2059 2059
2060static int shmem_xattr_security_set(struct inode *inode, const char *name, 2060static int shmem_xattr_security_set(struct dentry *dentry, const char *name,
2061 const void *value, size_t size, int flags) 2061 const void *value, size_t size, int flags, int handler_flags)
2062{ 2062{
2063 if (strcmp(name, "") == 0) 2063 if (strcmp(name, "") == 0)
2064 return -EINVAL; 2064 return -EINVAL;
2065 return security_inode_setsecurity(inode, name, value, size, flags); 2065 return security_inode_setsecurity(dentry->d_inode, name, value,
2066 size, flags);
2066} 2067}
2067 2068
2068static struct xattr_handler shmem_xattr_security_handler = { 2069static struct xattr_handler shmem_xattr_security_handler = {
diff --git a/mm/shmem_acl.c b/mm/shmem_acl.c
index df2c87fdae50..f8d5330ec0d7 100644
--- a/mm/shmem_acl.c
+++ b/mm/shmem_acl.c
@@ -63,86 +63,48 @@ struct generic_acl_operations shmem_acl_ops = {
63 .setacl = shmem_set_acl, 63 .setacl = shmem_set_acl,
64}; 64};
65 65
66/**
67 * shmem_list_acl_access, shmem_get_acl_access, shmem_set_acl_access,
68 * shmem_xattr_acl_access_handler - plumbing code to implement the
69 * system.posix_acl_access xattr using the generic acl functions.
70 */
71
72static size_t 66static size_t
73shmem_list_acl_access(struct inode *inode, char *list, size_t list_size, 67shmem_xattr_list_acl(struct dentry *dentry, char *list, size_t list_size,
74 const char *name, size_t name_len) 68 const char *name, size_t name_len, int type)
75{ 69{
76 return generic_acl_list(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, 70 return generic_acl_list(dentry->d_inode, &shmem_acl_ops,
77 list, list_size); 71 type, list, list_size);
78} 72}
79 73
80static int 74static int
81shmem_get_acl_access(struct inode *inode, const char *name, void *buffer, 75shmem_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
82 size_t size) 76 size_t size, int type)
83{ 77{
84 if (strcmp(name, "") != 0) 78 if (strcmp(name, "") != 0)
85 return -EINVAL; 79 return -EINVAL;
86 return generic_acl_get(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, buffer, 80 return generic_acl_get(dentry->d_inode, &shmem_acl_ops, type,
87 size); 81 buffer, size);
88} 82}
89 83
90static int 84static int
91shmem_set_acl_access(struct inode *inode, const char *name, const void *value, 85shmem_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
92 size_t size, int flags) 86 size_t size, int flags, int type)
93{ 87{
94 if (strcmp(name, "") != 0) 88 if (strcmp(name, "") != 0)
95 return -EINVAL; 89 return -EINVAL;
96 return generic_acl_set(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, value, 90 return generic_acl_set(dentry->d_inode, &shmem_acl_ops, type,
97 size); 91 value, size);
98} 92}
99 93
100struct xattr_handler shmem_xattr_acl_access_handler = { 94struct xattr_handler shmem_xattr_acl_access_handler = {
101 .prefix = POSIX_ACL_XATTR_ACCESS, 95 .prefix = POSIX_ACL_XATTR_ACCESS,
102 .list = shmem_list_acl_access, 96 .flags = ACL_TYPE_ACCESS,
103 .get = shmem_get_acl_access, 97 .list = shmem_xattr_list_acl,
104 .set = shmem_set_acl_access, 98 .get = shmem_xattr_get_acl,
99 .set = shmem_xattr_set_acl,
105}; 100};
106 101
107/**
108 * shmem_list_acl_default, shmem_get_acl_default, shmem_set_acl_default,
109 * shmem_xattr_acl_default_handler - plumbing code to implement the
110 * system.posix_acl_default xattr using the generic acl functions.
111 */
112
113static size_t
114shmem_list_acl_default(struct inode *inode, char *list, size_t list_size,
115 const char *name, size_t name_len)
116{
117 return generic_acl_list(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT,
118 list, list_size);
119}
120
121static int
122shmem_get_acl_default(struct inode *inode, const char *name, void *buffer,
123 size_t size)
124{
125 if (strcmp(name, "") != 0)
126 return -EINVAL;
127 return generic_acl_get(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT, buffer,
128 size);
129}
130
131static int
132shmem_set_acl_default(struct inode *inode, const char *name, const void *value,
133 size_t size, int flags)
134{
135 if (strcmp(name, "") != 0)
136 return -EINVAL;
137 return generic_acl_set(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT, value,
138 size);
139}
140
141struct xattr_handler shmem_xattr_acl_default_handler = { 102struct xattr_handler shmem_xattr_acl_default_handler = {
142 .prefix = POSIX_ACL_XATTR_DEFAULT, 103 .prefix = POSIX_ACL_XATTR_DEFAULT,
143 .list = shmem_list_acl_default, 104 .flags = ACL_TYPE_DEFAULT,
144 .get = shmem_get_acl_default, 105 .list = shmem_xattr_list_acl,
145 .set = shmem_set_acl_default, 106 .get = shmem_xattr_get_acl,
107 .set = shmem_xattr_set_acl,
146}; 108};
147 109
148/** 110/**