diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_acl.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_acl.c | 80 |
1 files changed, 19 insertions, 61 deletions
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c index cac48fe22ad..44ce5165680 100644 --- a/fs/xfs/linux-2.6/xfs_acl.c +++ b/fs/xfs/linux-2.6/xfs_acl.c | |||
@@ -114,6 +114,8 @@ xfs_get_acl(struct inode *inode, int type) | |||
114 | if (acl != ACL_NOT_CACHED) | 114 | if (acl != ACL_NOT_CACHED) |
115 | return acl; | 115 | return acl; |
116 | 116 | ||
117 | trace_xfs_get_acl(ip); | ||
118 | |||
117 | switch (type) { | 119 | switch (type) { |
118 | case ACL_TYPE_ACCESS: | 120 | case ACL_TYPE_ACCESS: |
119 | ea_name = SGI_ACL_FILE; | 121 | ea_name = SGI_ACL_FILE; |
@@ -218,40 +220,6 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
218 | return error; | 220 | return error; |
219 | } | 221 | } |
220 | 222 | ||
221 | int | ||
222 | xfs_check_acl(struct inode *inode, int mask) | ||
223 | { | ||
224 | struct xfs_inode *ip; | ||
225 | struct posix_acl *acl; | ||
226 | int error = -EAGAIN; | ||
227 | |||
228 | ip = XFS_I(inode); | ||
229 | trace_xfs_check_acl(ip); | ||
230 | |||
231 | /* | ||
232 | * If there is no attribute fork no ACL exists on this inode and | ||
233 | * we can skip the whole exercise. | ||
234 | */ | ||
235 | if (!XFS_IFORK_Q(ip)) | ||
236 | return -EAGAIN; | ||
237 | |||
238 | if (mask & MAY_NOT_BLOCK) { | ||
239 | if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) | ||
240 | return -ECHILD; | ||
241 | return -EAGAIN; | ||
242 | } | ||
243 | |||
244 | acl = xfs_get_acl(inode, ACL_TYPE_ACCESS); | ||
245 | if (IS_ERR(acl)) | ||
246 | return PTR_ERR(acl); | ||
247 | if (acl) { | ||
248 | error = posix_acl_permission(inode, acl, mask); | ||
249 | posix_acl_release(acl); | ||
250 | } | ||
251 | |||
252 | return error; | ||
253 | } | ||
254 | |||
255 | static int | 223 | static int |
256 | xfs_set_mode(struct inode *inode, mode_t mode) | 224 | xfs_set_mode(struct inode *inode, mode_t mode) |
257 | { | 225 | { |
@@ -297,29 +265,23 @@ posix_acl_default_exists(struct inode *inode) | |||
297 | * No need for i_mutex because the inode is not yet exposed to the VFS. | 265 | * No need for i_mutex because the inode is not yet exposed to the VFS. |
298 | */ | 266 | */ |
299 | int | 267 | int |
300 | xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl) | 268 | xfs_inherit_acl(struct inode *inode, struct posix_acl *acl) |
301 | { | 269 | { |
302 | struct posix_acl *clone; | 270 | mode_t mode = inode->i_mode; |
303 | mode_t mode; | ||
304 | int error = 0, inherit = 0; | 271 | int error = 0, inherit = 0; |
305 | 272 | ||
306 | if (S_ISDIR(inode->i_mode)) { | 273 | if (S_ISDIR(inode->i_mode)) { |
307 | error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl); | 274 | error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, acl); |
308 | if (error) | 275 | if (error) |
309 | return error; | 276 | goto out; |
310 | } | 277 | } |
311 | 278 | ||
312 | clone = posix_acl_clone(default_acl, GFP_KERNEL); | 279 | error = posix_acl_create(&acl, GFP_KERNEL, &mode); |
313 | if (!clone) | ||
314 | return -ENOMEM; | ||
315 | |||
316 | mode = inode->i_mode; | ||
317 | error = posix_acl_create_masq(clone, &mode); | ||
318 | if (error < 0) | 280 | if (error < 0) |
319 | goto out_release_clone; | 281 | return error; |
320 | 282 | ||
321 | /* | 283 | /* |
322 | * If posix_acl_create_masq returns a positive value we need to | 284 | * If posix_acl_create returns a positive value we need to |
323 | * inherit a permission that can't be represented using the Unix | 285 | * inherit a permission that can't be represented using the Unix |
324 | * mode bits and we actually need to set an ACL. | 286 | * mode bits and we actually need to set an ACL. |
325 | */ | 287 | */ |
@@ -328,20 +290,20 @@ xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl) | |||
328 | 290 | ||
329 | error = xfs_set_mode(inode, mode); | 291 | error = xfs_set_mode(inode, mode); |
330 | if (error) | 292 | if (error) |
331 | goto out_release_clone; | 293 | goto out; |
332 | 294 | ||
333 | if (inherit) | 295 | if (inherit) |
334 | error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone); | 296 | error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl); |
335 | 297 | ||
336 | out_release_clone: | 298 | out: |
337 | posix_acl_release(clone); | 299 | posix_acl_release(acl); |
338 | return error; | 300 | return error; |
339 | } | 301 | } |
340 | 302 | ||
341 | int | 303 | int |
342 | xfs_acl_chmod(struct inode *inode) | 304 | xfs_acl_chmod(struct inode *inode) |
343 | { | 305 | { |
344 | struct posix_acl *acl, *clone; | 306 | struct posix_acl *acl; |
345 | int error; | 307 | int error; |
346 | 308 | ||
347 | if (S_ISLNK(inode->i_mode)) | 309 | if (S_ISLNK(inode->i_mode)) |
@@ -351,16 +313,12 @@ xfs_acl_chmod(struct inode *inode) | |||
351 | if (IS_ERR(acl) || !acl) | 313 | if (IS_ERR(acl) || !acl) |
352 | return PTR_ERR(acl); | 314 | return PTR_ERR(acl); |
353 | 315 | ||
354 | clone = posix_acl_clone(acl, GFP_KERNEL); | 316 | error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); |
355 | posix_acl_release(acl); | 317 | if (error) |
356 | if (!clone) | 318 | return error; |
357 | return -ENOMEM; | ||
358 | |||
359 | error = posix_acl_chmod_masq(clone, inode->i_mode); | ||
360 | if (!error) | ||
361 | error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone); | ||
362 | 319 | ||
363 | posix_acl_release(clone); | 320 | error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl); |
321 | posix_acl_release(acl); | ||
364 | return error; | 322 | return error; |
365 | } | 323 | } |
366 | 324 | ||