2 fs/ext3/ext3-exports.c | 13
7 fs/ext3/xattr.c | 1242 +++++++++++++++++++++++++++++++++++++++++++++
8 include/linux/ext3_fs.h | 46 -
9 include/linux/ext3_jbd.h | 8
10 include/linux/ext3_xattr.h | 155 +++++
11 include/linux/xattr.h | 15
12 11 files changed, 1496 insertions(+), 52 deletions(-)
14 --- linux-2.4.18-p4smp/fs/ext3/ialloc.c~linux-2.4.18ea-0.8.26 2003-07-20 17:12:43.000000000 -0600
15 +++ linux-2.4.18-p4smp-braam/fs/ext3/ialloc.c 2003-07-21 22:49:05.000000000 -0600
17 #include <linux/jbd.h>
18 #include <linux/ext3_fs.h>
19 #include <linux/ext3_jbd.h>
20 +#include <linux/ext3_xattr.h>
21 #include <linux/stat.h>
22 #include <linux/string.h>
23 #include <linux/locks.h>
24 @@ -216,6 +217,7 @@ void ext3_free_inode (handle_t *handle,
25 * as writing the quota to disk may need the lock as well.
28 + ext3_xattr_drop_inode(handle, inode);
29 DQUOT_FREE_INODE(inode);
32 --- linux-2.4.18-p4smp/fs/ext3/inode.c~linux-2.4.18ea-0.8.26 2003-07-20 17:12:43.000000000 -0600
33 +++ linux-2.4.18-p4smp-braam/fs/ext3/inode.c 2003-07-21 22:49:05.000000000 -0600
36 #undef SEARCH_FROM_ZERO
39 + * Test whether an inode is a fast symlink.
41 +static inline int ext3_inode_is_fast_symlink(struct inode *inode)
43 + int ea_blocks = EXT3_I(inode)->i_file_acl ?
44 + (inode->i_sb->s_blocksize >> 9) : 0;
46 + return (S_ISLNK(inode->i_mode) &&
47 + inode->i_blocks - ea_blocks == 0);
50 /* The ext3 forget function must perform a revoke if we are freeing data
51 * which has been journaled. Metadata (eg. indirect blocks) must be
52 * revoked in all cases.
54 * still needs to be revoked.
57 -static int ext3_forget(handle_t *handle, int is_metadata,
58 +int ext3_forget(handle_t *handle, int is_metadata,
59 struct inode *inode, struct buffer_head *bh,
62 @@ -164,9 +176,7 @@ void ext3_delete_inode (struct inode * i
66 - if (is_bad_inode(inode) ||
67 - inode->i_ino == EXT3_ACL_IDX_INO ||
68 - inode->i_ino == EXT3_ACL_DATA_INO)
69 + if (is_bad_inode(inode))
73 @@ -1877,6 +1887,8 @@ void ext3_truncate(struct inode * inode)
74 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
75 S_ISLNK(inode->i_mode)))
77 + if (ext3_inode_is_fast_symlink(inode))
79 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
82 @@ -2038,8 +2050,6 @@ int ext3_get_inode_loc (struct inode *in
83 struct ext3_group_desc * gdp;
85 if ((inode->i_ino != EXT3_ROOT_INO &&
86 - inode->i_ino != EXT3_ACL_IDX_INO &&
87 - inode->i_ino != EXT3_ACL_DATA_INO &&
88 inode->i_ino != EXT3_JOURNAL_INO &&
89 inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
90 inode->i_ino > le32_to_cpu(
91 @@ -2166,10 +2176,7 @@ void ext3_read_inode(struct inode * inod
95 - if (inode->i_ino == EXT3_ACL_IDX_INO ||
96 - inode->i_ino == EXT3_ACL_DATA_INO)
97 - /* Nothing to do */ ;
98 - else if (S_ISREG(inode->i_mode)) {
99 + if (S_ISREG(inode->i_mode)) {
100 inode->i_op = &ext3_file_inode_operations;
101 inode->i_fop = &ext3_file_operations;
102 inode->i_mapping->a_ops = &ext3_aops;
103 @@ -2177,7 +2184,7 @@ void ext3_read_inode(struct inode * inod
104 inode->i_op = &ext3_dir_inode_operations;
105 inode->i_fop = &ext3_dir_operations;
106 } else if (S_ISLNK(inode->i_mode)) {
107 - if (!inode->i_blocks)
108 + if (ext3_inode_is_fast_symlink(inode))
109 inode->i_op = &ext3_fast_symlink_inode_operations;
111 inode->i_op = &page_symlink_inode_operations;
112 --- linux-2.4.18-p4smp/fs/ext3/namei.c~linux-2.4.18ea-0.8.26 2003-07-21 22:29:27.000000000 -0600
113 +++ linux-2.4.18-p4smp-braam/fs/ext3/namei.c 2003-07-21 22:49:05.000000000 -0600
115 #include <linux/sched.h>
116 #include <linux/ext3_fs.h>
117 #include <linux/ext3_jbd.h>
118 +#include <linux/ext3_xattr.h>
119 #include <linux/fcntl.h>
120 #include <linux/stat.h>
121 #include <linux/string.h>
122 @@ -1183,6 +1184,7 @@ static int ext3_add_nondir(handle_t *han
123 d_instantiate(dentry, inode);
126 + ext3_xattr_drop_inode(handle, inode);
127 ext3_dec_count(handle, inode);
130 @@ -1268,15 +1270,14 @@ static int ext3_mkdir(struct inode * dir
134 - inode = ext3_new_inode (handle, dir, S_IFDIR);
135 + inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
136 err = PTR_ERR(inode);
140 inode->i_op = &ext3_dir_inode_operations;
141 inode->i_fop = &ext3_dir_operations;
142 - inode->i_size = inode->u.ext3_i.i_disksize = inode->i_sb->s_blocksize;
143 - inode->i_blocks = 0;
144 + inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
145 dir_block = ext3_bread (handle, inode, 0, 1, &err);
147 inode->i_nlink--; /* is this nlink == 0? */
148 @@ -1303,9 +1304,6 @@ static int ext3_mkdir(struct inode * dir
149 BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
150 ext3_journal_dirty_metadata(handle, dir_block);
152 - inode->i_mode = S_IFDIR | mode;
153 - if (dir->i_mode & S_ISGID)
154 - inode->i_mode |= S_ISGID;
155 ext3_mark_inode_dirty(handle, inode);
156 err = ext3_add_entry (handle, dentry, inode);
158 @@ -1671,7 +1669,7 @@ static int ext3_symlink (struct inode *
162 - if (l > sizeof (inode->u.ext3_i.i_data)) {
163 + if (l > sizeof(EXT3_I(inode)->i_data)) {
164 inode->i_op = &page_symlink_inode_operations;
165 inode->i_mapping->a_ops = &ext3_aops;
167 --- linux-2.4.18-p4smp/fs/ext3/super.c~linux-2.4.18ea-0.8.26 2003-07-21 22:29:27.000000000 -0600
168 +++ linux-2.4.18-p4smp-braam/fs/ext3/super.c 2003-07-21 22:50:28.000000000 -0600
170 #include <linux/jbd.h>
171 #include <linux/ext3_fs.h>
172 #include <linux/ext3_jbd.h>
173 +#include <linux/ext3_xattr.h>
174 #include <linux/slab.h>
175 #include <linux/init.h>
176 #include <linux/locks.h>
177 @@ -406,6 +407,7 @@ void ext3_put_super (struct super_block
178 kdev_t j_dev = sbi->s_journal->j_dev;
181 + ext3_xattr_put_super(sb);
182 journal_destroy(sbi->s_journal);
183 if (!(sb->s_flags & MS_RDONLY)) {
184 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
185 @@ -1749,17 +1751,27 @@ int ext3_statfs (struct super_block * sb
187 static DECLARE_FSTYPE_DEV(ext3_fs_type, "ext3", ext3_read_super);
189 -static int __init init_ext3_fs(void)
190 +static void exit_ext3_fs(void)
192 - return register_filesystem(&ext3_fs_type);
193 + unregister_filesystem(&ext3_fs_type);
194 + exit_ext3_xattr_user();
198 -static void __exit exit_ext3_fs(void)
199 +static int __init init_ext3_fs(void)
201 - unregister_filesystem(&ext3_fs_type);
202 + int error = init_ext3_xattr();
204 + error = init_ext3_xattr_user();
206 + error = register_filesystem(&ext3_fs_type);
214 -EXPORT_SYMBOL(ext3_bread);
216 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
217 MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
218 --- /dev/null 2003-01-30 03:24:37.000000000 -0700
219 +++ linux-2.4.18-p4smp-braam/fs/ext3/ext3-exports.c 2003-07-21 22:49:05.000000000 -0600
221 +#include <linux/config.h>
222 +#include <linux/module.h>
223 +#include <linux/ext3_fs.h>
224 +#include <linux/ext3_jbd.h>
225 +#include <linux/ext3_xattr.h>
227 +EXPORT_SYMBOL(ext3_force_commit);
228 +EXPORT_SYMBOL(ext3_bread);
229 +EXPORT_SYMBOL(ext3_xattr_register);
230 +EXPORT_SYMBOL(ext3_xattr_unregister);
231 +EXPORT_SYMBOL(ext3_xattr_get);
232 +EXPORT_SYMBOL(ext3_xattr_list);
233 +EXPORT_SYMBOL(ext3_xattr_set);
234 --- /dev/null 2003-01-30 03:24:37.000000000 -0700
235 +++ linux-2.4.18-p4smp-braam/fs/ext3/xattr.c 2003-07-21 22:50:40.000000000 -0600
238 + * linux/fs/ext3/xattr.c
240 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
242 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
243 + * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
244 + * Extended attributes for symlinks and special files added per
245 + * suggestion of Luka Renko <luka.renko@hermes.si>.
249 + * Extended attributes are stored on disk blocks allocated outside of
250 + * any inode. The i_file_acl field is then made to point to this allocated
251 + * block. If all extended attributes of an inode are identical, these
252 + * inodes may share the same extended attribute block. Such situations
253 + * are automatically detected by keeping a cache of recent attribute block
254 + * numbers and hashes over the block's contents in memory.
257 + * Extended attribute block layout:
259 + * +------------------+
262 + * | entry 2 | | growing downwards
264 + * | four null bytes |
267 + * | value 3 | | growing upwards
269 + * +------------------+
271 + * The block header is followed by multiple entry descriptors. These entry
272 + * descriptors are variable in size, and alligned to EXT3_XATTR_PAD
273 + * byte boundaries. The entry descriptors are sorted by attribute name,
274 + * so that two extended attribute blocks can be compared efficiently.
276 + * Attribute values are aligned to the end of the block, stored in
277 + * no specific order. They are also padded to EXT3_XATTR_PAD byte
278 + * boundaries. No additional gaps are left between them.
282 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
283 + * the xattr inode operations are called, so we are guaranteed that only one
284 + * processes accesses extended attributes of an inode at any time.
286 + * For writing we also grab the ext3_xattr_sem semaphore. This ensures that
287 + * only a single process is modifying an extended attribute block, even
288 + * if the block is shared among inodes.
290 + * Note for porting to 2.5
291 + * -----------------------
292 + * The BKL will no longer be held in the xattr inode operations.
295 +#include <linux/fs.h>
296 +#include <linux/locks.h>
297 +#include <linux/slab.h>
298 +#include <linux/ext3_jbd.h>
299 +#include <linux/ext3_fs.h>
300 +#include <linux/ext3_xattr.h>
301 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
302 +#include <linux/mbcache.h>
304 +#include <linux/quotaops.h>
305 +#include <asm/semaphore.h>
306 +#include <linux/compatmac.h>
307 +#include <linux/module.h>
309 +/* These symbols may be needed by a module. */
311 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
312 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
315 +#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data))
316 +#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr))
317 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
318 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
320 +#ifdef EXT3_XATTR_DEBUG
321 +# define ea_idebug(inode, f...) do { \
322 + printk(KERN_DEBUG "inode %s:%ld: ", \
323 + kdevname(inode->i_dev), inode->i_ino); \
327 +# define ea_bdebug(bh, f...) do { \
328 + printk(KERN_DEBUG "block %s:%ld: ", \
329 + kdevname(bh->b_dev), bh->b_blocknr); \
334 +# define ea_idebug(f...)
335 +# define ea_bdebug(f...)
338 +static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *,
339 + struct ext3_xattr_header *);
341 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
343 +static int ext3_xattr_cache_insert(struct buffer_head *);
344 +static struct buffer_head *ext3_xattr_cache_find(struct inode *,
345 + struct ext3_xattr_header *);
346 +static void ext3_xattr_cache_remove(struct buffer_head *);
347 +static void ext3_xattr_rehash(struct ext3_xattr_header *,
348 + struct ext3_xattr_entry *);
350 +static struct mb_cache *ext3_xattr_cache;
353 +# define ext3_xattr_cache_insert(bh) 0
354 +# define ext3_xattr_cache_find(inode, header) NULL
355 +# define ext3_xattr_cache_remove(bh) do {} while(0)
356 +# define ext3_xattr_rehash(header, entry) do {} while(0)
360 + * If a file system does not share extended attributes among inodes,
361 + * we should not need the ext3_xattr_sem semaphore. However, the
362 + * filesystem may still contain shared blocks, so we always take
366 +DECLARE_MUTEX(ext3_xattr_sem);
369 +ext3_xattr_lock(void)
371 + down(&ext3_xattr_sem);
375 +ext3_xattr_unlock(void)
377 + up(&ext3_xattr_sem);
381 +ext3_xattr_new_block(handle_t *handle, struct inode *inode,
382 + int * errp, int force)
384 + struct super_block *sb = inode->i_sb;
385 + int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
386 + EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb);
388 + /* How can we enforce the allocation? */
389 + int block = ext3_new_block(handle, inode, goal, 0, 0, errp);
392 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
398 +ext3_xattr_quota_alloc(struct inode *inode, int force)
400 + /* How can we enforce the allocation? */
402 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
404 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
406 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
414 +ext3_xattr_quota_free(struct inode *inode)
416 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
417 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
421 +ext3_xattr_free_block(handle_t *handle, struct inode * inode,
422 + unsigned long block)
424 + ext3_free_blocks(handle, inode, block, 1);
425 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
429 +# define ext3_xattr_quota_free(inode) \
430 + DQUOT_FREE_BLOCK(inode, 1)
431 +# define ext3_xattr_free_block(handle, inode, block) \
432 + ext3_free_blocks(handle, inode, block, 1)
435 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
437 +static inline struct buffer_head *
438 +sb_bread(struct super_block *sb, int block)
440 + return bread(sb->s_dev, block, sb->s_blocksize);
443 +static inline struct buffer_head *
444 +sb_getblk(struct super_block *sb, int block)
446 + return getblk(sb->s_dev, block, sb->s_blocksize);
451 +struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
452 +rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
455 +ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
457 + int error = -EINVAL;
459 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
460 + write_lock(&ext3_handler_lock);
461 + if (!ext3_xattr_handlers[name_index-1]) {
462 + ext3_xattr_handlers[name_index-1] = handler;
465 + write_unlock(&ext3_handler_lock);
471 +ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
473 + if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
474 + write_lock(&ext3_handler_lock);
475 + ext3_xattr_handlers[name_index-1] = NULL;
476 + write_unlock(&ext3_handler_lock);
480 +static inline const char *
481 +strcmp_prefix(const char *a, const char *a_prefix)
483 + while (*a_prefix && *a == *a_prefix) {
487 + return *a_prefix ? NULL : a;
491 + * Decode the extended attribute name, and translate it into
492 + * the name_index and name suffix.
494 +static inline struct ext3_xattr_handler *
495 +ext3_xattr_resolve_name(const char **name)
497 + struct ext3_xattr_handler *handler = NULL;
502 + read_lock(&ext3_handler_lock);
503 + for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
504 + if (ext3_xattr_handlers[i]) {
505 + const char *n = strcmp_prefix(*name,
506 + ext3_xattr_handlers[i]->prefix);
508 + handler = ext3_xattr_handlers[i];
514 + read_unlock(&ext3_handler_lock);
518 +static inline struct ext3_xattr_handler *
519 +ext3_xattr_handler(int name_index)
521 + struct ext3_xattr_handler *handler = NULL;
522 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
523 + read_lock(&ext3_handler_lock);
524 + handler = ext3_xattr_handlers[name_index-1];
525 + read_unlock(&ext3_handler_lock);
531 + * Inode operation getxattr()
533 + * dentry->d_inode->i_sem down
534 + * BKL held [before 2.5.x]
537 +ext3_getxattr(struct dentry *dentry, const char *name,
538 + void *buffer, size_t size)
540 + struct ext3_xattr_handler *handler;
541 + struct inode *inode = dentry->d_inode;
543 + handler = ext3_xattr_resolve_name(&name);
546 + return handler->get(inode, name, buffer, size);
550 + * Inode operation listxattr()
552 + * dentry->d_inode->i_sem down
553 + * BKL held [before 2.5.x]
556 +ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
558 + return ext3_xattr_list(dentry->d_inode, buffer, size);
562 + * Inode operation setxattr()
564 + * dentry->d_inode->i_sem down
565 + * BKL held [before 2.5.x]
568 +ext3_setxattr(struct dentry *dentry, const char *name,
569 + void *value, size_t size, int flags)
571 + struct ext3_xattr_handler *handler;
572 + struct inode *inode = dentry->d_inode;
575 + value = ""; /* empty EA, do not remove */
576 + handler = ext3_xattr_resolve_name(&name);
579 + return handler->set(inode, name, value, size, flags);
583 + * Inode operation removexattr()
585 + * dentry->d_inode->i_sem down
586 + * BKL held [before 2.5.x]
589 +ext3_removexattr(struct dentry *dentry, const char *name)
591 + struct ext3_xattr_handler *handler;
592 + struct inode *inode = dentry->d_inode;
594 + handler = ext3_xattr_resolve_name(&name);
597 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
603 + * Copy an extended attribute into the buffer
604 + * provided, or compute the buffer size required.
605 + * Buffer is NULL to compute the size of the buffer required.
607 + * Returns a negative error number on failure, or the number of bytes
608 + * used / required on success.
611 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
612 + void *buffer, size_t buffer_size)
614 + struct buffer_head *bh = NULL;
615 + struct ext3_xattr_entry *entry;
616 + unsigned int block, size;
618 + int name_len, error;
620 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
621 + name_index, name, buffer, (long)buffer_size);
625 + if (!EXT3_I(inode)->i_file_acl)
627 + block = EXT3_I(inode)->i_file_acl;
628 + ea_idebug(inode, "reading block %d", block);
629 + bh = sb_bread(inode->i_sb, block);
632 + ea_bdebug(bh, "b_count=%d, refcount=%d",
633 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
634 + end = bh->b_data + bh->b_size;
635 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
636 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
637 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_get",
638 + "inode %ld: bad block %d", inode->i_ino, block);
642 + /* find named attribute */
643 + name_len = strlen(name);
646 + if (name_len > 255)
648 + entry = FIRST_ENTRY(bh);
649 + while (!IS_LAST_ENTRY(entry)) {
650 + struct ext3_xattr_entry *next =
651 + EXT3_XATTR_NEXT(entry);
652 + if ((char *)next >= end)
654 + if (name_index == entry->e_name_index &&
655 + name_len == entry->e_name_len &&
656 + memcmp(name, entry->e_name, name_len) == 0)
660 + /* Check the remaining name entries */
661 + while (!IS_LAST_ENTRY(entry)) {
662 + struct ext3_xattr_entry *next =
663 + EXT3_XATTR_NEXT(entry);
664 + if ((char *)next >= end)
668 + if (ext3_xattr_cache_insert(bh))
669 + ea_idebug(inode, "cache insert failed");
673 + /* check the buffer size */
674 + if (entry->e_value_block != 0)
676 + size = le32_to_cpu(entry->e_value_size);
677 + if (size > inode->i_sb->s_blocksize ||
678 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
681 + if (ext3_xattr_cache_insert(bh))
682 + ea_idebug(inode, "cache insert failed");
685 + if (size > buffer_size)
687 + /* return value of attribute */
688 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
700 + * ext3_xattr_list()
702 + * Copy a list of attribute names into the buffer
703 + * provided, or compute the buffer size required.
704 + * Buffer is NULL to compute the size of the buffer required.
706 + * Returns a negative error number on failure, or the number of bytes
707 + * used / required on success.
710 +ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
712 + struct buffer_head *bh = NULL;
713 + struct ext3_xattr_entry *entry;
714 + unsigned int block, size = 0;
718 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
719 + buffer, (long)buffer_size);
721 + if (!EXT3_I(inode)->i_file_acl)
723 + block = EXT3_I(inode)->i_file_acl;
724 + ea_idebug(inode, "reading block %d", block);
725 + bh = sb_bread(inode->i_sb, block);
728 + ea_bdebug(bh, "b_count=%d, refcount=%d",
729 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
730 + end = bh->b_data + bh->b_size;
731 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
732 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
733 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_list",
734 + "inode %ld: bad block %d", inode->i_ino, block);
738 + /* compute the size required for the list of attribute names */
739 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
740 + entry = EXT3_XATTR_NEXT(entry)) {
741 + struct ext3_xattr_handler *handler;
742 + struct ext3_xattr_entry *next =
743 + EXT3_XATTR_NEXT(entry);
744 + if ((char *)next >= end)
747 + handler = ext3_xattr_handler(entry->e_name_index);
749 + size += handler->list(NULL, inode, entry->e_name,
750 + entry->e_name_len) + 1;
754 + if (ext3_xattr_cache_insert(bh))
755 + ea_idebug(inode, "cache insert failed");
761 + if (size > buffer_size)
765 + /* list the attribute names */
767 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
768 + entry = EXT3_XATTR_NEXT(entry)) {
769 + struct ext3_xattr_handler *handler;
771 + handler = ext3_xattr_handler(entry->e_name_index);
773 + buf += handler->list(buf, inode, entry->e_name,
774 + entry->e_name_len);
787 + * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is
790 +static void ext3_xattr_update_super_block(handle_t *handle,
791 + struct super_block *sb)
793 + if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
797 + ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
798 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
799 + EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR;
801 + EXT3_SB(sb)->s_es->s_feature_compat |=
802 + cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
804 + ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
811 + * Create, replace or remove an extended attribute for this inode. Buffer
812 + * is NULL to remove an existing extended attribute, and non-NULL to
813 + * either replace an existing extended attribute, or create a new extended
814 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
815 + * specify that an extended attribute must exist and must not exist
816 + * previous to the call, respectively.
818 + * Returns 0, or a negative error number on failure.
821 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
822 + const char *name, void *value, size_t value_len, int flags)
824 + struct super_block *sb = inode->i_sb;
825 + struct buffer_head *bh = NULL;
826 + struct ext3_xattr_header *header = NULL;
827 + struct ext3_xattr_entry *here, *last;
828 + unsigned int name_len;
829 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
833 + * header -- Points either into bh, or to a temporarily
834 + * allocated buffer.
835 + * here -- The named entry found, or the place for inserting, within
836 + * the block pointed to by header.
837 + * last -- Points right after the last named entry within the block
838 + * pointed to by header.
839 + * min_offs -- The offset of the first value (values are aligned
840 + * towards the end of the block).
841 + * end -- Points right after the block pointed to by header.
844 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
845 + name_index, name, value, (long)value_len);
847 + if (IS_RDONLY(inode))
849 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
855 + name_len = strlen(name);
856 + if (name_len > 255 || value_len > sb->s_blocksize)
860 + if (EXT3_I(inode)->i_file_acl) {
861 + /* The inode already has an extended attribute block. */
862 + int block = EXT3_I(inode)->i_file_acl;
864 + bh = sb_bread(sb, block);
868 + ea_bdebug(bh, "b_count=%d, refcount=%d",
869 + atomic_read(&(bh->b_count)),
870 + le32_to_cpu(HDR(bh)->h_refcount));
872 + end = bh->b_data + bh->b_size;
873 + if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
874 + header->h_blocks != cpu_to_le32(1)) {
875 +bad_block: ext3_error(sb, "ext3_xattr_set",
876 + "inode %ld: bad block %d", inode->i_ino, block);
880 + /* Find the named attribute. */
881 + here = FIRST_ENTRY(bh);
882 + while (!IS_LAST_ENTRY(here)) {
883 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here);
884 + if ((char *)next >= end)
886 + if (!here->e_value_block && here->e_value_size) {
887 + int offs = le16_to_cpu(here->e_value_offs);
888 + if (offs < min_offs)
891 + not_found = name_index - here->e_name_index;
893 + not_found = name_len - here->e_name_len;
895 + not_found = memcmp(name, here->e_name,name_len);
896 + if (not_found <= 0)
901 + /* We still need to compute min_offs and last. */
902 + while (!IS_LAST_ENTRY(last)) {
903 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last);
904 + if ((char *)next >= end)
906 + if (!last->e_value_block && last->e_value_size) {
907 + int offs = le16_to_cpu(last->e_value_offs);
908 + if (offs < min_offs)
914 + /* Check whether we have enough space left. */
915 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
917 + /* We will use a new extended attribute block. */
918 + free = sb->s_blocksize -
919 + sizeof(struct ext3_xattr_header) - sizeof(__u32);
920 + here = last = NULL; /* avoid gcc uninitialized warning. */
924 + /* Request to remove a nonexistent attribute? */
926 + if (flags & XATTR_REPLACE)
932 + free -= EXT3_XATTR_LEN(name_len);
934 + /* Request to create an existing attribute? */
936 + if (flags & XATTR_CREATE)
938 + if (!here->e_value_block && here->e_value_size) {
939 + unsigned int size = le32_to_cpu(here->e_value_size);
941 + if (le16_to_cpu(here->e_value_offs) + size >
942 + sb->s_blocksize || size > sb->s_blocksize)
944 + free += EXT3_XATTR_SIZE(size);
947 + free -= EXT3_XATTR_SIZE(value_len);
952 + /* Here we know that we can set the new attribute. */
955 + if (header->h_refcount == cpu_to_le32(1)) {
956 + ea_bdebug(bh, "modifying in-place");
957 + ext3_xattr_cache_remove(bh);
958 + error = ext3_journal_get_write_access(handle, bh);
964 + ea_bdebug(bh, "cloning");
965 + header = kmalloc(bh->b_size, GFP_KERNEL);
967 + if (header == NULL)
969 + memcpy(header, HDR(bh), bh->b_size);
970 + header->h_refcount = cpu_to_le32(1);
971 + offset = (char *)header - bh->b_data;
972 + here = ENTRY((char *)here + offset);
973 + last = ENTRY((char *)last + offset);
976 + /* Allocate a buffer where we construct the new block. */
977 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
979 + if (header == NULL)
981 + memset(header, 0, sb->s_blocksize);
982 + end = (char *)header + sb->s_blocksize;
983 + header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
984 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
985 + last = here = ENTRY(header+1);
989 + /* Insert the new name. */
990 + int size = EXT3_XATTR_LEN(name_len);
991 + int rest = (char *)last - (char *)here;
992 + memmove((char *)here + size, here, rest);
993 + memset(here, 0, size);
994 + here->e_name_index = name_index;
995 + here->e_name_len = name_len;
996 + memcpy(here->e_name, name, name_len);
998 + /* Remove the old value. */
999 + if (!here->e_value_block && here->e_value_size) {
1000 + char *first_val = (char *)header + min_offs;
1001 + int offs = le16_to_cpu(here->e_value_offs);
1002 + char *val = (char *)header + offs;
1003 + size_t size = EXT3_XATTR_SIZE(
1004 + le32_to_cpu(here->e_value_size));
1005 + memmove(first_val + size, first_val, val - first_val);
1006 + memset(first_val, 0, size);
1007 + here->e_value_offs = 0;
1010 + /* Adjust all value offsets. */
1011 + last = ENTRY(header+1);
1012 + while (!IS_LAST_ENTRY(last)) {
1013 + int o = le16_to_cpu(last->e_value_offs);
1014 + if (!last->e_value_block && o < offs)
1015 + last->e_value_offs =
1016 + cpu_to_le16(o + size);
1017 + last = EXT3_XATTR_NEXT(last);
1020 + if (value == NULL) {
1021 + /* Remove this attribute. */
1022 + if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) {
1023 + /* This block is now empty. */
1024 + error = ext3_xattr_set2(handle, inode, bh,NULL);
1027 + /* Remove the old name. */
1028 + int size = EXT3_XATTR_LEN(name_len);
1029 + last = ENTRY((char *)last - size);
1030 + memmove(here, (char*)here + size,
1031 + (char*)last - (char*)here);
1032 + memset(last, 0, size);
1037 + if (value != NULL) {
1038 + /* Insert the new value. */
1039 + here->e_value_size = cpu_to_le32(value_len);
1041 + size_t size = EXT3_XATTR_SIZE(value_len);
1042 + char *val = (char *)header + min_offs - size;
1043 + here->e_value_offs =
1044 + cpu_to_le16((char *)val - (char *)header);
1045 + memset(val + size - EXT3_XATTR_PAD, 0,
1046 + EXT3_XATTR_PAD); /* Clear the pad bytes. */
1047 + memcpy(val, value, value_len);
1050 + ext3_xattr_rehash(header, here);
1052 + error = ext3_xattr_set2(handle, inode, bh, header);
1056 + if (!(bh && header == HDR(bh)))
1058 + ext3_xattr_unlock();
1064 + * Second half of ext3_xattr_set(): Update the file system.
1067 +ext3_xattr_set2(handle_t *handle, struct inode *inode,
1068 + struct buffer_head *old_bh, struct ext3_xattr_header *header)
1070 + struct super_block *sb = inode->i_sb;
1071 + struct buffer_head *new_bh = NULL;
1075 + new_bh = ext3_xattr_cache_find(inode, header);
1078 + * We found an identical block in the cache.
1079 + * The old block will be released after updating
1082 + ea_bdebug(old_bh, "reusing block %ld",
1083 + new_bh->b_blocknr);
1086 + if (ext3_xattr_quota_alloc(inode, 1))
1089 + error = ext3_journal_get_write_access(handle, new_bh);
1092 + HDR(new_bh)->h_refcount = cpu_to_le32(
1093 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
1094 + ea_bdebug(new_bh, "refcount now=%d",
1095 + le32_to_cpu(HDR(new_bh)->h_refcount));
1096 + } else if (old_bh && header == HDR(old_bh)) {
1097 + /* Keep this block. */
1099 + (void)ext3_xattr_cache_insert(new_bh);
1101 + /* We need to allocate a new block */
1102 + int force = EXT3_I(inode)->i_file_acl != 0;
1103 + int block = ext3_xattr_new_block(handle, inode,
1107 + ea_idebug(inode, "creating block %d", block);
1109 + new_bh = sb_getblk(sb, block);
1111 +getblk_failed: ext3_xattr_free_block(handle, inode, block);
1115 + lock_buffer(new_bh);
1116 + error = ext3_journal_get_create_access(handle, new_bh);
1118 + unlock_buffer(new_bh);
1119 + goto getblk_failed;
1121 + memcpy(new_bh->b_data, header, new_bh->b_size);
1122 + mark_buffer_uptodate(new_bh, 1);
1123 + unlock_buffer(new_bh);
1124 + (void)ext3_xattr_cache_insert(new_bh);
1125 + ext3_xattr_update_super_block(handle, sb);
1127 + error = ext3_journal_dirty_metadata(handle, new_bh);
1132 + /* Update the inode. */
1133 + EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
1134 + inode->i_ctime = CURRENT_TIME;
1135 + ext3_mark_inode_dirty(handle, inode);
1136 + if (IS_SYNC(inode))
1137 + handle->h_sync = 1;
1140 + if (old_bh && old_bh != new_bh) {
1142 + * If there was an old block, and we are not still using it,
1143 + * we now release the old block.
1145 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
1147 + error = ext3_journal_get_write_access(handle, old_bh);
1150 + if (refcount == 1) {
1151 + /* Free the old block. */
1152 + ea_bdebug(old_bh, "freeing");
1153 + ext3_xattr_free_block(handle, inode, old_bh->b_blocknr);
1155 + /* ext3_forget() calls bforget() for us, but we
1156 + let our caller release old_bh, so we need to
1157 + duplicate the handle before. */
1159 + ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr);
1161 + /* Decrement the refcount only. */
1163 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
1164 + ext3_xattr_quota_free(inode);
1165 + ext3_journal_dirty_metadata(handle, old_bh);
1166 + ea_bdebug(old_bh, "refcount now=%d", refcount);
1171 + if (old_bh != new_bh)
1178 + * ext3_xattr_drop_inode()
1180 + * Free extended attribute resources associated with this inode. This
1181 + * is called immediately before an inode is freed.
1184 +ext3_xattr_drop_inode(handle_t *handle, struct inode *inode)
1186 + struct buffer_head *bh;
1187 + unsigned int block = EXT3_I(inode)->i_file_acl;
1191 + ext3_xattr_lock();
1193 + bh = sb_bread(inode->i_sb, block);
1195 + ext3_error(inode->i_sb, "ext3_xattr_drop_inode",
1196 + "inode %ld: block %d read error", inode->i_ino, block);
1199 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
1200 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
1201 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1202 + ext3_error(inode->i_sb, "ext3_xattr_drop_inode",
1203 + "inode %ld: bad block %d", inode->i_ino, block);
1206 + ext3_journal_get_write_access(handle, bh);
1207 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
1208 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
1209 + ext3_xattr_cache_remove(bh);
1210 + ext3_xattr_free_block(handle, inode, block);
1211 + ext3_forget(handle, 1, inode, bh, block);
1214 + HDR(bh)->h_refcount = cpu_to_le32(
1215 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
1216 + ext3_journal_dirty_metadata(handle, bh);
1217 + if (IS_SYNC(inode))
1218 + handle->h_sync = 1;
1219 + ext3_xattr_quota_free(inode);
1221 + EXT3_I(inode)->i_file_acl = 0;
1225 + ext3_xattr_unlock();
1229 + * ext3_xattr_put_super()
1231 + * This is called when a file system is unmounted.
1234 +ext3_xattr_put_super(struct super_block *sb)
1236 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
1237 + mb_cache_shrink(ext3_xattr_cache, sb->s_dev);
1241 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
1244 + * ext3_xattr_cache_insert()
1246 + * Create a new entry in the extended attribute cache, and insert
1247 + * it unless such an entry is already in the cache.
1249 + * Returns 0, or a negative error number on failure.
1252 +ext3_xattr_cache_insert(struct buffer_head *bh)
1254 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
1255 + struct mb_cache_entry *ce;
1258 + ce = mb_cache_entry_alloc(ext3_xattr_cache);
1261 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
1263 + mb_cache_entry_free(ce);
1264 + if (error == -EBUSY) {
1265 + ea_bdebug(bh, "already in cache (%d cache entries)",
1266 + atomic_read(&ext3_xattr_cache->c_entry_count));
1270 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
1271 + atomic_read(&ext3_xattr_cache->c_entry_count));
1272 + mb_cache_entry_release(ce);
1278 + * ext3_xattr_cmp()
1280 + * Compare two extended attribute blocks for equality.
1282 + * Returns 0 if the blocks are equal, 1 if they differ, and
1283 + * a negative error number on errors.
1286 +ext3_xattr_cmp(struct ext3_xattr_header *header1,
1287 + struct ext3_xattr_header *header2)
1289 + struct ext3_xattr_entry *entry1, *entry2;
1291 + entry1 = ENTRY(header1+1);
1292 + entry2 = ENTRY(header2+1);
1293 + while (!IS_LAST_ENTRY(entry1)) {
1294 + if (IS_LAST_ENTRY(entry2))
1296 + if (entry1->e_hash != entry2->e_hash ||
1297 + entry1->e_name_len != entry2->e_name_len ||
1298 + entry1->e_value_size != entry2->e_value_size ||
1299 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1301 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1303 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1304 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1305 + le32_to_cpu(entry1->e_value_size)))
1308 + entry1 = EXT3_XATTR_NEXT(entry1);
1309 + entry2 = EXT3_XATTR_NEXT(entry2);
1311 + if (!IS_LAST_ENTRY(entry2))
1317 + * ext3_xattr_cache_find()
1319 + * Find an identical extended attribute block.
1321 + * Returns a pointer to the block found, or NULL if such a block was
1322 + * not found or an error occurred.
1324 +static struct buffer_head *
1325 +ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header)
1327 + __u32 hash = le32_to_cpu(header->h_hash);
1328 + struct mb_cache_entry *ce;
1330 + if (!header->h_hash)
1331 + return NULL; /* never share */
1332 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
1333 + ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash);
1335 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
1338 + ext3_error(inode->i_sb, "ext3_xattr_cache_find",
1339 + "inode %ld: block %ld read error",
1340 + inode->i_ino, ce->e_block);
1341 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
1342 + EXT3_XATTR_REFCOUNT_MAX) {
1343 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
1344 + le32_to_cpu(HDR(bh)->h_refcount),
1345 + EXT3_XATTR_REFCOUNT_MAX);
1346 + } else if (!ext3_xattr_cmp(header, HDR(bh))) {
1347 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
1348 + mb_cache_entry_release(ce);
1352 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
1358 + * ext3_xattr_cache_remove()
1360 + * Remove the cache entry of a block from the cache. Called when a
1361 + * block becomes invalid.
1364 +ext3_xattr_cache_remove(struct buffer_head *bh)
1366 + struct mb_cache_entry *ce;
1368 + ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr);
1370 + ea_bdebug(bh, "removing (%d cache entries remaining)",
1371 + atomic_read(&ext3_xattr_cache->c_entry_count)-1);
1372 + mb_cache_entry_free(ce);
1374 + ea_bdebug(bh, "no cache entry");
1377 +#define NAME_HASH_SHIFT 5
1378 +#define VALUE_HASH_SHIFT 16
1381 + * ext3_xattr_hash_entry()
1383 + * Compute the hash of an extended attribute.
1385 +static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
1386 + struct ext3_xattr_entry *entry)
1389 + char *name = entry->e_name;
1392 + for (n=0; n < entry->e_name_len; n++) {
1393 + hash = (hash << NAME_HASH_SHIFT) ^
1394 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
1398 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
1399 + __u32 *value = (__u32 *)((char *)header +
1400 + le16_to_cpu(entry->e_value_offs));
1401 + for (n = (le32_to_cpu(entry->e_value_size) +
1402 + EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
1403 + hash = (hash << VALUE_HASH_SHIFT) ^
1404 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
1405 + le32_to_cpu(*value++);
1408 + entry->e_hash = cpu_to_le32(hash);
1411 +#undef NAME_HASH_SHIFT
1412 +#undef VALUE_HASH_SHIFT
1414 +#define BLOCK_HASH_SHIFT 16
1417 + * ext3_xattr_rehash()
1419 + * Re-compute the extended attribute hash value after an entry has changed.
1421 +static void ext3_xattr_rehash(struct ext3_xattr_header *header,
1422 + struct ext3_xattr_entry *entry)
1424 + struct ext3_xattr_entry *here;
1427 + ext3_xattr_hash_entry(header, entry);
1428 + here = ENTRY(header+1);
1429 + while (!IS_LAST_ENTRY(here)) {
1430 + if (!here->e_hash) {
1431 + /* Block is not shared if an entry's hash value == 0 */
1435 + hash = (hash << BLOCK_HASH_SHIFT) ^
1436 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
1437 + le32_to_cpu(here->e_hash);
1438 + here = EXT3_XATTR_NEXT(here);
1440 + header->h_hash = cpu_to_le32(hash);
1443 +#undef BLOCK_HASH_SHIFT
1446 +init_ext3_xattr(void)
1448 + ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
1449 + sizeof(struct mb_cache_entry) +
1450 + sizeof(struct mb_cache_entry_index), 1, 61);
1451 + if (!ext3_xattr_cache)
1458 +exit_ext3_xattr(void)
1460 + if (ext3_xattr_cache)
1461 + mb_cache_destroy(ext3_xattr_cache);
1462 + ext3_xattr_cache = NULL;
1465 +#else /* CONFIG_EXT3_FS_XATTR_SHARING */
1468 +init_ext3_xattr(void)
1474 +exit_ext3_xattr(void)
1478 +#endif /* CONFIG_EXT3_FS_XATTR_SHARING */
1479 --- linux-2.4.18-p4smp/include/linux/ext3_fs.h~linux-2.4.18ea-0.8.26 2003-07-21 22:29:27.000000000 -0600
1480 +++ linux-2.4.18-p4smp-braam/include/linux/ext3_fs.h 2003-07-21 22:49:05.000000000 -0600
1483 #define EXT3_BAD_INO 1 /* Bad blocks inode */
1484 #define EXT3_ROOT_INO 2 /* Root inode */
1485 -#define EXT3_ACL_IDX_INO 3 /* ACL inode */
1486 -#define EXT3_ACL_DATA_INO 4 /* ACL inode */
1487 #define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
1488 #define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
1489 #define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
1492 # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
1494 -#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
1495 #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
1497 # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
1498 @@ -124,28 +121,6 @@
1504 -struct ext3_acl_header /* Header of Access Control Lists */
1507 - __u32 aclh_file_count;
1508 - __u32 aclh_acle_count;
1509 - __u32 aclh_first_acle;
1512 -struct ext3_acl_entry /* Access Control List Entry */
1515 - __u16 acle_perms; /* Access permissions */
1516 - __u16 acle_type; /* Type of entry */
1517 - __u16 acle_tag; /* User or group identity */
1519 - __u32 acle_next; /* Pointer on next entry for the */
1520 - /* same inode or on next free entry */
1524 * Structure of a blocks group descriptor
1526 struct ext3_group_desc
1527 @@ -513,7 +488,7 @@ struct ext3_super_block {
1528 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
1529 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
1531 -#define EXT3_FEATURE_COMPAT_SUPP 0
1532 +#define EXT3_FEATURE_COMPAT_SUPP EXT3_FEATURE_COMPAT_EXT_ATTR
1533 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
1534 EXT3_FEATURE_INCOMPAT_RECOVER)
1535 #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
1536 @@ -606,6 +581,24 @@ struct ext3_iloc
1537 unsigned long block_group;
1540 +/* Defined for extended attributes */
1541 +#define CONFIG_EXT3_FS_XATTR y
1543 +#define ENOATTR ENODATA /* No such attribute */
1546 +#define ENOTSUP EOPNOTSUPP /* Operation not supported */
1548 +#ifndef XATTR_NAME_MAX
1549 +#define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */
1550 +#define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */
1551 +#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
1553 +#ifndef XATTR_CREATE
1554 +#define XATTR_CREATE 1 /* set value, fail if attr already exists */
1555 +#define XATTR_REPLACE 2 /* set value, fail if attr does not exist */
1559 * Function prototypes
1561 @@ -647,6 +640,7 @@ extern void ext3_check_inodes_bitmap (st
1562 extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
1565 +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
1566 extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
1567 extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
1569 --- linux-2.4.18-p4smp/include/linux/ext3_jbd.h~linux-2.4.18ea-0.8.26 2003-07-21 22:29:27.000000000 -0600
1570 +++ linux-2.4.18-p4smp-braam/include/linux/ext3_jbd.h 2003-07-21 22:49:05.000000000 -0600
1573 #define EXT3_SINGLEDATA_TRANS_BLOCKS 8
1575 +/* Extended attributes may touch two data buffers, two bitmap buffers,
1576 + * and two group and summaries. */
1578 +#define EXT3_XATTR_TRANS_BLOCKS 8
1580 /* Define the minimum size for a transaction which modifies data. This
1581 * needs to take into account the fact that we may end up modifying two
1582 * quota files too (one for the group, one for the user quota). The
1583 * superblock only gets updated once, of course, so don't bother
1584 * counting that again for the quota updates. */
1586 -#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2)
1587 +#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \
1588 + EXT3_XATTR_TRANS_BLOCKS - 2)
1590 extern int ext3_writepage_trans_blocks(struct inode *inode);
1592 --- /dev/null 2003-01-30 03:24:37.000000000 -0700
1593 +++ linux-2.4.18-p4smp-braam/include/linux/ext3_xattr.h 2003-07-21 22:49:05.000000000 -0600
1596 + File: linux/ext3_xattr.h
1598 + On-disk format of extended attributes for the ext3 filesystem.
1600 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
1603 +#include <linux/config.h>
1604 +#include <linux/init.h>
1605 +#include <linux/xattr.h>
1607 +/* Magic value in attribute blocks */
1608 +#define EXT3_XATTR_MAGIC 0xEA020000
1610 +/* Maximum number of references to one attribute block */
1611 +#define EXT3_XATTR_REFCOUNT_MAX 1024
1614 +#define EXT3_XATTR_INDEX_MAX 10
1615 +#define EXT3_XATTR_INDEX_USER 1
1617 +struct ext3_xattr_header {
1618 + __u32 h_magic; /* magic number for identification */
1619 + __u32 h_refcount; /* reference count */
1620 + __u32 h_blocks; /* number of disk blocks used */
1621 + __u32 h_hash; /* hash value of all attributes */
1622 + __u32 h_reserved[4]; /* zero right now */
1625 +struct ext3_xattr_entry {
1626 + __u8 e_name_len; /* length of name */
1627 + __u8 e_name_index; /* attribute name index */
1628 + __u16 e_value_offs; /* offset in disk block of value */
1629 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
1630 + __u32 e_value_size; /* size of attribute value */
1631 + __u32 e_hash; /* hash value of name and value */
1632 + char e_name[0]; /* attribute name */
1635 +#define EXT3_XATTR_PAD_BITS 2
1636 +#define EXT3_XATTR_PAD (1<<EXT3_XATTR_PAD_BITS)
1637 +#define EXT3_XATTR_ROUND (EXT3_XATTR_PAD-1)
1638 +#define EXT3_XATTR_LEN(name_len) \
1639 + (((name_len) + EXT3_XATTR_ROUND + \
1640 + sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
1641 +#define EXT3_XATTR_NEXT(entry) \
1642 + ( (struct ext3_xattr_entry *)( \
1643 + (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
1644 +#define EXT3_XATTR_SIZE(size) \
1645 + (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
1649 +# ifdef CONFIG_EXT3_FS_XATTR
1651 +struct ext3_xattr_handler {
1653 + size_t (*list)(char *list, struct inode *inode, const char *name,
1655 + int (*get)(struct inode *inode, const char *name, void *buffer,
1657 + int (*set)(struct inode *inode, const char *name, void *buffer,
1658 + size_t size, int flags);
1661 +extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
1662 +extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
1664 +extern int ext3_setxattr(struct dentry *, const char *, void *, size_t, int);
1665 +extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
1666 +extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
1667 +extern int ext3_removexattr(struct dentry *, const char *);
1669 +extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
1670 +extern int ext3_xattr_list(struct inode *, char *, size_t);
1671 +extern int ext3_xattr_set(handle_t *handle, struct inode *, int, const char *, void *, size_t, int);
1673 +extern void ext3_xattr_drop_inode(handle_t *, struct inode *);
1674 +extern void ext3_xattr_put_super(struct super_block *);
1676 +extern int init_ext3_xattr(void) __init;
1677 +extern void exit_ext3_xattr(void);
1679 +# else /* CONFIG_EXT3_FS_XATTR */
1680 +# define ext3_setxattr NULL
1681 +# define ext3_getxattr NULL
1682 +# define ext3_listxattr NULL
1683 +# define ext3_removexattr NULL
1686 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
1687 + void *buffer, size_t size, int flags)
1693 +ext3_xattr_list(struct inode *inode, void *buffer, size_t size, int flags)
1699 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
1700 + const char *name, void *value, size_t size, int flags)
1706 +ext3_xattr_drop_inode(handle_t *handle, struct inode *inode)
1711 +ext3_xattr_put_super(struct super_block *sb)
1716 +init_ext3_xattr(void)
1722 +exit_ext3_xattr(void)
1726 +# endif /* CONFIG_EXT3_FS_XATTR */
1728 +# ifdef CONFIG_EXT3_FS_XATTR_USER
1730 +extern int init_ext3_xattr_user(void) __init;
1731 +extern void exit_ext3_xattr_user(void);
1733 +# else /* CONFIG_EXT3_FS_XATTR_USER */
1736 +init_ext3_xattr_user(void)
1742 +exit_ext3_xattr_user(void)
1746 +#endif /* CONFIG_EXT3_FS_XATTR_USER */
1748 +#endif /* __KERNEL__ */
1750 --- /dev/null 2003-01-30 03:24:37.000000000 -0700
1751 +++ linux-2.4.18-p4smp-braam/include/linux/xattr.h 2003-07-21 22:49:05.000000000 -0600
1754 + File: linux/xattr.h
1756 + Extended attributes handling.
1758 + Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
1759 + Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
1761 +#ifndef _LINUX_XATTR_H
1762 +#define _LINUX_XATTR_H
1764 +#define XATTR_CREATE 1 /* set value, fail if attr already exists */
1765 +#define XATTR_REPLACE 2 /* set value, fail if attr does not exist */
1767 +#endif /* _LINUX_XATTR_H */
1768 --- linux-2.4.18-p4smp/fs/ext3/Makefile~linux-2.4.18ea-0.8.26 2003-07-21 22:27:37.000000000 -0600
1769 +++ linux-2.4.18-p4smp-braam/fs/ext3/Makefile 2003-07-21 22:51:23.000000000 -0600
1774 -export-objs := super.o inode.o
1775 +export-objs := ext3-exports.o
1777 obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
1778 - ioctl.o namei.o super.o symlink.o
1779 + ioctl.o namei.o super.o symlink.o xattr.o ext3-exports.o
1780 obj-m := $(O_TARGET)
1782 include $(TOPDIR)/Rules.make