1 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/Makefile linux-2.4.23.xattr/Makefile
2 --- linux-2.4.23.datalogging+quota/Makefile 2003-12-11 12:53:17.834531104 -0500
3 +++ linux-2.4.23.xattr/Makefile 2003-12-11 13:03:06.815992312 -0500
4 @@ -92,7 +92,7 @@ export MODLIB
5 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
7 CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
8 - -fno-strict-aliasing -fno-common
9 + -fno-strict-aliasing -fno-common -Wno-sign-compare
10 ifndef CONFIG_FRAME_POINTER
11 CFLAGS += -fomit-frame-pointer
13 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/Config.in linux-2.4.23.xattr/fs/Config.in
14 --- linux-2.4.23.datalogging+quota/fs/Config.in 2003-12-11 13:00:09.957878832 -0500
15 +++ linux-2.4.23.xattr/fs/Config.in 2003-12-11 13:00:17.428743088 -0500
16 @@ -15,6 +15,7 @@ dep_mbool ' Enable reiserfs debug mode'
17 dep_mbool ' Stats in /proc/fs/reiserfs' CONFIG_REISERFS_PROC_INFO $CONFIG_REISERFS_FS
18 dep_mbool ' ReiserFS extended attributes' CONFIG_REISERFS_FS_XATTR $CONFIG_REISERFS_FS
19 dep_mbool ' ReiserFS extended user attributes' CONFIG_REISERFS_FS_XATTR_USER $CONFIG_REISERFS_FS_XATTR
20 +dep_mbool ' ReiserFS POSIX Access Control Lists' CONFIG_REISERFS_FS_POSIX_ACL $CONFIG_REISERFS_FS_XATTR $CONFIG_FS_POSIX_ACL
22 dep_tristate 'ADFS file system support (EXPERIMENTAL)' CONFIG_ADFS_FS $CONFIG_EXPERIMENTAL
23 dep_mbool ' ADFS write support (DANGEROUS)' CONFIG_ADFS_FS_RW $CONFIG_ADFS_FS $CONFIG_EXPERIMENTAL
24 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/Makefile linux-2.4.23.xattr/fs/reiserfs/Makefile
25 --- linux-2.4.23.datalogging+quota/fs/reiserfs/Makefile 2003-12-11 13:00:09.958878680 -0500
26 +++ linux-2.4.23.xattr/fs/reiserfs/Makefile 2003-12-11 13:00:17.429742936 -0500
27 @@ -14,6 +14,7 @@ lbalance.o ibalance.o stree.o hashes.o b
29 obj-$(CONFIG_REISERFS_FS_XATTR) += xattr.o
30 obj-$(CONFIG_REISERFS_FS_XATTR_USER) += xattr_user.o
31 +obj-$(CONFIG_REISERFS_FS_POSIX_ACL) += xattr_acl.o
35 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/file.c linux-2.4.23.xattr/fs/reiserfs/file.c
36 --- linux-2.4.23.datalogging+quota/fs/reiserfs/file.c 2003-12-11 13:00:09.958878680 -0500
37 +++ linux-2.4.23.xattr/fs/reiserfs/file.c 2003-12-11 13:00:17.429742936 -0500
40 #include <linux/sched.h>
41 #include <linux/reiserfs_fs.h>
42 +#include <linux/reiserfs_acl.h>
43 #include <linux/reiserfs_xattr.h>
44 #include <linux/smp_lock.h>
45 #include <linux/quotaops.h>
46 @@ -178,6 +179,7 @@ struct inode_operations reiserfs_file_i
47 getxattr: reiserfs_getxattr,
48 listxattr: reiserfs_listxattr,
49 removexattr: reiserfs_removexattr,
50 + permission: reiserfs_permission,
54 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/inode.c linux-2.4.23.xattr/fs/reiserfs/inode.c
55 --- linux-2.4.23.datalogging+quota/fs/reiserfs/inode.c 2003-12-11 13:00:09.961878224 -0500
56 +++ linux-2.4.23.xattr/fs/reiserfs/inode.c 2003-12-11 13:04:08.957545360 -0500
59 #include <linux/reiserfs_fs.h>
60 #include <linux/reiserfs_xattr.h>
61 +#include <linux/reiserfs_acl.h>
62 #include <linux/quotaops.h>
63 #include <linux/locks.h>
64 #include <linux/smp_lock.h>
65 @@ -1851,6 +1852,18 @@ int reiserfs_new_inode (struct reiserfs_
69 + if (reiserfs_posixacl (inode->i_sb)) {
70 + retval = reiserfs_inherit_default_acl (dir, dentry, inode);
74 + reiserfs_check_path(&path_to_key) ;
75 + goto out_inserted_sd;
77 + } else if (inode->i_sb->s_flags & MS_POSIXACL) {
78 + reiserfs_warning (inode->i_sb, "ACLs aren't enabled in the fs, but vfs thinks they are!\n");
81 insert_inode_hash (inode);
82 reiserfs_update_sd(th, inode) ;
83 reiserfs_check_path(&path_to_key) ;
84 @@ -2753,6 +2766,15 @@ int reiserfs_setattr(struct dentry *dent
87 error = inode_setattr(inode, attr) ;
88 + if (!error && reiserfs_posixacl (inode->i_sb)) {
89 + if (attr->ia_valid & ATTR_MODE) {
90 + if (!(attr->ia_valid & ATTR_SIZE))
91 + down (&inode->i_sem);
92 + error = reiserfs_acl_chmod (inode);
93 + if (!(attr->ia_valid & ATTR_SIZE))
100 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/namei.c linux-2.4.23.xattr/fs/reiserfs/namei.c
101 --- linux-2.4.23.datalogging+quota/fs/reiserfs/namei.c 2003-12-11 13:00:09.962878072 -0500
102 +++ linux-2.4.23.xattr/fs/reiserfs/namei.c 2003-12-11 13:00:17.434742176 -0500
104 #include <linux/sched.h>
105 #include <linux/bitops.h>
106 #include <linux/reiserfs_fs.h>
107 +#include <linux/reiserfs_acl.h>
108 #include <linux/reiserfs_xattr.h>
109 #include <linux/smp_lock.h>
110 #include <linux/quotaops.h>
111 @@ -546,6 +547,7 @@ static int reiserfs_create (struct inode
112 struct inode * inode;
113 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 ;
114 struct reiserfs_transaction_handle th ;
117 if (!(inode = new_inode(dir->i_sb))) {
119 @@ -554,6 +556,10 @@ static int reiserfs_create (struct inode
123 + locked = reiserfs_cache_default_acl (dir);
125 + reiserfs_write_lock_xattrs (dir->i_sb);
127 journal_begin(&th, dir->i_sb, jbegin_count) ;
128 retval = reiserfs_new_inode (&th, dir, mode, 0, 0/*i_size*/, dentry, inode);
130 @@ -566,6 +572,9 @@ static int reiserfs_create (struct inode
132 retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
133 inode, 1/*visible*/);
135 + reiserfs_write_unlock_xattrs (dir->i_sb);
139 reiserfs_update_sd (&th, inode);
140 @@ -591,6 +600,7 @@ static int reiserfs_mknod (struct inode
141 struct inode * inode;
142 struct reiserfs_transaction_handle th ;
143 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3;
146 if (!(inode = new_inode(dir->i_sb))) {
148 @@ -599,9 +609,17 @@ static int reiserfs_mknod (struct inode
152 + locked = reiserfs_cache_default_acl (dir);
154 + reiserfs_write_lock_xattrs (inode->i_sb);
156 journal_begin(&th, dir->i_sb, jbegin_count) ;
158 retval = reiserfs_new_inode(&th, dir, mode, 0, 0/*i_size*/, dentry, inode);
161 + reiserfs_write_unlock_xattrs (inode->i_sb);
166 @@ -639,6 +657,7 @@ static int reiserfs_mkdir (struct inode
167 struct inode * inode;
168 struct reiserfs_transaction_handle th ;
169 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3;
172 mode = S_IFDIR | mode;
173 if (!(inode = new_inode(dir->i_sb))) {
174 @@ -648,6 +667,10 @@ static int reiserfs_mkdir (struct inode
178 + locked = reiserfs_cache_default_acl (dir);
180 + reiserfs_write_lock_xattrs (inode->i_sb);
182 journal_begin(&th, dir->i_sb, jbegin_count) ;
184 /* inc the link count now, so another writer doesn't overflow it while
185 @@ -663,6 +686,9 @@ static int reiserfs_mkdir (struct inode
186 old_format_only (dir->i_sb) ?
187 EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
190 + reiserfs_write_unlock_xattrs (inode->i_sb);
195 @@ -908,6 +934,8 @@ static int reiserfs_symlink (struct inod
196 memcpy (name, symname, strlen (symname));
197 padd_item (name, item_len, strlen (symname));
199 + /* We would inherit the default ACL here, but symlinks don't get ACLs */
201 journal_begin(&th, parent_dir->i_sb, jbegin_count) ;
203 retval = reiserfs_new_inode(&th, parent_dir, mode, name,
204 @@ -1297,6 +1325,7 @@ struct inode_operations reiserfs_dir_ino
205 getxattr: reiserfs_getxattr,
206 listxattr: reiserfs_listxattr,
207 removexattr: reiserfs_removexattr,
208 + permission: reiserfs_permission,
212 @@ -1311,4 +1340,5 @@ struct inode_operations reiserfs_symlink
213 getxattr: reiserfs_getxattr,
214 listxattr: reiserfs_listxattr,
215 removexattr: reiserfs_removexattr,
216 + permission: reiserfs_permission,
218 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/super.c linux-2.4.23.xattr/fs/reiserfs/super.c
219 --- linux-2.4.23.datalogging+quota/fs/reiserfs/super.c 2003-12-11 13:00:09.963877920 -0500
220 +++ linux-2.4.23.xattr/fs/reiserfs/super.c 2003-12-11 13:00:17.435742024 -0500
222 #include <linux/vmalloc.h>
223 #include <asm/uaccess.h>
224 #include <linux/reiserfs_fs.h>
225 +#include <linux/reiserfs_acl.h>
226 #include <linux/reiserfs_xattr.h>
227 #include <linux/smp_lock.h>
228 #include <linux/locks.h>
229 @@ -430,6 +431,22 @@ static void reiserfs_dirty_inode (struct
233 +static void reiserfs_clear_inode (struct inode *inode)
235 + struct posix_acl *acl;
237 + acl = inode->u.reiserfs_i.i_acl_access;
238 + if (acl && !IS_ERR (acl))
239 + posix_acl_release (acl);
240 + inode->u.reiserfs_i.i_acl_access = NULL;
242 + acl = inode->u.reiserfs_i.i_acl_default;
243 + if (acl && !IS_ERR (acl))
244 + posix_acl_release (acl);
245 + inode->u.reiserfs_i.i_acl_default = NULL;
249 struct super_operations reiserfs_sops =
251 read_inode: reiserfs_read_inode,
252 @@ -437,6 +454,7 @@ struct super_operations reiserfs_sops =
253 write_inode: reiserfs_write_inode,
254 dirty_inode: reiserfs_dirty_inode,
255 delete_inode: reiserfs_delete_inode,
256 + clear_inode: reiserfs_clear_inode,
257 put_super: reiserfs_put_super,
258 write_super: reiserfs_write_super,
259 write_super_lockfs: reiserfs_write_super_lockfs,
260 @@ -655,6 +673,10 @@ static int reiserfs_parse_options (struc
261 {"user_xattr", 0, 0, 1<<REISERFS_XATTRS_USER, 0},
262 {"nouser_xattr", 0, 0, 0, 1<<REISERFS_XATTRS_USER},
264 +# ifdef CONFIG_REISERFS_FS_POSIX_ACL
265 + {"acl", 0, 0, 1<<REISERFS_POSIXACL, 0},
266 + {"noacl", 0, 0, 0, 1<<REISERFS_POSIXACL},
271 @@ -774,6 +796,7 @@ static int reiserfs_remount (struct supe
272 safe_mask |= 1 << REISERFS_TEST4;
273 safe_mask |= 1 << REISERFS_ATTRS;
274 safe_mask |= 1 << REISERFS_XATTRS_USER;
275 + safe_mask |= 1 << REISERFS_POSIXACL;
277 /* Update the bitmask, taking care to keep
278 * the bits we're not allowed to change here */
279 @@ -1487,8 +1510,14 @@ static int __init init_reiserfs_fs (void
281 goto failed_xattr_user_init;
283 + ret = reiserfs_xattr_posix_acl_init ();
285 + goto failed_xattr_posix_acl_init;
287 return register_filesystem(&reiserfs_fs_type);
289 +failed_xattr_posix_acl_init:
290 + reiserfs_xattr_user_exit();
291 failed_xattr_user_init:
292 failed_journal_cache_init:
293 reiserfs_proc_unregister_global( "version" );
294 @@ -1503,6 +1532,7 @@ MODULE_LICENSE("GPL");
296 static void __exit exit_reiserfs_fs(void)
298 + reiserfs_xattr_posix_acl_exit ();
299 reiserfs_xattr_user_exit ();
300 reiserfs_proc_unregister_global( "version" );
301 reiserfs_proc_info_global_done();
302 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/xattr.c linux-2.4.23.xattr/fs/reiserfs/xattr.c
303 --- linux-2.4.23.datalogging+quota/fs/reiserfs/xattr.c 2003-12-11 13:00:09.966877464 -0500
304 +++ linux-2.4.23.xattr/fs/reiserfs/xattr.c 2003-12-11 13:00:17.437741720 -0500
309 - * In order to implement EAs in a clean, backwards compatible manner,
310 + * In order to implement EA/ACLs in a clean, backwards compatible manner,
311 * they are implemented as files in a "private" directory.
312 * Each EA is in it's own file, with the directory layout like so (/ is assumed
313 * to be relative to fs root). Inside the /.reiserfs_priv/xattrs directory,
315 * named with the name of the extended attribute.
317 * So, for objectid 12648430, we could have:
318 + * /.reiserfs_priv/xattrs/C0FFEE.0/system.posix_acl_access
319 + * /.reiserfs_priv/xattrs/C0FFEE.0/system.posix_acl_default
320 * /.reiserfs_priv/xattrs/C0FFEE.0/user.Content-Type
323 * The file contents are the text of the EA. The size is known based on the
324 * stat data describing the file.
326 + * In the case of system.posix_acl_access and system.posix_acl_default, since
327 + * these are special cases for filesystem ACLs, they are interpreted by the
328 + * kernel, in addition, they are negatively and positively cached and attached
329 + * to the inode so that unnecessary lookups are avoided.
332 #include <linux/reiserfs_fs.h>
333 @@ -1182,7 +1188,7 @@ reiserfs_xattr_init (struct super_block
334 /* We need generation numbers to ensure that the oid mapping is correct
335 * v3.5 filesystems don't have them. */
336 if (old_format_only (s)) {
337 - reiserfs_warning (s, "reiserfs: xattrs not supported on pre v3.6 "
338 + reiserfs_warning (s, "reiserfs: xattrs/ACLs not supported on pre v3.6 "
339 "format filesystem. Failing mount.\n");
342 @@ -1221,7 +1227,7 @@ reiserfs_xattr_init (struct super_block
343 * created. Not an error -- just no xattrs on the fs. We'll
344 * check again if we go read-write */
345 if (!(mount_flags & MS_RDONLY)) {
346 - reiserfs_warning (s, "reiserfs: xattrs enabled and couldn't "
347 + reiserfs_warning (s, "reiserfs: xattrs/ACLs enabled and couldn't "
348 "find/create .reiserfs_priv. Failing mount.\n");
351 @@ -1230,6 +1236,7 @@ reiserfs_xattr_init (struct super_block
353 clear_bit (REISERFS_XATTRS, &(s->u.reiserfs_sb.s_mount_opt));
354 clear_bit (REISERFS_XATTRS_USER, &(s->u.reiserfs_sb.s_mount_opt));
355 + clear_bit (REISERFS_POSIXACL, &(s->u.reiserfs_sb.s_mount_opt));
359 @@ -1241,6 +1248,10 @@ error:
361 clear_bit (REISERFS_XATTRS, &(s->u.reiserfs_sb.s_mount_opt));
362 clear_bit (REISERFS_XATTRS_USER, &(s->u.reiserfs_sb.s_mount_opt));
363 + clear_bit (REISERFS_POSIXACL, &(s->u.reiserfs_sb.s_mount_opt));
366 + s->s_flags = (s->s_flags & ~MS_POSIXACL) |
367 + (reiserfs_posixacl (s) ? MS_POSIXACL : 0);
370 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/xattr_acl.c linux-2.4.23.xattr/fs/reiserfs/xattr_acl.c
371 --- linux-2.4.23.datalogging+quota/fs/reiserfs/xattr_acl.c 1969-12-31 19:00:00.000000000 -0500
372 +++ linux-2.4.23.xattr/fs/reiserfs/xattr_acl.c 2003-12-11 13:00:17.438741568 -0500
374 +#include <linux/posix_acl.h>
375 +#include <linux/reiserfs_fs.h>
376 +#include <linux/errno.h>
377 +#include <linux/fs.h>
378 +#include <linux/pagemap.h>
379 +#include <linux/xattr.h>
380 +#include <linux/xattr_acl.h>
381 +#include <linux/reiserfs_xattr.h>
382 +#include <linux/reiserfs_acl.h>
383 +#include <asm/uaccess.h>
386 +xattr_set_acl(struct inode *inode, int type, const void *value, size_t size)
388 + struct posix_acl *acl;
391 + if (!reiserfs_posixacl(inode->i_sb))
392 + return -EOPNOTSUPP;
393 + if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
397 + acl = posix_acl_from_xattr(value, size);
399 + return PTR_ERR(acl);
401 + error = posix_acl_valid(acl);
403 + goto release_and_out;
408 + error = reiserfs_set_acl (inode, type, acl);
411 + posix_acl_release(acl);
417 +xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
419 + struct posix_acl *acl;
422 + if (!reiserfs_posixacl(inode->i_sb))
423 + return -EOPNOTSUPP;
425 + acl = reiserfs_get_acl (inode, type);
427 + return PTR_ERR(acl);
430 + error = posix_acl_to_xattr(acl, buffer, size);
431 + posix_acl_release(acl);
438 + * Convert from filesystem to in-memory representation.
440 +static struct posix_acl *
441 +posix_acl_from_disk(const void *value, size_t size)
443 + const char *end = (char *)value + size;
445 + struct posix_acl *acl;
449 + if (size < sizeof(reiserfs_acl_header))
450 + return ERR_PTR(-EINVAL);
451 + if (((reiserfs_acl_header *)value)->a_version !=
452 + cpu_to_le32(REISERFS_ACL_VERSION))
453 + return ERR_PTR(-EINVAL);
454 + value = (char *)value + sizeof(reiserfs_acl_header);
455 + count = reiserfs_acl_count(size);
457 + return ERR_PTR(-EINVAL);
460 + acl = posix_acl_alloc(count, GFP_NOFS);
462 + return ERR_PTR(-ENOMEM);
463 + for (n=0; n < count; n++) {
464 + reiserfs_acl_entry *entry =
465 + (reiserfs_acl_entry *)value;
466 + if ((char *)value + sizeof(reiserfs_acl_entry_short) > end)
468 + acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
469 + acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
470 + switch(acl->a_entries[n].e_tag) {
472 + case ACL_GROUP_OBJ:
475 + value = (char *)value +
476 + sizeof(reiserfs_acl_entry_short);
477 + acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
482 + value = (char *)value + sizeof(reiserfs_acl_entry);
483 + if ((char *)value > end)
485 + acl->a_entries[n].e_id =
486 + le32_to_cpu(entry->e_id);
498 + posix_acl_release(acl);
499 + return ERR_PTR(-EINVAL);
503 + * Convert from in-memory to filesystem representation.
506 +posix_acl_to_disk(const struct posix_acl *acl, size_t *size)
508 + reiserfs_acl_header *ext_acl;
512 + *size = reiserfs_acl_size(acl->a_count);
513 + ext_acl = (reiserfs_acl_header *)kmalloc(sizeof(reiserfs_acl_header) +
514 + acl->a_count * sizeof(reiserfs_acl_entry), GFP_NOFS);
516 + return ERR_PTR(-ENOMEM);
517 + ext_acl->a_version = cpu_to_le32(REISERFS_ACL_VERSION);
518 + e = (char *)ext_acl + sizeof(reiserfs_acl_header);
519 + for (n=0; n < acl->a_count; n++) {
520 + reiserfs_acl_entry *entry = (reiserfs_acl_entry *)e;
521 + entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
522 + entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
523 + switch(acl->a_entries[n].e_tag) {
527 + cpu_to_le32(acl->a_entries[n].e_id);
528 + e += sizeof(reiserfs_acl_entry);
532 + case ACL_GROUP_OBJ:
535 + e += sizeof(reiserfs_acl_entry_short);
542 + return (char *)ext_acl;
546 + return ERR_PTR(-EINVAL);
550 + * Inode operation get_posix_acl().
552 + * inode->i_sem: down
553 + * BKL held [before 2.5.x]
556 +reiserfs_get_acl(struct inode *inode, int type)
558 + char *name, *value;
559 + struct posix_acl *acl, **p_acl;
564 + case ACL_TYPE_ACCESS:
565 + name = XATTR_NAME_ACL_ACCESS;
566 + p_acl = &inode->u.reiserfs_i.i_acl_access;
568 + case ACL_TYPE_DEFAULT:
569 + name = XATTR_NAME_ACL_DEFAULT;
570 + p_acl = &inode->u.reiserfs_i.i_acl_default;
573 + return ERR_PTR (-EINVAL);
576 + if (IS_ERR (*p_acl)) {
577 + if (PTR_ERR (*p_acl) == -ENODATA)
579 + } else if (*p_acl != NULL)
580 + return posix_acl_dup (*p_acl);
582 + size = reiserfs_xattr_get (inode, name, NULL, 0);
583 + if ((int)size < 0) {
584 + if (size == -ENODATA || size == -ENOSYS) {
585 + *p_acl = ERR_PTR (-ENODATA);
588 + return ERR_PTR (size);
591 + value = kmalloc (size, GFP_NOFS);
593 + return ERR_PTR (-ENOMEM);
595 + retval = reiserfs_xattr_get(inode, name, value, size);
596 + if (retval == -ENODATA || retval == -ENOSYS) {
597 + /* This shouldn't actually happen as it should have
598 + been caught above.. but just in case */
600 + *p_acl = ERR_PTR (-ENODATA);
601 + } else if (retval < 0) {
602 + acl = ERR_PTR(retval);
604 + acl = posix_acl_from_disk(value, retval);
605 + *p_acl = posix_acl_dup (acl);
613 + * Inode operation set_posix_acl().
615 + * inode->i_sem: down
616 + * BKL held [before 2.5.x]
619 +reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
622 + void *value = NULL;
623 + struct posix_acl **p_acl;
627 + if (S_ISLNK(inode->i_mode))
628 + return -EOPNOTSUPP;
632 + case ACL_TYPE_ACCESS:
633 + name = XATTR_NAME_ACL_ACCESS;
634 + p_acl = &inode->u.reiserfs_i.i_acl_access;
636 + mode_t mode = inode->i_mode;
637 + error = posix_acl_equiv_mode (acl, &mode);
641 + inode->i_mode = mode;
647 + case ACL_TYPE_DEFAULT:
648 + name = XATTR_NAME_ACL_DEFAULT;
649 + p_acl = &inode->u.reiserfs_i.i_acl_default;
650 + if (!S_ISDIR (inode->i_mode))
651 + return acl ? -EACCES : 0;
658 + value = posix_acl_to_disk(acl, &size);
660 + return (int)PTR_ERR(value);
661 + error = reiserfs_xattr_set(inode, name, value, size, 0);
663 + error = reiserfs_xattr_del (inode, name);
664 + if (error == -ENODATA)
672 + /* Release the old one */
673 + if (!IS_ERR (*p_acl) && *p_acl)
674 + posix_acl_release (*p_acl);
677 + *p_acl = ERR_PTR (-ENODATA);
679 + *p_acl = posix_acl_dup (acl);
685 +/* dir->i_sem: down,
686 + * inode is new and not released into the wild yet */
688 +reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode)
690 + struct posix_acl *acl;
693 + /* ACLs only get applied to files and directories */
694 + if (S_ISLNK (inode->i_mode))
697 + /* ACLs can only be used on "new" objects, so if it's an old object
698 + * there is nothing to inherit from */
699 + if (get_inode_sd_version (dir) == STAT_DATA_V1)
702 + /* Don't apply ACLs to objects in the .reiserfs_priv tree.. This
703 + * would be useless since permissions are ignored, and a pain because
704 + * it introduces locking cycles */
705 + if (is_reiserfs_priv_object (dir)) {
706 + inode->u.reiserfs_i.i_flags |= i_priv_object;
710 + acl = reiserfs_get_acl (dir, ACL_TYPE_DEFAULT);
711 + if (IS_ERR (acl)) {
712 + if (PTR_ERR (acl) == -ENODATA)
714 + return PTR_ERR (acl);
718 + struct posix_acl *acl_copy;
719 + mode_t mode = inode->i_mode;
722 + /* Copy the default ACL to the default ACL of a new directory */
723 + if (S_ISDIR (inode->i_mode)) {
724 + err = reiserfs_set_acl (inode, ACL_TYPE_DEFAULT, acl);
729 + /* Now we reconcile the new ACL and the mode,
730 + potentially modifying both */
731 + acl_copy = posix_acl_clone (acl, GFP_NOFS);
738 + need_acl = posix_acl_create_masq (acl_copy, &mode);
739 + if (need_acl >= 0) {
740 + if (mode != inode->i_mode) {
741 + inode->i_mode = mode;
744 + /* If we need an ACL.. */
745 + if (need_acl > 0) {
746 + err = reiserfs_set_acl (inode, ACL_TYPE_ACCESS, acl_copy);
752 + posix_acl_release (acl_copy);
754 + posix_acl_release (acl);
757 + /* no ACL, apply umask */
758 + inode->i_mode &= ~current->fs->umask;
764 +/* Looks up and caches the result of the default ACL.
765 + * We do this so that we don't need to carry the xattr_sem into
766 + * reiserfs_new_inode if we don't need to */
768 +reiserfs_cache_default_acl (struct inode *inode)
771 + if (reiserfs_posixacl (inode->i_sb) &&
772 + !is_reiserfs_priv_object (inode)) {
773 + struct posix_acl *acl;
774 + reiserfs_read_lock_xattrs (inode->i_sb);
775 + acl = reiserfs_get_acl (inode, ACL_TYPE_DEFAULT);
776 + reiserfs_read_unlock_xattrs (inode->i_sb);
778 + posix_acl_release (acl);
785 +__reiserfs_permission (struct inode *inode, int mask, int need_lock)
787 + int mode = inode->i_mode;
789 + /* Nobody gets write access to a read-only fs */
790 + if ((mask & MAY_WRITE) && IS_RDONLY(inode) &&
791 + (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
794 + /* Nobody gets write access to an immutable file */
795 + if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
798 + /* We don't do permission checks on the internal objects.
799 + * Permissions are determined by the "owning" object. */
800 + if (is_reiserfs_priv_object (inode))
803 + if (current->fsuid == inode->i_uid) {
805 + } else if (reiserfs_posixacl(inode->i_sb) &&
806 + get_inode_sd_version (inode) != STAT_DATA_V1) {
807 + struct posix_acl *acl;
809 + /* ACL can't contain additional permissions if
810 + the ACL_MASK entry is 0 */
811 + if (!(mode & S_IRWXG))
815 + reiserfs_read_lock_xattrs (inode->i_sb);
816 + acl = reiserfs_get_acl (inode, ACL_TYPE_ACCESS);
818 + reiserfs_read_unlock_xattrs (inode->i_sb);
819 + if (IS_ERR (acl)) {
820 + if (PTR_ERR (acl) == -ENODATA)
822 + return PTR_ERR (acl);
826 + int err = posix_acl_permission (inode, acl, mask);
827 + posix_acl_release (acl);
828 + if (err == -EACCES) {
829 + goto check_capabilities;
838 + if (in_group_p(inode->i_gid))
841 + if ((mode & mask & S_IRWXO) == mask)
845 + /* Allowed to override Discretionary Access Control? */
846 + if ((mask & (MAY_READ|MAY_WRITE)) || (inode->i_mode & S_IXUGO))
847 + if (capable(CAP_DAC_OVERRIDE))
849 + /* Read and search granted if capable(CAP_DAC_READ_SEARCH) */
850 + if (capable(CAP_DAC_READ_SEARCH) && ((mask == MAY_READ) ||
851 + (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE))))
857 +reiserfs_permission (struct inode *inode, int mask)
859 + return __reiserfs_permission (inode, mask, 1);
863 +reiserfs_permission_locked (struct inode *inode, int mask)
865 + return __reiserfs_permission (inode, mask, 0);
869 +reiserfs_acl_chmod (struct inode *inode)
871 + struct posix_acl *acl, *clone;
874 + if (S_ISLNK(inode->i_mode))
875 + return -EOPNOTSUPP;
877 + if (get_inode_sd_version (inode) == STAT_DATA_V1 ||
878 + !reiserfs_posixacl(inode->i_sb))
883 + reiserfs_read_lock_xattrs (inode->i_sb);
884 + acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
885 + reiserfs_read_unlock_xattrs (inode->i_sb);
889 + return PTR_ERR(acl);
890 + clone = posix_acl_clone(acl, GFP_NOFS);
891 + posix_acl_release(acl);
894 + error = posix_acl_chmod_masq(clone, inode->i_mode);
896 + reiserfs_write_lock_xattrs (inode->i_sb);
897 + error = reiserfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
898 + reiserfs_write_unlock_xattrs (inode->i_sb);
900 + posix_acl_release(clone);
905 +posix_acl_access_get(struct inode *inode, const char *name,
906 + void *buffer, size_t size)
908 + if (strlen(name) != sizeof(XATTR_NAME_ACL_ACCESS)-1)
910 + return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
914 +posix_acl_access_set(struct inode *inode, const char *name,
915 + const void *value, size_t size, int flags)
917 + if (strlen(name) != sizeof(XATTR_NAME_ACL_ACCESS)-1)
919 + return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
923 +posix_acl_access_del (struct inode *inode, const char *name)
925 + struct posix_acl **acl = &inode->u.reiserfs_i.i_acl_access;
926 + if (strlen(name) != sizeof(XATTR_NAME_ACL_ACCESS)-1)
928 + if (!IS_ERR (*acl) && *acl) {
929 + posix_acl_release (*acl);
930 + *acl = ERR_PTR (-ENODATA);
937 +posix_acl_access_list (struct inode *inode, const char *name, int namelen, char *out)
940 + if (!reiserfs_posixacl (inode->i_sb))
943 + memcpy (out, name, len);
948 +struct reiserfs_xattr_handler posix_acl_access_handler = {
949 + prefix: XATTR_NAME_ACL_ACCESS,
950 + get: posix_acl_access_get,
951 + set: posix_acl_access_set,
952 + del: posix_acl_access_del,
953 + list: posix_acl_access_list,
957 +posix_acl_default_get (struct inode *inode, const char *name,
958 + void *buffer, size_t size)
960 + if (strlen(name) != sizeof(XATTR_NAME_ACL_DEFAULT)-1)
962 + return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
966 +posix_acl_default_set(struct inode *inode, const char *name,
967 + const void *value, size_t size, int flags)
969 + if (strlen(name) != sizeof(XATTR_NAME_ACL_DEFAULT)-1)
971 + return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
975 +posix_acl_default_del (struct inode *inode, const char *name)
977 + struct posix_acl **acl = &inode->u.reiserfs_i.i_acl_default;
978 + if (strlen(name) != sizeof(XATTR_NAME_ACL_DEFAULT)-1)
980 + if (!IS_ERR (*acl) && *acl) {
981 + posix_acl_release (*acl);
982 + *acl = ERR_PTR (-ENODATA);
989 +posix_acl_default_list (struct inode *inode, const char *name, int namelen, char *out)
992 + if (!reiserfs_posixacl (inode->i_sb))
995 + memcpy (out, name, len);
1000 +struct reiserfs_xattr_handler posix_acl_default_handler = {
1001 + prefix: XATTR_NAME_ACL_DEFAULT,
1002 + get: posix_acl_default_get,
1003 + set: posix_acl_default_set,
1004 + del: posix_acl_default_del,
1005 + list: posix_acl_default_list,
1009 +reiserfs_xattr_posix_acl_init (void)
1012 + err = reiserfs_xattr_register_handler (&posix_acl_access_handler);
1014 + err = reiserfs_xattr_register_handler (&posix_acl_default_handler);
1019 +reiserfs_xattr_posix_acl_exit (void)
1022 + err = reiserfs_xattr_unregister_handler (&posix_acl_access_handler);
1024 + err = reiserfs_xattr_unregister_handler (&posix_acl_default_handler);
1027 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/fs/reiserfs/xattr_user.c linux-2.4.23.xattr/fs/reiserfs/xattr_user.c
1028 --- linux-2.4.23.datalogging+quota/fs/reiserfs/xattr_user.c 2003-12-11 13:00:09.967877312 -0500
1029 +++ linux-2.4.23.xattr/fs/reiserfs/xattr_user.c 2003-12-11 13:00:17.439741416 -0500
1031 #include <linux/reiserfs_xattr.h>
1032 #include <asm/uaccess.h>
1034 +#ifdef CONFIG_REISERFS_FS_POSIX_ACL
1035 +# include <linux/reiserfs_acl.h>
1038 #define XATTR_USER_PREFIX "user."
1041 @@ -20,7 +24,7 @@ user_get (struct inode *inode, const cha
1042 if (!reiserfs_xattrs_user (inode->i_sb))
1045 - error = permission (inode, MAY_READ);
1046 + error = reiserfs_permission_locked (inode, MAY_READ);
1050 @@ -44,7 +48,7 @@ user_set (struct inode *inode, const cha
1051 (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX))
1054 - error = permission (inode, MAY_WRITE);
1055 + error = reiserfs_permission_locked (inode, MAY_WRITE);
1059 @@ -66,7 +70,7 @@ user_del (struct inode *inode, const cha
1060 (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX))
1063 - error = permission (inode, MAY_WRITE);
1064 + error = reiserfs_permission_locked (inode, MAY_WRITE);
1068 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/include/linux/reiserfs_acl.h linux-2.4.23.xattr/include/linux/reiserfs_acl.h
1069 --- linux-2.4.23.datalogging+quota/include/linux/reiserfs_acl.h 1969-12-31 19:00:00.000000000 -0500
1070 +++ linux-2.4.23.xattr/include/linux/reiserfs_acl.h 2003-12-11 13:02:54.070929856 -0500
1072 +#include <linux/init.h>
1073 +#include <linux/posix_acl.h>
1074 +#include <linux/xattr_acl.h>
1076 +#define REISERFS_ACL_VERSION 0x0001
1082 +} reiserfs_acl_entry;
1087 +} reiserfs_acl_entry_short;
1091 +} reiserfs_acl_header;
1093 +static inline size_t reiserfs_acl_size(int count)
1096 + return sizeof(reiserfs_acl_header) +
1097 + count * sizeof(reiserfs_acl_entry_short);
1099 + return sizeof(reiserfs_acl_header) +
1100 + 4 * sizeof(reiserfs_acl_entry_short) +
1101 + (count - 4) * sizeof(reiserfs_acl_entry);
1105 +static inline int reiserfs_acl_count(size_t size)
1108 + size -= sizeof(reiserfs_acl_header);
1109 + s = size - 4 * sizeof(reiserfs_acl_entry_short);
1111 + if (size % sizeof(reiserfs_acl_entry_short))
1113 + return size / sizeof(reiserfs_acl_entry_short);
1115 + if (s % sizeof(reiserfs_acl_entry))
1117 + return s / sizeof(reiserfs_acl_entry) + 4;
1122 +#ifdef CONFIG_REISERFS_FS_POSIX_ACL
1123 +struct posix_acl * reiserfs_get_acl(struct inode *inode, int type);
1124 +int reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl);
1125 +int reiserfs_permission (struct inode *inode, int mask);
1126 +int reiserfs_permission_locked (struct inode *inode, int mask);
1127 +int reiserfs_acl_chmod (struct inode *inode);
1128 +int reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode);
1129 +int reiserfs_cache_default_acl (struct inode *dir);
1130 +extern int reiserfs_xattr_posix_acl_init (void) __init;
1131 +extern int reiserfs_xattr_posix_acl_exit (void);
1134 +#define reiserfs_permission NULL
1135 +#define reiserfs_set_acl NULL
1136 +#define reiserfs_get_acl NULL
1137 +#define reiserfs_cache_default_acl(inode) 0
1140 +reiserfs_xattr_posix_acl_init (void)
1146 +reiserfs_xattr_posix_acl_exit (void)
1152 +reiserfs_acl_chmod (struct inode *inode)
1158 +reiserfs_inherit_default_acl (const struct inode *dir, struct dentry *dentry, struct inode *inode)
1164 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/include/linux/reiserfs_fs_i.h linux-2.4.23.xattr/include/linux/reiserfs_fs_i.h
1165 --- linux-2.4.23.datalogging+quota/include/linux/reiserfs_fs_i.h 2003-12-11 13:00:09.969877008 -0500
1166 +++ linux-2.4.23.xattr/include/linux/reiserfs_fs_i.h 2003-12-11 13:02:51.667295264 -0500
1167 @@ -65,6 +65,9 @@ struct reiserfs_inode_info {
1169 unsigned long i_tail_trans_id;
1170 struct reiserfs_journal_list *i_tail_jl;
1172 + struct posix_acl *i_acl_access;
1173 + struct posix_acl *i_acl_default;
1177 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/include/linux/reiserfs_fs_sb.h linux-2.4.23.xattr/include/linux/reiserfs_fs_sb.h
1178 --- linux-2.4.23.datalogging+quota/include/linux/reiserfs_fs_sb.h 2003-12-11 13:00:09.970876856 -0500
1179 +++ linux-2.4.23.xattr/include/linux/reiserfs_fs_sb.h 2003-12-11 13:02:51.689291920 -0500
1180 @@ -492,6 +492,7 @@ enum {
1183 REISERFS_XATTRS_USER,
1184 + REISERFS_POSIXACL,
1187 #define reiserfs_r5_hash(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << FORCE_R5_HASH))
1188 @@ -515,7 +516,8 @@ enum {
1189 #define convert_reiserfs(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_CONVERT))
1190 #define reiserfs_xattrs(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_XATTRS))
1191 #define reiserfs_xattrs_user(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_XATTRS_USER))
1192 -#define reiserfs_xattrs_optional(s) reiserfs_xattrs_user(s)
1193 +#define reiserfs_xattrs_optional(s) (reiserfs_xattrs_user(s) || reiserfs_posixacl(s))
1194 +#define reiserfs_posixacl(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_POSIXACL))
1197 void reiserfs_file_buffer (struct buffer_head * bh, int list);
1198 diff -ruNp -X ../dontdiff linux-2.4.23.datalogging+quota/include/linux/reiserfs_xattr.h linux-2.4.23.xattr/include/linux/reiserfs_xattr.h
1199 --- linux-2.4.23.datalogging+quota/include/linux/reiserfs_xattr.h 2003-12-11 13:00:09.970876856 -0500
1200 +++ linux-2.4.23.xattr/include/linux/reiserfs_xattr.h 2003-12-11 13:02:54.072929552 -0500
1201 @@ -73,6 +73,7 @@ reiserfs_read_unlock_xattrs(struct super
1203 reiserfs_xattr_init (struct super_block *s, int mount_flags)
1205 + s->s_flags = (s->s_flags & ~MS_POSIXACL); /* to be sure */