aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/reiserfs/acl.h4
-rw-r--r--fs/reiserfs/file.c1
-rw-r--r--fs/reiserfs/namei.c4
-rw-r--r--fs/reiserfs/xattr.c5
-rw-r--r--fs/reiserfs/xattr_acl.c182
5 files changed, 35 insertions, 161 deletions
diff --git a/fs/reiserfs/acl.h b/fs/reiserfs/acl.h
index f096b80e73d8..4a211f5b34b8 100644
--- a/fs/reiserfs/acl.h
+++ b/fs/reiserfs/acl.h
@@ -48,18 +48,18 @@ static inline int reiserfs_acl_count(size_t size)
48 48
49#ifdef CONFIG_REISERFS_FS_POSIX_ACL 49#ifdef CONFIG_REISERFS_FS_POSIX_ACL
50struct posix_acl *reiserfs_get_acl(struct inode *inode, int type); 50struct posix_acl *reiserfs_get_acl(struct inode *inode, int type);
51int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
51int reiserfs_acl_chmod(struct inode *inode); 52int reiserfs_acl_chmod(struct inode *inode);
52int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, 53int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
53 struct inode *dir, struct dentry *dentry, 54 struct inode *dir, struct dentry *dentry,
54 struct inode *inode); 55 struct inode *inode);
55int reiserfs_cache_default_acl(struct inode *dir); 56int reiserfs_cache_default_acl(struct inode *dir);
56extern const struct xattr_handler reiserfs_posix_acl_default_handler;
57extern const struct xattr_handler reiserfs_posix_acl_access_handler;
58 57
59#else 58#else
60 59
61#define reiserfs_cache_default_acl(inode) 0 60#define reiserfs_cache_default_acl(inode) 0
62#define reiserfs_get_acl NULL 61#define reiserfs_get_acl NULL
62#define reiserfs_set_acl NULL
63 63
64static inline int reiserfs_acl_chmod(struct inode *inode) 64static inline int reiserfs_acl_chmod(struct inode *inode)
65{ 65{
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index dcaafcfc23b0..ed58d843d578 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -260,4 +260,5 @@ const struct inode_operations reiserfs_file_inode_operations = {
260 .removexattr = reiserfs_removexattr, 260 .removexattr = reiserfs_removexattr,
261 .permission = reiserfs_permission, 261 .permission = reiserfs_permission,
262 .get_acl = reiserfs_get_acl, 262 .get_acl = reiserfs_get_acl,
263 .set_acl = reiserfs_set_acl,
263}; 264};
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index dc5236f6de1b..e825f8b63e6b 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -1522,6 +1522,7 @@ const struct inode_operations reiserfs_dir_inode_operations = {
1522 .removexattr = reiserfs_removexattr, 1522 .removexattr = reiserfs_removexattr,
1523 .permission = reiserfs_permission, 1523 .permission = reiserfs_permission,
1524 .get_acl = reiserfs_get_acl, 1524 .get_acl = reiserfs_get_acl,
1525 .set_acl = reiserfs_set_acl,
1525}; 1526};
1526 1527
1527/* 1528/*
@@ -1538,8 +1539,6 @@ const struct inode_operations reiserfs_symlink_inode_operations = {
1538 .listxattr = reiserfs_listxattr, 1539 .listxattr = reiserfs_listxattr,
1539 .removexattr = reiserfs_removexattr, 1540 .removexattr = reiserfs_removexattr,
1540 .permission = reiserfs_permission, 1541 .permission = reiserfs_permission,
1541 .get_acl = reiserfs_get_acl,
1542
1543}; 1542};
1544 1543
1545/* 1544/*
@@ -1553,4 +1552,5 @@ const struct inode_operations reiserfs_special_inode_operations = {
1553 .removexattr = reiserfs_removexattr, 1552 .removexattr = reiserfs_removexattr,
1554 .permission = reiserfs_permission, 1553 .permission = reiserfs_permission,
1555 .get_acl = reiserfs_get_acl, 1554 .get_acl = reiserfs_get_acl,
1555 .set_acl = reiserfs_set_acl,
1556}; 1556};
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 8a9e2dcfe004..5cdfbd638b5c 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -50,6 +50,7 @@
50#include <linux/stat.h> 50#include <linux/stat.h>
51#include <linux/quotaops.h> 51#include <linux/quotaops.h>
52#include <linux/security.h> 52#include <linux/security.h>
53#include <linux/posix_acl_xattr.h>
53 54
54#define PRIVROOT_NAME ".reiserfs_priv" 55#define PRIVROOT_NAME ".reiserfs_priv"
55#define XAROOT_NAME "xattrs" 56#define XAROOT_NAME "xattrs"
@@ -904,8 +905,8 @@ static const struct xattr_handler *reiserfs_xattr_handlers[] = {
904 &reiserfs_xattr_security_handler, 905 &reiserfs_xattr_security_handler,
905#endif 906#endif
906#ifdef CONFIG_REISERFS_FS_POSIX_ACL 907#ifdef CONFIG_REISERFS_FS_POSIX_ACL
907 &reiserfs_posix_acl_access_handler, 908 &posix_acl_access_xattr_handler,
908 &reiserfs_posix_acl_default_handler, 909 &posix_acl_default_xattr_handler,
909#endif 910#endif
910 NULL 911 NULL
911}; 912};
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index d95c9592327b..a6ce532402dc 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -11,35 +11,19 @@
11#include "acl.h" 11#include "acl.h"
12#include <asm/uaccess.h> 12#include <asm/uaccess.h>
13 13
14static int reiserfs_set_acl(struct reiserfs_transaction_handle *th, 14static int __reiserfs_set_acl(struct reiserfs_transaction_handle *th,
15 struct inode *inode, int type, 15 struct inode *inode, int type,
16 struct posix_acl *acl); 16 struct posix_acl *acl);
17 17
18static int 18
19reiserfs_posix_acl_set(struct dentry *dentry, const char *name, const void *value, 19int
20 size_t size, int flags, int type) 20reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
21{ 21{
22 struct inode *inode = dentry->d_inode;
23 struct posix_acl *acl;
24 int error, error2; 22 int error, error2;
25 struct reiserfs_transaction_handle th; 23 struct reiserfs_transaction_handle th;
26 size_t jcreate_blocks; 24 size_t jcreate_blocks;
27 if (!reiserfs_posixacl(inode->i_sb)) 25 int size = acl ? posix_acl_xattr_size(acl->a_count) : 0;
28 return -EOPNOTSUPP; 26
29 if (!inode_owner_or_capable(inode))
30 return -EPERM;
31
32 if (value) {
33 acl = posix_acl_from_xattr(&init_user_ns, value, size);
34 if (IS_ERR(acl)) {
35 return PTR_ERR(acl);
36 } else if (acl) {
37 error = posix_acl_valid(acl);
38 if (error)
39 goto release_and_out;
40 }
41 } else
42 acl = NULL;
43 27
44 /* Pessimism: We can't assume that anything from the xattr root up 28 /* Pessimism: We can't assume that anything from the xattr root up
45 * has been created. */ 29 * has been created. */
@@ -51,7 +35,7 @@ reiserfs_posix_acl_set(struct dentry *dentry, const char *name, const void *valu
51 error = journal_begin(&th, inode->i_sb, jcreate_blocks); 35 error = journal_begin(&th, inode->i_sb, jcreate_blocks);
52 reiserfs_write_unlock(inode->i_sb); 36 reiserfs_write_unlock(inode->i_sb);
53 if (error == 0) { 37 if (error == 0) {
54 error = reiserfs_set_acl(&th, inode, type, acl); 38 error = __reiserfs_set_acl(&th, inode, type, acl);
55 reiserfs_write_lock(inode->i_sb); 39 reiserfs_write_lock(inode->i_sb);
56 error2 = journal_end(&th, inode->i_sb, jcreate_blocks); 40 error2 = journal_end(&th, inode->i_sb, jcreate_blocks);
57 reiserfs_write_unlock(inode->i_sb); 41 reiserfs_write_unlock(inode->i_sb);
@@ -59,29 +43,6 @@ reiserfs_posix_acl_set(struct dentry *dentry, const char *name, const void *valu
59 error = error2; 43 error = error2;
60 } 44 }
61 45
62 release_and_out:
63 posix_acl_release(acl);
64 return error;
65}
66
67static int
68reiserfs_posix_acl_get(struct dentry *dentry, const char *name, void *buffer,
69 size_t size, int type)
70{
71 struct posix_acl *acl;
72 int error;
73
74 if (!reiserfs_posixacl(dentry->d_sb))
75 return -EOPNOTSUPP;
76
77 acl = reiserfs_get_acl(dentry->d_inode, type);
78 if (IS_ERR(acl))
79 return PTR_ERR(acl);
80 if (acl == NULL)
81 return -ENODATA;
82 error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
83 posix_acl_release(acl);
84
85 return error; 46 return error;
86} 47}
87 48
@@ -221,10 +182,6 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
221 int size; 182 int size;
222 int retval; 183 int retval;
223 184
224 acl = get_cached_acl(inode, type);
225 if (acl != ACL_NOT_CACHED)
226 return acl;
227
228 switch (type) { 185 switch (type) {
229 case ACL_TYPE_ACCESS: 186 case ACL_TYPE_ACCESS:
230 name = POSIX_ACL_XATTR_ACCESS; 187 name = POSIX_ACL_XATTR_ACCESS;
@@ -273,7 +230,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
273 * BKL held [before 2.5.x] 230 * BKL held [before 2.5.x]
274 */ 231 */
275static int 232static int
276reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, 233__reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
277 int type, struct posix_acl *acl) 234 int type, struct posix_acl *acl)
278{ 235{
279 char *name; 236 char *name;
@@ -281,9 +238,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
281 size_t size = 0; 238 size_t size = 0;
282 int error; 239 int error;
283 240
284 if (S_ISLNK(inode->i_mode))
285 return -EOPNOTSUPP;
286
287 switch (type) { 241 switch (type) {
288 case ACL_TYPE_ACCESS: 242 case ACL_TYPE_ACCESS:
289 name = POSIX_ACL_XATTR_ACCESS; 243 name = POSIX_ACL_XATTR_ACCESS;
@@ -343,7 +297,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
343 struct inode *dir, struct dentry *dentry, 297 struct inode *dir, struct dentry *dentry,
344 struct inode *inode) 298 struct inode *inode)
345{ 299{
346 struct posix_acl *acl; 300 struct posix_acl *default_acl, *acl;
347 int err = 0; 301 int err = 0;
348 302
349 /* ACLs only get applied to files and directories */ 303 /* ACLs only get applied to files and directories */
@@ -363,37 +317,28 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
363 goto apply_umask; 317 goto apply_umask;
364 } 318 }
365 319
366 acl = reiserfs_get_acl(dir, ACL_TYPE_DEFAULT); 320 err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
367 if (IS_ERR(acl)) 321 if (err)
368 return PTR_ERR(acl); 322 return err;
369 323
324 if (default_acl) {
325 err = __reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
326 default_acl);
327 posix_acl_release(default_acl);
328 }
370 if (acl) { 329 if (acl) {
371 /* Copy the default ACL to the default ACL of a new directory */ 330 if (!err)
372 if (S_ISDIR(inode->i_mode)) { 331 err = __reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS,
373 err = reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT, 332 acl);
374 acl);
375 if (err)
376 goto cleanup;
377 }
378
379 /* Now we reconcile the new ACL and the mode,
380 potentially modifying both */
381 err = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
382 if (err < 0)
383 return err;
384
385 /* If we need an ACL.. */
386 if (err > 0)
387 err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
388 cleanup:
389 posix_acl_release(acl); 333 posix_acl_release(acl);
390 } else {
391 apply_umask:
392 /* no ACL, apply umask */
393 inode->i_mode &= ~current_umask();
394 } 334 }
395 335
396 return err; 336 return err;
337
338 apply_umask:
339 /* no ACL, apply umask */
340 inode->i_mode &= ~current_umask();
341 return err;
397} 342}
398 343
399/* This is used to cache the default acl before a new object is created. 344/* This is used to cache the default acl before a new object is created.
@@ -442,84 +387,11 @@ int reiserfs_cache_default_acl(struct inode *inode)
442 */ 387 */
443int reiserfs_acl_chmod(struct inode *inode) 388int reiserfs_acl_chmod(struct inode *inode)
444{ 389{
445 struct reiserfs_transaction_handle th;
446 struct posix_acl *acl;
447 size_t size;
448 int error;
449
450 if (IS_PRIVATE(inode)) 390 if (IS_PRIVATE(inode))
451 return 0; 391 return 0;
452
453 if (S_ISLNK(inode->i_mode))
454 return -EOPNOTSUPP;
455
456 if (get_inode_sd_version(inode) == STAT_DATA_V1 || 392 if (get_inode_sd_version(inode) == STAT_DATA_V1 ||
457 !reiserfs_posixacl(inode->i_sb)) { 393 !reiserfs_posixacl(inode->i_sb))
458 return 0; 394 return 0;
459 }
460 395
461 acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS); 396 return posix_acl_chmod(inode, inode->i_mode);
462 if (!acl)
463 return 0;
464 if (IS_ERR(acl))
465 return PTR_ERR(acl);
466 error = __posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode);
467 if (error)
468 return error;
469
470 size = reiserfs_xattr_nblocks(inode, reiserfs_acl_size(acl->a_count));
471 reiserfs_write_lock(inode->i_sb);
472 error = journal_begin(&th, inode->i_sb, size * 2);
473 reiserfs_write_unlock(inode->i_sb);
474 if (!error) {
475 int error2;
476 error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS, acl);
477 reiserfs_write_lock(inode->i_sb);
478 error2 = journal_end(&th, inode->i_sb, size * 2);
479 reiserfs_write_unlock(inode->i_sb);
480 if (error2)
481 error = error2;
482 }
483 posix_acl_release(acl);
484 return error;
485}
486
487static size_t posix_acl_access_list(struct dentry *dentry, char *list,
488 size_t list_size, const char *name,
489 size_t name_len, int type)
490{
491 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
492 if (!reiserfs_posixacl(dentry->d_sb))
493 return 0;
494 if (list && size <= list_size)
495 memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
496 return size;
497} 397}
498
499const struct xattr_handler reiserfs_posix_acl_access_handler = {
500 .prefix = POSIX_ACL_XATTR_ACCESS,
501 .flags = ACL_TYPE_ACCESS,
502 .get = reiserfs_posix_acl_get,
503 .set = reiserfs_posix_acl_set,
504 .list = posix_acl_access_list,
505};
506
507static size_t posix_acl_default_list(struct dentry *dentry, char *list,
508 size_t list_size, const char *name,
509 size_t name_len, int type)
510{
511 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
512 if (!reiserfs_posixacl(dentry->d_sb))
513 return 0;
514 if (list && size <= list_size)
515 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
516 return size;
517}
518
519const struct xattr_handler reiserfs_posix_acl_default_handler = {
520 .prefix = POSIX_ACL_XATTR_DEFAULT,
521 .flags = ACL_TYPE_DEFAULT,
522 .get = reiserfs_posix_acl_get,
523 .set = reiserfs_posix_acl_set,
524 .list = posix_acl_default_list,
525};