diff options
Diffstat (limited to 'fs/btrfs/acl.c')
-rw-r--r-- | fs/btrfs/acl.c | 81 |
1 files changed, 32 insertions, 49 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 361604244271..6df6d6ed74fd 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -73,13 +73,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | |||
73 | return acl; | 73 | return acl; |
74 | } | 74 | } |
75 | 75 | ||
76 | static int btrfs_xattr_get_acl(struct inode *inode, int type, | 76 | static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name, |
77 | void *value, size_t size) | 77 | void *value, size_t size, int type) |
78 | { | 78 | { |
79 | struct posix_acl *acl; | 79 | struct posix_acl *acl; |
80 | int ret = 0; | 80 | int ret = 0; |
81 | 81 | ||
82 | acl = btrfs_get_acl(inode, type); | 82 | acl = btrfs_get_acl(dentry->d_inode, type); |
83 | 83 | ||
84 | if (IS_ERR(acl)) | 84 | if (IS_ERR(acl)) |
85 | return PTR_ERR(acl); | 85 | return PTR_ERR(acl); |
@@ -94,7 +94,8 @@ static int btrfs_xattr_get_acl(struct inode *inode, int type, | |||
94 | /* | 94 | /* |
95 | * Needs to be called with fs_mutex held | 95 | * Needs to be called with fs_mutex held |
96 | */ | 96 | */ |
97 | static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | 97 | static int btrfs_set_acl(struct btrfs_trans_handle *trans, |
98 | struct inode *inode, struct posix_acl *acl, int type) | ||
98 | { | 99 | { |
99 | int ret, size = 0; | 100 | int ret, size = 0; |
100 | const char *name; | 101 | const char *name; |
@@ -111,12 +112,14 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
111 | switch (type) { | 112 | switch (type) { |
112 | case ACL_TYPE_ACCESS: | 113 | case ACL_TYPE_ACCESS: |
113 | mode = inode->i_mode; | 114 | mode = inode->i_mode; |
114 | ret = posix_acl_equiv_mode(acl, &mode); | ||
115 | if (ret < 0) | ||
116 | return ret; | ||
117 | ret = 0; | ||
118 | inode->i_mode = mode; | ||
119 | name = POSIX_ACL_XATTR_ACCESS; | 115 | name = POSIX_ACL_XATTR_ACCESS; |
116 | if (acl) { | ||
117 | ret = posix_acl_equiv_mode(acl, &mode); | ||
118 | if (ret < 0) | ||
119 | return ret; | ||
120 | inode->i_mode = mode; | ||
121 | } | ||
122 | ret = 0; | ||
120 | break; | 123 | break; |
121 | case ACL_TYPE_DEFAULT: | 124 | case ACL_TYPE_DEFAULT: |
122 | if (!S_ISDIR(inode->i_mode)) | 125 | if (!S_ISDIR(inode->i_mode)) |
@@ -140,8 +143,7 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
140 | goto out; | 143 | goto out; |
141 | } | 144 | } |
142 | 145 | ||
143 | ret = __btrfs_setxattr(inode, name, value, size, 0); | 146 | ret = __btrfs_setxattr(trans, inode, name, value, size, 0); |
144 | |||
145 | out: | 147 | out: |
146 | kfree(value); | 148 | kfree(value); |
147 | 149 | ||
@@ -151,10 +153,10 @@ out: | |||
151 | return ret; | 153 | return ret; |
152 | } | 154 | } |
153 | 155 | ||
154 | static int btrfs_xattr_set_acl(struct inode *inode, int type, | 156 | static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, |
155 | const void *value, size_t size) | 157 | const void *value, size_t size, int flags, int type) |
156 | { | 158 | { |
157 | int ret = 0; | 159 | int ret; |
158 | struct posix_acl *acl = NULL; | 160 | struct posix_acl *acl = NULL; |
159 | 161 | ||
160 | if (value) { | 162 | if (value) { |
@@ -167,38 +169,13 @@ static int btrfs_xattr_set_acl(struct inode *inode, int type, | |||
167 | } | 169 | } |
168 | } | 170 | } |
169 | 171 | ||
170 | ret = btrfs_set_acl(inode, acl, type); | 172 | ret = btrfs_set_acl(NULL, dentry->d_inode, acl, type); |
171 | 173 | ||
172 | posix_acl_release(acl); | 174 | posix_acl_release(acl); |
173 | 175 | ||
174 | return ret; | 176 | return ret; |
175 | } | 177 | } |
176 | 178 | ||
177 | |||
178 | static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name, | ||
179 | void *value, size_t size) | ||
180 | { | ||
181 | return btrfs_xattr_get_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
182 | } | ||
183 | |||
184 | static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name, | ||
185 | const void *value, size_t size, int flags) | ||
186 | { | ||
187 | return btrfs_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
188 | } | ||
189 | |||
190 | static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name, | ||
191 | void *value, size_t size) | ||
192 | { | ||
193 | return btrfs_xattr_get_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
194 | } | ||
195 | |||
196 | static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name, | ||
197 | const void *value, size_t size, int flags) | ||
198 | { | ||
199 | return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
200 | } | ||
201 | |||
202 | int btrfs_check_acl(struct inode *inode, int mask) | 179 | int btrfs_check_acl(struct inode *inode, int mask) |
203 | { | 180 | { |
204 | struct posix_acl *acl; | 181 | struct posix_acl *acl; |
@@ -221,7 +198,8 @@ int btrfs_check_acl(struct inode *inode, int mask) | |||
221 | * stuff has been fixed to work with that. If the locking stuff changes, we | 198 | * stuff has been fixed to work with that. If the locking stuff changes, we |
222 | * need to re-evaluate the acl locking stuff. | 199 | * need to re-evaluate the acl locking stuff. |
223 | */ | 200 | */ |
224 | int btrfs_init_acl(struct inode *inode, struct inode *dir) | 201 | int btrfs_init_acl(struct btrfs_trans_handle *trans, |
202 | struct inode *inode, struct inode *dir) | ||
225 | { | 203 | { |
226 | struct posix_acl *acl = NULL; | 204 | struct posix_acl *acl = NULL; |
227 | int ret = 0; | 205 | int ret = 0; |
@@ -246,7 +224,8 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir) | |||
246 | mode_t mode; | 224 | mode_t mode; |
247 | 225 | ||
248 | if (S_ISDIR(inode->i_mode)) { | 226 | if (S_ISDIR(inode->i_mode)) { |
249 | ret = btrfs_set_acl(inode, acl, ACL_TYPE_DEFAULT); | 227 | ret = btrfs_set_acl(trans, inode, acl, |
228 | ACL_TYPE_DEFAULT); | ||
250 | if (ret) | 229 | if (ret) |
251 | goto failed; | 230 | goto failed; |
252 | } | 231 | } |
@@ -261,10 +240,11 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir) | |||
261 | inode->i_mode = mode; | 240 | inode->i_mode = mode; |
262 | if (ret > 0) { | 241 | if (ret > 0) { |
263 | /* we need an acl */ | 242 | /* we need an acl */ |
264 | ret = btrfs_set_acl(inode, clone, | 243 | ret = btrfs_set_acl(trans, inode, clone, |
265 | ACL_TYPE_ACCESS); | 244 | ACL_TYPE_ACCESS); |
266 | } | 245 | } |
267 | } | 246 | } |
247 | posix_acl_release(clone); | ||
268 | } | 248 | } |
269 | failed: | 249 | failed: |
270 | posix_acl_release(acl); | 250 | posix_acl_release(acl); |
@@ -294,7 +274,7 @@ int btrfs_acl_chmod(struct inode *inode) | |||
294 | 274 | ||
295 | ret = posix_acl_chmod_masq(clone, inode->i_mode); | 275 | ret = posix_acl_chmod_masq(clone, inode->i_mode); |
296 | if (!ret) | 276 | if (!ret) |
297 | ret = btrfs_set_acl(inode, clone, ACL_TYPE_ACCESS); | 277 | ret = btrfs_set_acl(NULL, inode, clone, ACL_TYPE_ACCESS); |
298 | 278 | ||
299 | posix_acl_release(clone); | 279 | posix_acl_release(clone); |
300 | 280 | ||
@@ -303,14 +283,16 @@ int btrfs_acl_chmod(struct inode *inode) | |||
303 | 283 | ||
304 | struct xattr_handler btrfs_xattr_acl_default_handler = { | 284 | struct xattr_handler btrfs_xattr_acl_default_handler = { |
305 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 285 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
306 | .get = btrfs_xattr_acl_default_get, | 286 | .flags = ACL_TYPE_DEFAULT, |
307 | .set = btrfs_xattr_acl_default_set, | 287 | .get = btrfs_xattr_acl_get, |
288 | .set = btrfs_xattr_acl_set, | ||
308 | }; | 289 | }; |
309 | 290 | ||
310 | struct xattr_handler btrfs_xattr_acl_access_handler = { | 291 | struct xattr_handler btrfs_xattr_acl_access_handler = { |
311 | .prefix = POSIX_ACL_XATTR_ACCESS, | 292 | .prefix = POSIX_ACL_XATTR_ACCESS, |
312 | .get = btrfs_xattr_acl_access_get, | 293 | .flags = ACL_TYPE_ACCESS, |
313 | .set = btrfs_xattr_acl_access_set, | 294 | .get = btrfs_xattr_acl_get, |
295 | .set = btrfs_xattr_acl_set, | ||
314 | }; | 296 | }; |
315 | 297 | ||
316 | #else /* CONFIG_BTRFS_FS_POSIX_ACL */ | 298 | #else /* CONFIG_BTRFS_FS_POSIX_ACL */ |
@@ -320,7 +302,8 @@ int btrfs_acl_chmod(struct inode *inode) | |||
320 | return 0; | 302 | return 0; |
321 | } | 303 | } |
322 | 304 | ||
323 | int btrfs_init_acl(struct inode *inode, struct inode *dir) | 305 | int btrfs_init_acl(struct btrfs_trans_handle *trans, |
306 | struct inode *inode, struct inode *dir) | ||
324 | { | 307 | { |
325 | return 0; | 308 | return 0; |
326 | } | 309 | } |