diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 11:38:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 11:38:04 -0500 |
commit | bf3d846b783327359ddc4bd4f52627b36abb4d1d (patch) | |
tree | c6b8fddbf04a2962dfcf9f487af25033f11b10b9 /fs/reiserfs | |
parent | 54c0a4b46150db1571d955d598cd342c9f1d9657 (diff) | |
parent | f6500801522c61782d4990fa1ad96154cb397cd4 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro:
"Assorted stuff; the biggest pile here is Christoph's ACL series. Plus
assorted cleanups and fixes all over the place...
There will be another pile later this week"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (43 commits)
__dentry_path() fixes
vfs: Remove second variable named error in __dentry_path
vfs: Is mounted should be testing mnt_ns for NULL or error.
Fix race when checking i_size on direct i/o read
hfsplus: remove can_set_xattr
nfsd: use get_acl and ->set_acl
fs: remove generic_acl
nfs: use generic posix ACL infrastructure for v3 Posix ACLs
gfs2: use generic posix ACL infrastructure
jfs: use generic posix ACL infrastructure
xfs: use generic posix ACL infrastructure
reiserfs: use generic posix ACL infrastructure
ocfs2: use generic posix ACL infrastructure
jffs2: use generic posix ACL infrastructure
hfsplus: use generic posix ACL infrastructure
f2fs: use generic posix ACL infrastructure
ext2/3/4: use generic posix ACL infrastructure
btrfs: use generic posix ACL infrastructure
fs: make posix_acl_create more useful
fs: make posix_acl_chmod more useful
...
Diffstat (limited to 'fs/reiserfs')
-rw-r--r-- | fs/reiserfs/acl.h | 4 | ||||
-rw-r--r-- | fs/reiserfs/file.c | 1 | ||||
-rw-r--r-- | fs/reiserfs/namei.c | 4 | ||||
-rw-r--r-- | fs/reiserfs/procfs.c | 4 | ||||
-rw-r--r-- | fs/reiserfs/reiserfs.h | 8 | ||||
-rw-r--r-- | fs/reiserfs/super.c | 8 | ||||
-rw-r--r-- | fs/reiserfs/xattr.c | 5 | ||||
-rw-r--r-- | fs/reiserfs/xattr_acl.c | 190 |
8 files changed, 45 insertions, 179 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 |
50 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type); | 50 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type); |
51 | int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); | ||
51 | int reiserfs_acl_chmod(struct inode *inode); | 52 | int reiserfs_acl_chmod(struct inode *inode); |
52 | int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, | 53 | int 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); |
55 | int reiserfs_cache_default_acl(struct inode *dir); | 56 | int reiserfs_cache_default_acl(struct inode *dir); |
56 | extern const struct xattr_handler reiserfs_posix_acl_default_handler; | ||
57 | extern 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 | ||
64 | static inline int reiserfs_acl_chmod(struct inode *inode) | 64 | static 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/procfs.c b/fs/reiserfs/procfs.c index a958444a75fc..02b0b7d0f7d5 100644 --- a/fs/reiserfs/procfs.c +++ b/fs/reiserfs/procfs.c | |||
@@ -419,7 +419,7 @@ int reiserfs_proc_info_init(struct super_block *sb) | |||
419 | char *s; | 419 | char *s; |
420 | 420 | ||
421 | /* Some block devices use /'s */ | 421 | /* Some block devices use /'s */ |
422 | strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE); | 422 | strlcpy(b, sb->s_id, BDEVNAME_SIZE); |
423 | s = strchr(b, '/'); | 423 | s = strchr(b, '/'); |
424 | if (s) | 424 | if (s) |
425 | *s = '!'; | 425 | *s = '!'; |
@@ -449,7 +449,7 @@ int reiserfs_proc_info_done(struct super_block *sb) | |||
449 | char *s; | 449 | char *s; |
450 | 450 | ||
451 | /* Some block devices use /'s */ | 451 | /* Some block devices use /'s */ |
452 | strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE); | 452 | strlcpy(b, sb->s_id, BDEVNAME_SIZE); |
453 | s = strchr(b, '/'); | 453 | s = strchr(b, '/'); |
454 | if (s) | 454 | if (s) |
455 | *s = '!'; | 455 | *s = '!'; |
diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h index dfb617b2bad2..8d06adf89948 100644 --- a/fs/reiserfs/reiserfs.h +++ b/fs/reiserfs/reiserfs.h | |||
@@ -608,14 +608,6 @@ int reiserfs_resize(struct super_block *, unsigned long); | |||
608 | 608 | ||
609 | #define SB_DISK_JOURNAL_HEAD(s) (SB_JOURNAL(s)->j_header_bh->) | 609 | #define SB_DISK_JOURNAL_HEAD(s) (SB_JOURNAL(s)->j_header_bh->) |
610 | 610 | ||
611 | /* A safe version of the "bdevname", which returns the "s_id" field of | ||
612 | * a superblock or else "Null superblock" if the super block is NULL. | ||
613 | */ | ||
614 | static inline char *reiserfs_bdevname(struct super_block *s) | ||
615 | { | ||
616 | return (s == NULL) ? "Null superblock" : s->s_id; | ||
617 | } | ||
618 | |||
619 | #define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal))) | 611 | #define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal))) |
620 | static inline int __reiserfs_is_journal_aborted(struct reiserfs_journal | 612 | static inline int __reiserfs_is_journal_aborted(struct reiserfs_journal |
621 | *journal) | 613 | *journal) |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 3ead145dadc4..2c803353f8ac 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -1479,7 +1479,7 @@ static int read_super_block(struct super_block *s, int offset) | |||
1479 | if (!bh) { | 1479 | if (!bh) { |
1480 | reiserfs_warning(s, "sh-2006", | 1480 | reiserfs_warning(s, "sh-2006", |
1481 | "bread failed (dev %s, block %lu, size %lu)", | 1481 | "bread failed (dev %s, block %lu, size %lu)", |
1482 | reiserfs_bdevname(s), offset / s->s_blocksize, | 1482 | s->s_id, offset / s->s_blocksize, |
1483 | s->s_blocksize); | 1483 | s->s_blocksize); |
1484 | return 1; | 1484 | return 1; |
1485 | } | 1485 | } |
@@ -1500,7 +1500,7 @@ static int read_super_block(struct super_block *s, int offset) | |||
1500 | if (!bh) { | 1500 | if (!bh) { |
1501 | reiserfs_warning(s, "sh-2007", | 1501 | reiserfs_warning(s, "sh-2007", |
1502 | "bread failed (dev %s, block %lu, size %lu)", | 1502 | "bread failed (dev %s, block %lu, size %lu)", |
1503 | reiserfs_bdevname(s), offset / s->s_blocksize, | 1503 | s->s_id, offset / s->s_blocksize, |
1504 | s->s_blocksize); | 1504 | s->s_blocksize); |
1505 | return 1; | 1505 | return 1; |
1506 | } | 1506 | } |
@@ -1509,7 +1509,7 @@ static int read_super_block(struct super_block *s, int offset) | |||
1509 | if (sb_blocksize(rs) != s->s_blocksize) { | 1509 | if (sb_blocksize(rs) != s->s_blocksize) { |
1510 | reiserfs_warning(s, "sh-2011", "can't find a reiserfs " | 1510 | reiserfs_warning(s, "sh-2011", "can't find a reiserfs " |
1511 | "filesystem on (dev %s, block %Lu, size %lu)", | 1511 | "filesystem on (dev %s, block %Lu, size %lu)", |
1512 | reiserfs_bdevname(s), | 1512 | s->s_id, |
1513 | (unsigned long long)bh->b_blocknr, | 1513 | (unsigned long long)bh->b_blocknr, |
1514 | s->s_blocksize); | 1514 | s->s_blocksize); |
1515 | brelse(bh); | 1515 | brelse(bh); |
@@ -1825,7 +1825,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1825 | /* try new format (64-th 1k block), which can contain reiserfs super block */ | 1825 | /* try new format (64-th 1k block), which can contain reiserfs super block */ |
1826 | else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) { | 1826 | else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) { |
1827 | SWARN(silent, s, "sh-2021", "can not find reiserfs on %s", | 1827 | SWARN(silent, s, "sh-2021", "can not find reiserfs on %s", |
1828 | reiserfs_bdevname(s)); | 1828 | s->s_id); |
1829 | goto error_unlocked; | 1829 | goto error_unlocked; |
1830 | } | 1830 | } |
1831 | 1831 | ||
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 06c04f73da65..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 | ||
14 | static int reiserfs_set_acl(struct reiserfs_transaction_handle *th, | 14 | static 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 | ||
18 | static int | 18 | |
19 | posix_acl_set(struct dentry *dentry, const char *name, const void *value, | 19 | int |
20 | size_t size, int flags, int type) | 20 | reiserfs_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 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value, | |||
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,36 +43,13 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value, | |||
59 | error = error2; | 43 | error = error2; |
60 | } | 44 | } |
61 | 45 | ||
62 | release_and_out: | ||
63 | posix_acl_release(acl); | ||
64 | return error; | ||
65 | } | ||
66 | |||
67 | static int | ||
68 | 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 | ||
88 | /* | 49 | /* |
89 | * Convert from filesystem to in-memory representation. | 50 | * Convert from filesystem to in-memory representation. |
90 | */ | 51 | */ |
91 | static struct posix_acl *posix_acl_from_disk(const void *value, size_t size) | 52 | static struct posix_acl *reiserfs_posix_acl_from_disk(const void *value, size_t size) |
92 | { | 53 | { |
93 | const char *end = (char *)value + size; | 54 | const char *end = (char *)value + size; |
94 | int n, count; | 55 | int n, count; |
@@ -158,7 +119,7 @@ static struct posix_acl *posix_acl_from_disk(const void *value, size_t size) | |||
158 | /* | 119 | /* |
159 | * Convert from in-memory to filesystem representation. | 120 | * Convert from in-memory to filesystem representation. |
160 | */ | 121 | */ |
161 | static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size) | 122 | static void *reiserfs_posix_acl_to_disk(const struct posix_acl *acl, size_t * size) |
162 | { | 123 | { |
163 | reiserfs_acl_header *ext_acl; | 124 | reiserfs_acl_header *ext_acl; |
164 | char *e; | 125 | char *e; |
@@ -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; |
@@ -257,7 +214,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | |||
257 | } else if (retval < 0) { | 214 | } else if (retval < 0) { |
258 | acl = ERR_PTR(retval); | 215 | acl = ERR_PTR(retval); |
259 | } else { | 216 | } else { |
260 | acl = posix_acl_from_disk(value, retval); | 217 | acl = reiserfs_posix_acl_from_disk(value, retval); |
261 | } | 218 | } |
262 | if (!IS_ERR(acl)) | 219 | if (!IS_ERR(acl)) |
263 | set_cached_acl(inode, type, acl); | 220 | set_cached_acl(inode, type, acl); |
@@ -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 | */ |
275 | static int | 232 | static int |
276 | reiserfs_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; |
@@ -307,7 +261,7 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
307 | } | 261 | } |
308 | 262 | ||
309 | if (acl) { | 263 | if (acl) { |
310 | value = posix_acl_to_disk(acl, &size); | 264 | value = reiserfs_posix_acl_to_disk(acl, &size); |
311 | if (IS_ERR(value)) | 265 | if (IS_ERR(value)) |
312 | return (int)PTR_ERR(value); | 266 | return (int)PTR_ERR(value); |
313 | } | 267 | } |
@@ -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 | */ |
443 | int reiserfs_acl_chmod(struct inode *inode) | 388 | int 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 | |||
487 | static 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 | |||
499 | const struct xattr_handler reiserfs_posix_acl_access_handler = { | ||
500 | .prefix = POSIX_ACL_XATTR_ACCESS, | ||
501 | .flags = ACL_TYPE_ACCESS, | ||
502 | .get = posix_acl_get, | ||
503 | .set = posix_acl_set, | ||
504 | .list = posix_acl_access_list, | ||
505 | }; | ||
506 | |||
507 | static 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 | |||
519 | const struct xattr_handler reiserfs_posix_acl_default_handler = { | ||
520 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
521 | .flags = ACL_TYPE_DEFAULT, | ||
522 | .get = posix_acl_get, | ||
523 | .set = posix_acl_set, | ||
524 | .list = posix_acl_default_list, | ||
525 | }; | ||