Whamcloud - gitweb
minor fix for complilation
[fs/lustre-release.git] / lustre / kernel_patches / patches / linux-2.4.18ea-0.8.26-2.patch
1  fs/ext3/Makefile           |    4 
2  fs/ext3/ext3-exports.c     |   13 
3  fs/ext3/ialloc.c           |    2 
4  fs/ext3/inode.c            |   29 -
5  fs/ext3/namei.c            |    8 
6  fs/ext3/super.c            |   23 
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, 1494 insertions(+), 51 deletions(-)
13
14 --- /dev/null   2003-01-30 13:24:37.000000000 +0300
15 +++ linux-2.4.18-alexey/fs/ext3/ext3-exports.c  2003-09-01 14:55:39.000000000 +0400
16 @@ -0,0 +1,13 @@
17 +#include <linux/config.h>
18 +#include <linux/module.h>
19 +#include <linux/ext3_fs.h>
20 +#include <linux/ext3_jbd.h>
21 +#include <linux/ext3_xattr.h>
22 +
23 +EXPORT_SYMBOL(ext3_force_commit);
24 +EXPORT_SYMBOL(ext3_bread);
25 +EXPORT_SYMBOL(ext3_xattr_register);
26 +EXPORT_SYMBOL(ext3_xattr_unregister);
27 +EXPORT_SYMBOL(ext3_xattr_get);
28 +EXPORT_SYMBOL(ext3_xattr_list);
29 +EXPORT_SYMBOL(ext3_xattr_set);
30 --- linux-2.4.18/fs/ext3/ialloc.c~linux-2.4.18ea-0.8.26-2       2003-07-28 17:52:04.000000000 +0400
31 +++ linux-2.4.18-alexey/fs/ext3/ialloc.c        2003-09-01 14:55:39.000000000 +0400
32 @@ -17,6 +17,7 @@
33  #include <linux/jbd.h>
34  #include <linux/ext3_fs.h>
35  #include <linux/ext3_jbd.h>
36 +#include <linux/ext3_xattr.h>
37  #include <linux/stat.h>
38  #include <linux/string.h>
39  #include <linux/locks.h>
40 @@ -216,6 +217,7 @@ void ext3_free_inode (handle_t *handle, 
41          * as writing the quota to disk may need the lock as well.
42          */
43         DQUOT_INIT(inode);
44 +       ext3_xattr_drop_inode(handle, inode);
45         DQUOT_FREE_INODE(inode);
46         DQUOT_DROP(inode);
47  
48 --- linux-2.4.18/fs/ext3/inode.c~linux-2.4.18ea-0.8.26-2        2003-07-28 17:52:04.000000000 +0400
49 +++ linux-2.4.18-alexey/fs/ext3/inode.c 2003-09-01 14:55:39.000000000 +0400
50 @@ -39,6 +39,18 @@
51   */
52  #undef SEARCH_FROM_ZERO
53  
54 +/*
55 + * Test whether an inode is a fast symlink.
56 + */
57 +static inline int ext3_inode_is_fast_symlink(struct inode *inode)
58 +{
59 +       int ea_blocks = EXT3_I(inode)->i_file_acl ?
60 +               (inode->i_sb->s_blocksize >> 9) : 0;
61 +
62 +       return (S_ISLNK(inode->i_mode) &&
63 +               inode->i_blocks - ea_blocks == 0);
64 +}
65 +
66  /* The ext3 forget function must perform a revoke if we are freeing data
67   * which has been journaled.  Metadata (eg. indirect blocks) must be
68   * revoked in all cases. 
69 @@ -48,7 +60,7 @@
70   * still needs to be revoked.
71   */
72  
73 -static int ext3_forget(handle_t *handle, int is_metadata,
74 +int ext3_forget(handle_t *handle, int is_metadata,
75                        struct inode *inode, struct buffer_head *bh,
76                        int blocknr)
77  {
78 @@ -164,9 +176,7 @@ void ext3_delete_inode (struct inode * i
79  {
80         handle_t *handle;
81         
82 -       if (is_bad_inode(inode) ||
83 -           inode->i_ino == EXT3_ACL_IDX_INO ||
84 -           inode->i_ino == EXT3_ACL_DATA_INO)
85 +       if (is_bad_inode(inode))
86                 goto no_delete;
87  
88         lock_kernel();
89 @@ -1877,6 +1887,8 @@ void ext3_truncate(struct inode * inode)
90         if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
91             S_ISLNK(inode->i_mode)))
92                 return;
93 +       if (ext3_inode_is_fast_symlink(inode))
94 +               return;
95         if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
96                 return;
97  
98 @@ -2038,8 +2050,6 @@ int ext3_get_inode_loc (struct inode *in
99         struct ext3_group_desc * gdp;
100                 
101         if ((inode->i_ino != EXT3_ROOT_INO &&
102 -               inode->i_ino != EXT3_ACL_IDX_INO &&
103 -               inode->i_ino != EXT3_ACL_DATA_INO &&
104                 inode->i_ino != EXT3_JOURNAL_INO &&
105                 inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
106                 inode->i_ino > le32_to_cpu(
107 @@ -2166,10 +2176,7 @@ void ext3_read_inode(struct inode * inod
108  
109         brelse (iloc.bh);
110  
111 -       if (inode->i_ino == EXT3_ACL_IDX_INO ||
112 -           inode->i_ino == EXT3_ACL_DATA_INO)
113 -               /* Nothing to do */ ;
114 -       else if (S_ISREG(inode->i_mode)) {
115 +       if (S_ISREG(inode->i_mode)) {
116                 inode->i_op = &ext3_file_inode_operations;
117                 inode->i_fop = &ext3_file_operations;
118                 inode->i_mapping->a_ops = &ext3_aops;
119 @@ -2177,7 +2184,7 @@ void ext3_read_inode(struct inode * inod
120                 inode->i_op = &ext3_dir_inode_operations;
121                 inode->i_fop = &ext3_dir_operations;
122         } else if (S_ISLNK(inode->i_mode)) {
123 -               if (!inode->i_blocks)
124 +               if (ext3_inode_is_fast_symlink(inode))
125                         inode->i_op = &ext3_fast_symlink_inode_operations;
126                 else {
127                         inode->i_op = &page_symlink_inode_operations;
128 --- linux-2.4.18/fs/ext3/Makefile~linux-2.4.18ea-0.8.26-2       2003-08-29 16:53:17.000000000 +0400
129 +++ linux-2.4.18-alexey/fs/ext3/Makefile        2003-09-01 14:55:50.000000000 +0400
130 @@ -9,10 +9,10 @@
131  
132  O_TARGET := ext3.o
133  
134 -export-objs := super.o inode.o
135 +export-objs := ext3-exports.o
136  
137  obj-y    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
138 -               ioctl.o namei.o super.o symlink.o hash.o
139 +               ioctl.o namei.o super.o symlink.o xattr.o hash.o ext3-exports.o
140  obj-m    := $(O_TARGET)
141  
142  include $(TOPDIR)/Rules.make
143 --- linux-2.4.18/fs/ext3/namei.c~linux-2.4.18ea-0.8.26-2        2003-09-01 11:50:59.000000000 +0400
144 +++ linux-2.4.18-alexey/fs/ext3/namei.c 2003-09-01 14:55:39.000000000 +0400
145 @@ -29,6 +29,7 @@
146  #include <linux/sched.h>
147  #include <linux/ext3_fs.h>
148  #include <linux/ext3_jbd.h>
149 +#include <linux/ext3_xattr.h>
150  #include <linux/fcntl.h>
151  #include <linux/stat.h>
152  #include <linux/string.h>
153 @@ -1524,6 +1525,7 @@ static int ext3_add_nondir(handle_t *han
154                 d_instantiate(dentry, inode);
155                 return 0;
156         }
157 +       ext3_xattr_drop_inode(handle, inode);
158         ext3_dec_count(handle, inode);
159         iput(inode);
160         return err;
161 @@ -1612,7 +1614,7 @@ static int ext3_mkdir(struct inode * dir
162         if (IS_SYNC(dir))
163                 handle->h_sync = 1;
164  
165 -       inode = ext3_new_inode (handle, dir, S_IFDIR);
166 +       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
167         err = PTR_ERR(inode);
168         if (IS_ERR(inode))
169                 goto out_stop;
170 @@ -1620,7 +1622,6 @@ static int ext3_mkdir(struct inode * dir
171         inode->i_op = &ext3_dir_inode_operations;
172         inode->i_fop = &ext3_dir_operations;
173         inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
174 -       inode->i_blocks = 0;    
175         dir_block = ext3_bread (handle, inode, 0, 1, &err);
176         if (!dir_block) {
177                 inode->i_nlink--; /* is this nlink == 0? */
178 @@ -1647,9 +1648,6 @@ static int ext3_mkdir(struct inode * dir
179         BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
180         ext3_journal_dirty_metadata(handle, dir_block);
181         brelse (dir_block);
182 -       inode->i_mode = S_IFDIR | mode;
183 -       if (dir->i_mode & S_ISGID)
184 -               inode->i_mode |= S_ISGID;
185         ext3_mark_inode_dirty(handle, inode);
186         err = ext3_add_entry (handle, dentry, inode);
187         if (err) {
188 --- linux-2.4.18/fs/ext3/super.c~linux-2.4.18ea-0.8.26-2        2003-08-29 16:53:17.000000000 +0400
189 +++ linux-2.4.18-alexey/fs/ext3/super.c 2003-09-01 14:55:39.000000000 +0400
190 @@ -24,6 +24,7 @@
191  #include <linux/jbd.h>
192  #include <linux/ext3_fs.h>
193  #include <linux/ext3_jbd.h>
194 +#include <linux/ext3_xattr.h>
195  #include <linux/slab.h>
196  #include <linux/init.h>
197  #include <linux/locks.h>
198 @@ -406,6 +407,7 @@ void ext3_put_super (struct super_block 
199         kdev_t j_dev = sbi->s_journal->j_dev;
200         int i;
201  
202 +       ext3_xattr_put_super(sb);
203         journal_destroy(sbi->s_journal);
204         if (!(sb->s_flags & MS_RDONLY)) {
205                 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
206 @@ -1743,18 +1745,27 @@ int ext3_statfs (struct super_block * sb
207  
208  static DECLARE_FSTYPE_DEV(ext3_fs_type, "ext3", ext3_read_super);
209  
210 -static int __init init_ext3_fs(void)
211 +static void exit_ext3_fs(void)
212  {
213 -        return register_filesystem(&ext3_fs_type);
214 +       unregister_filesystem(&ext3_fs_type);
215 +       exit_ext3_xattr_user();
216 +       exit_ext3_xattr();
217  }
218  
219 -static void __exit exit_ext3_fs(void)
220 +static int __init init_ext3_fs(void)
221  {
222 -       unregister_filesystem(&ext3_fs_type);
223 +       int error = init_ext3_xattr();
224 +       if (!error)
225 +               error = init_ext3_xattr_user();
226 +       if (!error)
227 +               error = register_filesystem(&ext3_fs_type);
228 +       if (!error)
229 +               return 0;
230 +
231 +       exit_ext3_fs();
232 +       return error;
233  }
234  
235 -EXPORT_SYMBOL(ext3_force_commit);
236 -EXPORT_SYMBOL(ext3_bread);
237  
238  MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
239  MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
240 --- /dev/null   2003-01-30 13:24:37.000000000 +0300
241 +++ linux-2.4.18-alexey/fs/ext3/xattr.c 2003-09-01 14:55:39.000000000 +0400
242 @@ -0,0 +1,1242 @@
243 +/*
244 + * linux/fs/ext3/xattr.c
245 + *
246 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
247 + *
248 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
249 + * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
250 + * Extended attributes for symlinks and special files added per
251 + *  suggestion of Luka Renko <luka.renko@hermes.si>.
252 + */
253 +
254 +/*
255 + * Extended attributes are stored on disk blocks allocated outside of
256 + * any inode. The i_file_acl field is then made to point to this allocated
257 + * block. If all extended attributes of an inode are identical, these
258 + * inodes may share the same extended attribute block. Such situations
259 + * are automatically detected by keeping a cache of recent attribute block
260 + * numbers and hashes over the block's contents in memory.
261 + *
262 + *
263 + * Extended attribute block layout:
264 + *
265 + *   +------------------+
266 + *   | header           |
267 + *   Â¦ entry 1          | |
268 + *   | entry 2          | | growing downwards
269 + *   | entry 3          | v
270 + *   | four null bytes  |
271 + *   | . . .            |
272 + *   | value 1          | ^
273 + *   | value 3          | | growing upwards
274 + *   | value 2          | |
275 + *   +------------------+
276 + *
277 + * The block header is followed by multiple entry descriptors. These entry
278 + * descriptors are variable in size, and alligned to EXT3_XATTR_PAD
279 + * byte boundaries. The entry descriptors are sorted by attribute name,
280 + * so that two extended attribute blocks can be compared efficiently.
281 + *
282 + * Attribute values are aligned to the end of the block, stored in
283 + * no specific order. They are also padded to EXT3_XATTR_PAD byte
284 + * boundaries. No additional gaps are left between them.
285 + *
286 + * Locking strategy
287 + * ----------------
288 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
289 + * the xattr inode operations are called, so we are guaranteed that only one
290 + * processes accesses extended attributes of an inode at any time.
291 + *
292 + * For writing we also grab the ext3_xattr_sem semaphore. This ensures that
293 + * only a single process is modifying an extended attribute block, even
294 + * if the block is shared among inodes.
295 + *
296 + * Note for porting to 2.5
297 + * -----------------------
298 + * The BKL will no longer be held in the xattr inode operations.
299 + */
300 +
301 +#include <linux/fs.h>
302 +#include <linux/locks.h>
303 +#include <linux/slab.h>
304 +#include <linux/ext3_jbd.h>
305 +#include <linux/ext3_fs.h>
306 +#include <linux/ext3_xattr.h>
307 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
308 +#include <linux/mbcache.h>
309 +#endif
310 +#include <linux/quotaops.h>
311 +#include <asm/semaphore.h>
312 +#include <linux/compatmac.h>
313 +#include <linux/module.h>
314 +
315 +/* These symbols may be needed by a module. */
316 +
317 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
318 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
319 +#endif
320 +
321 +#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data))
322 +#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr))
323 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
324 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
325 +
326 +#ifdef EXT3_XATTR_DEBUG
327 +# define ea_idebug(inode, f...) do { \
328 +               printk(KERN_DEBUG "inode %s:%ld: ", \
329 +                       kdevname(inode->i_dev), inode->i_ino); \
330 +               printk(f); \
331 +               printk("\n"); \
332 +       } while (0)
333 +# define ea_bdebug(bh, f...) do { \
334 +               printk(KERN_DEBUG "block %s:%ld: ", \
335 +                       kdevname(bh->b_dev), bh->b_blocknr); \
336 +               printk(f); \
337 +               printk("\n"); \
338 +       } while (0)
339 +#else
340 +# define ea_idebug(f...)
341 +# define ea_bdebug(f...)
342 +#endif
343 +
344 +static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *,
345 +                          struct ext3_xattr_header *);
346 +
347 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
348 +
349 +static int ext3_xattr_cache_insert(struct buffer_head *);
350 +static struct buffer_head *ext3_xattr_cache_find(struct inode *,
351 +                                                struct ext3_xattr_header *);
352 +static void ext3_xattr_cache_remove(struct buffer_head *);
353 +static void ext3_xattr_rehash(struct ext3_xattr_header *,
354 +                             struct ext3_xattr_entry *);
355 +
356 +static struct mb_cache *ext3_xattr_cache;
357 +
358 +#else
359 +# define ext3_xattr_cache_insert(bh) 0
360 +# define ext3_xattr_cache_find(inode, header) NULL
361 +# define ext3_xattr_cache_remove(bh) do {} while(0)
362 +# define ext3_xattr_rehash(header, entry) do {} while(0)
363 +#endif
364 +
365 +/*
366 + * If a file system does not share extended attributes among inodes,
367 + * we should not need the ext3_xattr_sem semaphore. However, the
368 + * filesystem may still contain shared blocks, so we always take
369 + * the lock.
370 + */
371 +
372 +DECLARE_MUTEX(ext3_xattr_sem);
373 +
374 +static inline void
375 +ext3_xattr_lock(void)
376 +{
377 +       down(&ext3_xattr_sem);
378 +}
379 +
380 +static inline void
381 +ext3_xattr_unlock(void)
382 +{
383 +       up(&ext3_xattr_sem);
384 +}
385 +
386 +static inline int
387 +ext3_xattr_new_block(handle_t *handle, struct inode *inode,
388 +                    int * errp, int force)
389 +{
390 +       struct super_block *sb = inode->i_sb;
391 +       int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
392 +               EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb);
393 +
394 +       /* How can we enforce the allocation? */
395 +       int block = ext3_new_block(handle, inode, goal, 0, 0, errp);
396 +#ifdef OLD_QUOTAS
397 +       if (!*errp)
398 +               inode->i_blocks += inode->i_sb->s_blocksize >> 9;
399 +#endif
400 +       return block;
401 +}
402 +
403 +static inline int
404 +ext3_xattr_quota_alloc(struct inode *inode, int force)
405 +{
406 +       /* How can we enforce the allocation? */
407 +#ifdef OLD_QUOTAS
408 +       int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
409 +       if (!error)
410 +               inode->i_blocks += inode->i_sb->s_blocksize >> 9;
411 +#else
412 +       int error = DQUOT_ALLOC_BLOCK(inode, 1);
413 +#endif
414 +       return error;
415 +}
416 +
417 +#ifdef OLD_QUOTAS
418 +
419 +static inline void
420 +ext3_xattr_quota_free(struct inode *inode)
421 +{
422 +       DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
423 +       inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
424 +}
425 +
426 +static inline void
427 +ext3_xattr_free_block(handle_t *handle, struct inode * inode,
428 +                     unsigned long block)
429 +{
430 +       ext3_free_blocks(handle, inode, block, 1);
431 +       inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
432 +}
433 +
434 +#else
435 +# define ext3_xattr_quota_free(inode) \
436 +       DQUOT_FREE_BLOCK(inode, 1)
437 +# define ext3_xattr_free_block(handle, inode, block) \
438 +       ext3_free_blocks(handle, inode, block, 1)
439 +#endif
440 +
441 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
442 +
443 +static inline struct buffer_head *
444 +sb_bread(struct super_block *sb, int block)
445 +{
446 +       return bread(sb->s_dev, block, sb->s_blocksize);
447 +}
448 +
449 +static inline struct buffer_head *
450 +sb_getblk(struct super_block *sb, int block)
451 +{
452 +       return getblk(sb->s_dev, block, sb->s_blocksize);
453 +}
454 +
455 +#endif
456 +
457 +struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
458 +rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
459 +
460 +int
461 +ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
462 +{
463 +       int error = -EINVAL;
464 +
465 +       if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
466 +               write_lock(&ext3_handler_lock);
467 +               if (!ext3_xattr_handlers[name_index-1]) {
468 +                       ext3_xattr_handlers[name_index-1] = handler;
469 +                       error = 0;
470 +               }
471 +               write_unlock(&ext3_handler_lock);
472 +       }
473 +       return error;
474 +}
475 +
476 +void
477 +ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
478 +{
479 +       if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
480 +               write_lock(&ext3_handler_lock);
481 +               ext3_xattr_handlers[name_index-1] = NULL;
482 +               write_unlock(&ext3_handler_lock);
483 +       }
484 +}
485 +
486 +static inline const char *
487 +strcmp_prefix(const char *a, const char *a_prefix)
488 +{
489 +       while (*a_prefix && *a == *a_prefix) {
490 +               a++;
491 +               a_prefix++;
492 +       }
493 +       return *a_prefix ? NULL : a;
494 +}
495 +
496 +/*
497 + * Decode the extended attribute name, and translate it into
498 + * the name_index and name suffix.
499 + */
500 +static inline struct ext3_xattr_handler *
501 +ext3_xattr_resolve_name(const char **name)
502 +{
503 +       struct ext3_xattr_handler *handler = NULL;
504 +       int i;
505 +
506 +       if (!*name)
507 +               return NULL;
508 +       read_lock(&ext3_handler_lock);
509 +       for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
510 +               if (ext3_xattr_handlers[i]) {
511 +                       const char *n = strcmp_prefix(*name,
512 +                               ext3_xattr_handlers[i]->prefix);
513 +                       if (n) {
514 +                               handler = ext3_xattr_handlers[i];
515 +                               *name = n;
516 +                               break;
517 +                       }
518 +               }
519 +       }
520 +       read_unlock(&ext3_handler_lock);
521 +       return handler;
522 +}
523 +
524 +static inline struct ext3_xattr_handler *
525 +ext3_xattr_handler(int name_index)
526 +{
527 +       struct ext3_xattr_handler *handler = NULL;
528 +       if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
529 +               read_lock(&ext3_handler_lock);
530 +               handler = ext3_xattr_handlers[name_index-1];
531 +               read_unlock(&ext3_handler_lock);
532 +       }
533 +       return handler;
534 +}
535 +
536 +/*
537 + * Inode operation getxattr()
538 + *
539 + * dentry->d_inode->i_sem down
540 + * BKL held [before 2.5.x]
541 + */
542 +ssize_t
543 +ext3_getxattr(struct dentry *dentry, const char *name,
544 +             void *buffer, size_t size)
545 +{
546 +       struct ext3_xattr_handler *handler;
547 +       struct inode *inode = dentry->d_inode;
548 +
549 +       handler = ext3_xattr_resolve_name(&name);
550 +       if (!handler)
551 +               return -ENOTSUP;
552 +       return handler->get(inode, name, buffer, size);
553 +}
554 +
555 +/*
556 + * Inode operation listxattr()
557 + *
558 + * dentry->d_inode->i_sem down
559 + * BKL held [before 2.5.x]
560 + */
561 +ssize_t
562 +ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
563 +{
564 +       return ext3_xattr_list(dentry->d_inode, buffer, size);
565 +}
566 +
567 +/*
568 + * Inode operation setxattr()
569 + *
570 + * dentry->d_inode->i_sem down
571 + * BKL held [before 2.5.x]
572 + */
573 +int
574 +ext3_setxattr(struct dentry *dentry, const char *name,
575 +             void *value, size_t size, int flags)
576 +{
577 +       struct ext3_xattr_handler *handler;
578 +       struct inode *inode = dentry->d_inode;
579 +
580 +       if (size == 0)
581 +               value = "";  /* empty EA, do not remove */
582 +       handler = ext3_xattr_resolve_name(&name);
583 +       if (!handler)
584 +               return -ENOTSUP;
585 +       return handler->set(inode, name, value, size, flags);
586 +}
587 +
588 +/*
589 + * Inode operation removexattr()
590 + *
591 + * dentry->d_inode->i_sem down
592 + * BKL held [before 2.5.x]
593 + */
594 +int
595 +ext3_removexattr(struct dentry *dentry, const char *name)
596 +{
597 +       struct ext3_xattr_handler *handler;
598 +       struct inode *inode = dentry->d_inode;
599 +
600 +       handler = ext3_xattr_resolve_name(&name);
601 +       if (!handler)
602 +               return -ENOTSUP;
603 +       return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
604 +}
605 +
606 +/*
607 + * ext3_xattr_get()
608 + *
609 + * Copy an extended attribute into the buffer
610 + * provided, or compute the buffer size required.
611 + * Buffer is NULL to compute the size of the buffer required.
612 + *
613 + * Returns a negative error number on failure, or the number of bytes
614 + * used / required on success.
615 + */
616 +int
617 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
618 +              void *buffer, size_t buffer_size)
619 +{
620 +       struct buffer_head *bh = NULL;
621 +       struct ext3_xattr_entry *entry;
622 +       unsigned int block, size;
623 +       char *end;
624 +       int name_len, error;
625 +
626 +       ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
627 +                 name_index, name, buffer, (long)buffer_size);
628 +
629 +       if (name == NULL)
630 +               return -EINVAL;
631 +       if (!EXT3_I(inode)->i_file_acl)
632 +               return -ENOATTR;
633 +       block = EXT3_I(inode)->i_file_acl;
634 +       ea_idebug(inode, "reading block %d", block);
635 +       bh = sb_bread(inode->i_sb, block);
636 +       if (!bh)
637 +               return -EIO;
638 +       ea_bdebug(bh, "b_count=%d, refcount=%d",
639 +               atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
640 +       end = bh->b_data + bh->b_size;
641 +       if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
642 +           HDR(bh)->h_blocks != cpu_to_le32(1)) {
643 +bad_block:     ext3_error(inode->i_sb, "ext3_xattr_get",
644 +                       "inode %ld: bad block %d", inode->i_ino, block);
645 +               error = -EIO;
646 +               goto cleanup;
647 +       }
648 +       /* find named attribute */
649 +       name_len = strlen(name);
650 +
651 +       error = -ERANGE;
652 +       if (name_len > 255)
653 +               goto cleanup;
654 +       entry = FIRST_ENTRY(bh);
655 +       while (!IS_LAST_ENTRY(entry)) {
656 +               struct ext3_xattr_entry *next =
657 +                       EXT3_XATTR_NEXT(entry);
658 +               if ((char *)next >= end)
659 +                       goto bad_block;
660 +               if (name_index == entry->e_name_index &&
661 +                   name_len == entry->e_name_len &&
662 +                   memcmp(name, entry->e_name, name_len) == 0)
663 +                       goto found;
664 +               entry = next;
665 +       }
666 +       /* Check the remaining name entries */
667 +       while (!IS_LAST_ENTRY(entry)) {
668 +               struct ext3_xattr_entry *next =
669 +                       EXT3_XATTR_NEXT(entry);
670 +               if ((char *)next >= end)
671 +                       goto bad_block;
672 +               entry = next;
673 +       }
674 +       if (ext3_xattr_cache_insert(bh))
675 +               ea_idebug(inode, "cache insert failed");
676 +       error = -ENOATTR;
677 +       goto cleanup;
678 +found:
679 +       /* check the buffer size */
680 +       if (entry->e_value_block != 0)
681 +               goto bad_block;
682 +       size = le32_to_cpu(entry->e_value_size);
683 +       if (size > inode->i_sb->s_blocksize ||
684 +           le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
685 +               goto bad_block;
686 +
687 +       if (ext3_xattr_cache_insert(bh))
688 +               ea_idebug(inode, "cache insert failed");
689 +       if (buffer) {
690 +               error = -ERANGE;
691 +               if (size > buffer_size)
692 +                       goto cleanup;
693 +               /* return value of attribute */
694 +               memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
695 +                       size);
696 +       }
697 +       error = size;
698 +
699 +cleanup:
700 +       brelse(bh);
701 +
702 +       return error;
703 +}
704 +
705 +/*
706 + * ext3_xattr_list()
707 + *
708 + * Copy a list of attribute names into the buffer
709 + * provided, or compute the buffer size required.
710 + * Buffer is NULL to compute the size of the buffer required.
711 + *
712 + * Returns a negative error number on failure, or the number of bytes
713 + * used / required on success.
714 + */
715 +int
716 +ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
717 +{
718 +       struct buffer_head *bh = NULL;
719 +       struct ext3_xattr_entry *entry;
720 +       unsigned int block, size = 0;
721 +       char *buf, *end;
722 +       int error;
723 +
724 +       ea_idebug(inode, "buffer=%p, buffer_size=%ld",
725 +                 buffer, (long)buffer_size);
726 +
727 +       if (!EXT3_I(inode)->i_file_acl)
728 +               return 0;
729 +       block = EXT3_I(inode)->i_file_acl;
730 +       ea_idebug(inode, "reading block %d", block);
731 +       bh = sb_bread(inode->i_sb, block);
732 +       if (!bh)
733 +               return -EIO;
734 +       ea_bdebug(bh, "b_count=%d, refcount=%d",
735 +               atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
736 +       end = bh->b_data + bh->b_size;
737 +       if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
738 +           HDR(bh)->h_blocks != cpu_to_le32(1)) {
739 +bad_block:     ext3_error(inode->i_sb, "ext3_xattr_list",
740 +                       "inode %ld: bad block %d", inode->i_ino, block);
741 +               error = -EIO;
742 +               goto cleanup;
743 +       }
744 +       /* compute the size required for the list of attribute names */
745 +       for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
746 +            entry = EXT3_XATTR_NEXT(entry)) {
747 +               struct ext3_xattr_handler *handler;
748 +               struct ext3_xattr_entry *next =
749 +                       EXT3_XATTR_NEXT(entry);
750 +               if ((char *)next >= end)
751 +                       goto bad_block;
752 +
753 +               handler = ext3_xattr_handler(entry->e_name_index);
754 +               if (handler) {
755 +                       size += handler->list(NULL, inode, entry->e_name,
756 +                                             entry->e_name_len) + 1;
757 +               }
758 +       }
759 +
760 +       if (ext3_xattr_cache_insert(bh))
761 +               ea_idebug(inode, "cache insert failed");
762 +       if (!buffer) {
763 +               error = size;
764 +               goto cleanup;
765 +       } else {
766 +               error = -ERANGE;
767 +               if (size > buffer_size)
768 +                       goto cleanup;
769 +       }
770 +
771 +       /* list the attribute names */
772 +       buf = buffer;
773 +       for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
774 +            entry = EXT3_XATTR_NEXT(entry)) {
775 +               struct ext3_xattr_handler *handler;
776 +
777 +               handler = ext3_xattr_handler(entry->e_name_index);
778 +               if (handler) {
779 +                       buf += handler->list(buf, inode, entry->e_name,
780 +                                            entry->e_name_len);
781 +                       *buf++ = '\0';
782 +               }
783 +       }
784 +       error = size;
785 +
786 +cleanup:
787 +       brelse(bh);
788 +
789 +       return error;
790 +}
791 +
792 +/*
793 + * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is
794 + * not set, set it.
795 + */
796 +static void ext3_xattr_update_super_block(handle_t *handle,
797 +                                         struct super_block *sb)
798 +{
799 +       if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
800 +               return;
801 +
802 +       lock_super(sb);
803 +       ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
804 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
805 +       EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR;
806 +#endif
807 +       EXT3_SB(sb)->s_es->s_feature_compat |=
808 +               cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
809 +       sb->s_dirt = 1;
810 +       ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
811 +       unlock_super(sb);
812 +}
813 +
814 +/*
815 + * ext3_xattr_set()
816 + *
817 + * Create, replace or remove an extended attribute for this inode. Buffer
818 + * is NULL to remove an existing extended attribute, and non-NULL to
819 + * either replace an existing extended attribute, or create a new extended
820 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
821 + * specify that an extended attribute must exist and must not exist
822 + * previous to the call, respectively.
823 + *
824 + * Returns 0, or a negative error number on failure.
825 + */
826 +int
827 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
828 +              const char *name, void *value, size_t value_len, int flags)
829 +{
830 +       struct super_block *sb = inode->i_sb;
831 +       struct buffer_head *bh = NULL;
832 +       struct ext3_xattr_header *header = NULL;
833 +       struct ext3_xattr_entry *here, *last;
834 +       unsigned int name_len;
835 +       int min_offs = sb->s_blocksize, not_found = 1, free, error;
836 +       char *end;
837 +       
838 +       /*
839 +        * header -- Points either into bh, or to a temporarily
840 +        *           allocated buffer.
841 +        * here -- The named entry found, or the place for inserting, within
842 +        *         the block pointed to by header.
843 +        * last -- Points right after the last named entry within the block
844 +        *         pointed to by header.
845 +        * min_offs -- The offset of the first value (values are aligned
846 +        *             towards the end of the block).
847 +        * end -- Points right after the block pointed to by header.
848 +        */
849 +       
850 +       ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
851 +                 name_index, name, value, (long)value_len);
852 +
853 +       if (IS_RDONLY(inode))
854 +               return -EROFS;
855 +       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
856 +               return -EPERM;
857 +       if (value == NULL)
858 +               value_len = 0;
859 +       if (name == NULL)
860 +               return -EINVAL;
861 +       name_len = strlen(name);
862 +       if (name_len > 255 || value_len > sb->s_blocksize)
863 +               return -ERANGE;
864 +       ext3_xattr_lock();
865 +
866 +       if (EXT3_I(inode)->i_file_acl) {
867 +               /* The inode already has an extended attribute block. */
868 +               int block = EXT3_I(inode)->i_file_acl;
869 +
870 +               bh = sb_bread(sb, block);
871 +               error = -EIO;
872 +               if (!bh)
873 +                       goto cleanup;
874 +               ea_bdebug(bh, "b_count=%d, refcount=%d",
875 +                       atomic_read(&(bh->b_count)),
876 +                       le32_to_cpu(HDR(bh)->h_refcount));
877 +               header = HDR(bh);
878 +               end = bh->b_data + bh->b_size;
879 +               if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
880 +                   header->h_blocks != cpu_to_le32(1)) {
881 +bad_block:             ext3_error(sb, "ext3_xattr_set",
882 +                               "inode %ld: bad block %d", inode->i_ino, block);
883 +                       error = -EIO;
884 +                       goto cleanup;
885 +               }
886 +               /* Find the named attribute. */
887 +               here = FIRST_ENTRY(bh);
888 +               while (!IS_LAST_ENTRY(here)) {
889 +                       struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here);
890 +                       if ((char *)next >= end)
891 +                               goto bad_block;
892 +                       if (!here->e_value_block && here->e_value_size) {
893 +                               int offs = le16_to_cpu(here->e_value_offs);
894 +                               if (offs < min_offs)
895 +                                       min_offs = offs;
896 +                       }
897 +                       not_found = name_index - here->e_name_index;
898 +                       if (!not_found)
899 +                               not_found = name_len - here->e_name_len;
900 +                       if (!not_found)
901 +                               not_found = memcmp(name, here->e_name,name_len);
902 +                       if (not_found <= 0)
903 +                               break;
904 +                       here = next;
905 +               }
906 +               last = here;
907 +               /* We still need to compute min_offs and last. */
908 +               while (!IS_LAST_ENTRY(last)) {
909 +                       struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last);
910 +                       if ((char *)next >= end)
911 +                               goto bad_block;
912 +                       if (!last->e_value_block && last->e_value_size) {
913 +                               int offs = le16_to_cpu(last->e_value_offs);
914 +                               if (offs < min_offs)
915 +                                       min_offs = offs;
916 +                       }
917 +                       last = next;
918 +               }
919 +
920 +               /* Check whether we have enough space left. */
921 +               free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
922 +       } else {
923 +               /* We will use a new extended attribute block. */
924 +               free = sb->s_blocksize -
925 +                       sizeof(struct ext3_xattr_header) - sizeof(__u32);
926 +               here = last = NULL;  /* avoid gcc uninitialized warning. */
927 +       }
928 +
929 +       if (not_found) {
930 +               /* Request to remove a nonexistent attribute? */
931 +               error = -ENOATTR;
932 +               if (flags & XATTR_REPLACE)
933 +                       goto cleanup;
934 +               error = 0;
935 +               if (value == NULL)
936 +                       goto cleanup;
937 +               else
938 +                       free -= EXT3_XATTR_LEN(name_len);
939 +       } else {
940 +               /* Request to create an existing attribute? */
941 +               error = -EEXIST;
942 +               if (flags & XATTR_CREATE)
943 +                       goto cleanup;
944 +               if (!here->e_value_block && here->e_value_size) {
945 +                       unsigned int size = le32_to_cpu(here->e_value_size);
946 +
947 +                       if (le16_to_cpu(here->e_value_offs) + size > 
948 +                           sb->s_blocksize || size > sb->s_blocksize)
949 +                               goto bad_block;
950 +                       free += EXT3_XATTR_SIZE(size);
951 +               }
952 +       }
953 +       free -= EXT3_XATTR_SIZE(value_len);
954 +       error = -ENOSPC;
955 +       if (free < 0)
956 +               goto cleanup;
957 +
958 +       /* Here we know that we can set the new attribute. */
959 +
960 +       if (header) {
961 +               if (header->h_refcount == cpu_to_le32(1)) {
962 +                       ea_bdebug(bh, "modifying in-place");
963 +                       ext3_xattr_cache_remove(bh);
964 +                       error = ext3_journal_get_write_access(handle, bh);
965 +                       if (error)
966 +                               goto cleanup;
967 +               } else {
968 +                       int offset;
969 +
970 +                       ea_bdebug(bh, "cloning");
971 +                       header = kmalloc(bh->b_size, GFP_KERNEL);
972 +                       error = -ENOMEM;
973 +                       if (header == NULL)
974 +                               goto cleanup;
975 +                       memcpy(header, HDR(bh), bh->b_size);
976 +                       header->h_refcount = cpu_to_le32(1);
977 +                       offset = (char *)header - bh->b_data;
978 +                       here = ENTRY((char *)here + offset);
979 +                       last = ENTRY((char *)last + offset);
980 +               }
981 +       } else {
982 +               /* Allocate a buffer where we construct the new block. */
983 +               header = kmalloc(sb->s_blocksize, GFP_KERNEL);
984 +               error = -ENOMEM;
985 +               if (header == NULL)
986 +                       goto cleanup;
987 +               memset(header, 0, sb->s_blocksize);
988 +               end = (char *)header + sb->s_blocksize;
989 +               header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
990 +               header->h_blocks = header->h_refcount = cpu_to_le32(1);
991 +               last = here = ENTRY(header+1);
992 +       }
993 +
994 +       if (not_found) {
995 +               /* Insert the new name. */
996 +               int size = EXT3_XATTR_LEN(name_len);
997 +               int rest = (char *)last - (char *)here;
998 +               memmove((char *)here + size, here, rest);
999 +               memset(here, 0, size);
1000 +               here->e_name_index = name_index;
1001 +               here->e_name_len = name_len;
1002 +               memcpy(here->e_name, name, name_len);
1003 +       } else {
1004 +               /* Remove the old value. */
1005 +               if (!here->e_value_block && here->e_value_size) {
1006 +                       char *first_val = (char *)header + min_offs;
1007 +                       int offs = le16_to_cpu(here->e_value_offs);
1008 +                       char *val = (char *)header + offs;
1009 +                       size_t size = EXT3_XATTR_SIZE(
1010 +                               le32_to_cpu(here->e_value_size));
1011 +                       memmove(first_val + size, first_val, val - first_val);
1012 +                       memset(first_val, 0, size);
1013 +                       here->e_value_offs = 0;
1014 +                       min_offs += size;
1015 +
1016 +                       /* Adjust all value offsets. */
1017 +                       last = ENTRY(header+1);
1018 +                       while (!IS_LAST_ENTRY(last)) {
1019 +                               int o = le16_to_cpu(last->e_value_offs);
1020 +                               if (!last->e_value_block && o < offs)
1021 +                                       last->e_value_offs =
1022 +                                               cpu_to_le16(o + size);
1023 +                               last = EXT3_XATTR_NEXT(last);
1024 +                       }
1025 +               }
1026 +               if (value == NULL) {
1027 +                       /* Remove this attribute. */
1028 +                       if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) {
1029 +                               /* This block is now empty. */
1030 +                               error = ext3_xattr_set2(handle, inode, bh,NULL);
1031 +                               goto cleanup;
1032 +                       } else {
1033 +                               /* Remove the old name. */
1034 +                               int size = EXT3_XATTR_LEN(name_len);
1035 +                               last = ENTRY((char *)last - size);
1036 +                               memmove(here, (char*)here + size,
1037 +                                       (char*)last - (char*)here);
1038 +                               memset(last, 0, size);
1039 +                       }
1040 +               }
1041 +       }
1042 +
1043 +       if (value != NULL) {
1044 +               /* Insert the new value. */
1045 +               here->e_value_size = cpu_to_le32(value_len);
1046 +               if (value_len) {
1047 +                       size_t size = EXT3_XATTR_SIZE(value_len);
1048 +                       char *val = (char *)header + min_offs - size;
1049 +                       here->e_value_offs =
1050 +                               cpu_to_le16((char *)val - (char *)header);
1051 +                       memset(val + size - EXT3_XATTR_PAD, 0,
1052 +                              EXT3_XATTR_PAD); /* Clear the pad bytes. */
1053 +                       memcpy(val, value, value_len);
1054 +               }
1055 +       }
1056 +       ext3_xattr_rehash(header, here);
1057 +
1058 +       error = ext3_xattr_set2(handle, inode, bh, header);
1059 +
1060 +cleanup:
1061 +       brelse(bh);
1062 +       if (!(bh && header == HDR(bh)))
1063 +               kfree(header);
1064 +       ext3_xattr_unlock();
1065 +
1066 +       return error;
1067 +}
1068 +
1069 +/*
1070 + * Second half of ext3_xattr_set(): Update the file system.
1071 + */
1072 +static int
1073 +ext3_xattr_set2(handle_t *handle, struct inode *inode,
1074 +               struct buffer_head *old_bh, struct ext3_xattr_header *header)
1075 +{
1076 +       struct super_block *sb = inode->i_sb;
1077 +       struct buffer_head *new_bh = NULL;
1078 +       int error;
1079 +
1080 +       if (header) {
1081 +               new_bh = ext3_xattr_cache_find(inode, header);
1082 +               if (new_bh) {
1083 +                       /*
1084 +                        * We found an identical block in the cache.
1085 +                        * The old block will be released after updating
1086 +                        * the inode.
1087 +                        */
1088 +                       ea_bdebug(old_bh, "reusing block %ld",
1089 +                               new_bh->b_blocknr);
1090 +                       
1091 +                       error = -EDQUOT;
1092 +                       if (ext3_xattr_quota_alloc(inode, 1))
1093 +                               goto cleanup;
1094 +                       
1095 +                       error = ext3_journal_get_write_access(handle, new_bh);
1096 +                       if (error)
1097 +                               goto cleanup;
1098 +                       HDR(new_bh)->h_refcount = cpu_to_le32(
1099 +                               le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
1100 +                       ea_bdebug(new_bh, "refcount now=%d",
1101 +                               le32_to_cpu(HDR(new_bh)->h_refcount));
1102 +               } else if (old_bh && header == HDR(old_bh)) {
1103 +                       /* Keep this block. */
1104 +                       new_bh = old_bh;
1105 +                       (void)ext3_xattr_cache_insert(new_bh);
1106 +               } else {
1107 +                       /* We need to allocate a new block */
1108 +                       int force = EXT3_I(inode)->i_file_acl != 0;
1109 +                       int block = ext3_xattr_new_block(handle, inode,
1110 +                                                        &error, force);
1111 +                       if (error)
1112 +                               goto cleanup;
1113 +                       ea_idebug(inode, "creating block %d", block);
1114 +
1115 +                       new_bh = sb_getblk(sb, block);
1116 +                       if (!new_bh) {
1117 +getblk_failed:                 ext3_xattr_free_block(handle, inode, block);
1118 +                               error = -EIO;
1119 +                               goto cleanup;
1120 +                       }
1121 +                       lock_buffer(new_bh);
1122 +                       error = ext3_journal_get_create_access(handle, new_bh);
1123 +                       if (error) {
1124 +                               unlock_buffer(new_bh);
1125 +                               goto getblk_failed;
1126 +                       }
1127 +                       memcpy(new_bh->b_data, header, new_bh->b_size);
1128 +                       mark_buffer_uptodate(new_bh, 1);
1129 +                       unlock_buffer(new_bh);
1130 +                       (void)ext3_xattr_cache_insert(new_bh);
1131 +                       ext3_xattr_update_super_block(handle, sb);
1132 +               }
1133 +               error = ext3_journal_dirty_metadata(handle, new_bh);
1134 +               if (error)
1135 +                       goto cleanup;
1136 +       }
1137 +
1138 +       /* Update the inode. */
1139 +       EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
1140 +       inode->i_ctime = CURRENT_TIME;
1141 +       ext3_mark_inode_dirty(handle, inode);
1142 +       if (IS_SYNC(inode))
1143 +               handle->h_sync = 1;
1144 +
1145 +       error = 0;
1146 +       if (old_bh && old_bh != new_bh) {
1147 +               /*
1148 +                * If there was an old block, and we are not still using it,
1149 +                * we now release the old block.
1150 +               */
1151 +               unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
1152 +
1153 +               error = ext3_journal_get_write_access(handle, old_bh);
1154 +               if (error)
1155 +                       goto cleanup;
1156 +               if (refcount == 1) {
1157 +                       /* Free the old block. */
1158 +                       ea_bdebug(old_bh, "freeing");
1159 +                       ext3_xattr_free_block(handle, inode, old_bh->b_blocknr);
1160 +
1161 +                       /* ext3_forget() calls bforget() for us, but we
1162 +                          let our caller release old_bh, so we need to
1163 +                          duplicate the handle before. */
1164 +                       get_bh(old_bh);
1165 +                       ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr);
1166 +               } else {
1167 +                       /* Decrement the refcount only. */
1168 +                       refcount--;
1169 +                       HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
1170 +                       ext3_xattr_quota_free(inode);
1171 +                       ext3_journal_dirty_metadata(handle, old_bh);
1172 +                       ea_bdebug(old_bh, "refcount now=%d", refcount);
1173 +               }
1174 +       }
1175 +
1176 +cleanup:
1177 +       if (old_bh != new_bh)
1178 +               brelse(new_bh);
1179 +
1180 +       return error;
1181 +}
1182 +
1183 +/*
1184 + * ext3_xattr_drop_inode()
1185 + *
1186 + * Free extended attribute resources associated with this inode. This
1187 + * is called immediately before an inode is freed.
1188 + */
1189 +void
1190 +ext3_xattr_drop_inode(handle_t *handle, struct inode *inode)
1191 +{
1192 +       struct buffer_head *bh;
1193 +       unsigned int block = EXT3_I(inode)->i_file_acl;
1194 +
1195 +       if (!block)
1196 +               return;
1197 +       ext3_xattr_lock();
1198 +
1199 +       bh = sb_bread(inode->i_sb, block);
1200 +       if (!bh) {
1201 +               ext3_error(inode->i_sb, "ext3_xattr_drop_inode",
1202 +                       "inode %ld: block %d read error", inode->i_ino, block);
1203 +               goto cleanup;
1204 +       }
1205 +       ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
1206 +       if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
1207 +           HDR(bh)->h_blocks != cpu_to_le32(1)) {
1208 +               ext3_error(inode->i_sb, "ext3_xattr_drop_inode",
1209 +                       "inode %ld: bad block %d", inode->i_ino, block);
1210 +               goto cleanup;
1211 +       }
1212 +       ext3_journal_get_write_access(handle, bh);
1213 +       ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
1214 +       if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
1215 +               ext3_xattr_cache_remove(bh);
1216 +               ext3_xattr_free_block(handle, inode, block);
1217 +               ext3_forget(handle, 1, inode, bh, block);
1218 +               bh = NULL;
1219 +       } else {
1220 +               HDR(bh)->h_refcount = cpu_to_le32(
1221 +                       le32_to_cpu(HDR(bh)->h_refcount) - 1);
1222 +               ext3_journal_dirty_metadata(handle, bh);
1223 +               if (IS_SYNC(inode))
1224 +                       handle->h_sync = 1;
1225 +               ext3_xattr_quota_free(inode);
1226 +       }
1227 +       EXT3_I(inode)->i_file_acl = 0;
1228 +
1229 +cleanup:
1230 +       brelse(bh);
1231 +       ext3_xattr_unlock();
1232 +}
1233 +
1234 +/*
1235 + * ext3_xattr_put_super()
1236 + *
1237 + * This is called when a file system is unmounted.
1238 + */
1239 +void
1240 +ext3_xattr_put_super(struct super_block *sb)
1241 +{
1242 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
1243 +       mb_cache_shrink(ext3_xattr_cache, sb->s_dev);
1244 +#endif
1245 +}
1246 +
1247 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
1248 +
1249 +/*
1250 + * ext3_xattr_cache_insert()
1251 + *
1252 + * Create a new entry in the extended attribute cache, and insert
1253 + * it unless such an entry is already in the cache.
1254 + *
1255 + * Returns 0, or a negative error number on failure.
1256 + */
1257 +static int
1258 +ext3_xattr_cache_insert(struct buffer_head *bh)
1259 +{
1260 +       __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
1261 +       struct mb_cache_entry *ce;
1262 +       int error;
1263 +
1264 +       ce = mb_cache_entry_alloc(ext3_xattr_cache);
1265 +       if (!ce)
1266 +               return -ENOMEM;
1267 +       error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
1268 +       if (error) {
1269 +               mb_cache_entry_free(ce);
1270 +               if (error == -EBUSY) {
1271 +                       ea_bdebug(bh, "already in cache (%d cache entries)",
1272 +                               atomic_read(&ext3_xattr_cache->c_entry_count));
1273 +                       error = 0;
1274 +               }
1275 +       } else {
1276 +               ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
1277 +                         atomic_read(&ext3_xattr_cache->c_entry_count));
1278 +               mb_cache_entry_release(ce);
1279 +       }
1280 +       return error;
1281 +}
1282 +
1283 +/*
1284 + * ext3_xattr_cmp()
1285 + *
1286 + * Compare two extended attribute blocks for equality.
1287 + *
1288 + * Returns 0 if the blocks are equal, 1 if they differ, and
1289 + * a negative error number on errors.
1290 + */
1291 +static int
1292 +ext3_xattr_cmp(struct ext3_xattr_header *header1,
1293 +              struct ext3_xattr_header *header2)
1294 +{
1295 +       struct ext3_xattr_entry *entry1, *entry2;
1296 +
1297 +       entry1 = ENTRY(header1+1);
1298 +       entry2 = ENTRY(header2+1);
1299 +       while (!IS_LAST_ENTRY(entry1)) {
1300 +               if (IS_LAST_ENTRY(entry2))
1301 +                       return 1;
1302 +               if (entry1->e_hash != entry2->e_hash ||
1303 +                   entry1->e_name_len != entry2->e_name_len ||
1304 +                   entry1->e_value_size != entry2->e_value_size ||
1305 +                   memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1306 +                       return 1;
1307 +               if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1308 +                       return -EIO;
1309 +               if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1310 +                          (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1311 +                          le32_to_cpu(entry1->e_value_size)))
1312 +                       return 1;
1313 +
1314 +               entry1 = EXT3_XATTR_NEXT(entry1);
1315 +               entry2 = EXT3_XATTR_NEXT(entry2);
1316 +       }
1317 +       if (!IS_LAST_ENTRY(entry2))
1318 +               return 1;
1319 +       return 0;
1320 +}
1321 +
1322 +/*
1323 + * ext3_xattr_cache_find()
1324 + *
1325 + * Find an identical extended attribute block.
1326 + *
1327 + * Returns a pointer to the block found, or NULL if such a block was
1328 + * not found or an error occurred.
1329 + */
1330 +static struct buffer_head *
1331 +ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header)
1332 +{
1333 +       __u32 hash = le32_to_cpu(header->h_hash);
1334 +       struct mb_cache_entry *ce;
1335 +
1336 +       if (!header->h_hash)
1337 +               return NULL;  /* never share */
1338 +       ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
1339 +       ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash);
1340 +       while (ce) {
1341 +               struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
1342 +
1343 +               if (!bh) {
1344 +                       ext3_error(inode->i_sb, "ext3_xattr_cache_find",
1345 +                               "inode %ld: block %ld read error",
1346 +                               inode->i_ino, ce->e_block);
1347 +               } else if (le32_to_cpu(HDR(bh)->h_refcount) >
1348 +                          EXT3_XATTR_REFCOUNT_MAX) {
1349 +                       ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
1350 +                               le32_to_cpu(HDR(bh)->h_refcount),
1351 +                               EXT3_XATTR_REFCOUNT_MAX);
1352 +               } else if (!ext3_xattr_cmp(header, HDR(bh))) {
1353 +                       ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
1354 +                       mb_cache_entry_release(ce);
1355 +                       return bh;
1356 +               }
1357 +               brelse(bh);
1358 +               ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
1359 +       }
1360 +       return NULL;
1361 +}
1362 +
1363 +/*
1364 + * ext3_xattr_cache_remove()
1365 + *
1366 + * Remove the cache entry of a block from the cache. Called when a
1367 + * block becomes invalid.
1368 + */
1369 +static void
1370 +ext3_xattr_cache_remove(struct buffer_head *bh)
1371 +{
1372 +       struct mb_cache_entry *ce;
1373 +
1374 +       ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr);
1375 +       if (ce) {
1376 +               ea_bdebug(bh, "removing (%d cache entries remaining)",
1377 +                         atomic_read(&ext3_xattr_cache->c_entry_count)-1);
1378 +               mb_cache_entry_free(ce);
1379 +       } else 
1380 +               ea_bdebug(bh, "no cache entry");
1381 +}
1382 +
1383 +#define NAME_HASH_SHIFT 5
1384 +#define VALUE_HASH_SHIFT 16
1385 +
1386 +/*
1387 + * ext3_xattr_hash_entry()
1388 + *
1389 + * Compute the hash of an extended attribute.
1390 + */
1391 +static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
1392 +                                        struct ext3_xattr_entry *entry)
1393 +{
1394 +       __u32 hash = 0;
1395 +       char *name = entry->e_name;
1396 +       int n;
1397 +
1398 +       for (n=0; n < entry->e_name_len; n++) {
1399 +               hash = (hash << NAME_HASH_SHIFT) ^
1400 +                      (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
1401 +                      *name++;
1402 +       }
1403 +
1404 +       if (entry->e_value_block == 0 && entry->e_value_size != 0) {
1405 +               __u32 *value = (__u32 *)((char *)header +
1406 +                       le16_to_cpu(entry->e_value_offs));
1407 +               for (n = (le32_to_cpu(entry->e_value_size) +
1408 +                    EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
1409 +                       hash = (hash << VALUE_HASH_SHIFT) ^
1410 +                              (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
1411 +                              le32_to_cpu(*value++);
1412 +               }
1413 +       }
1414 +       entry->e_hash = cpu_to_le32(hash);
1415 +}
1416 +
1417 +#undef NAME_HASH_SHIFT
1418 +#undef VALUE_HASH_SHIFT
1419 +
1420 +#define BLOCK_HASH_SHIFT 16
1421 +
1422 +/*
1423 + * ext3_xattr_rehash()
1424 + *
1425 + * Re-compute the extended attribute hash value after an entry has changed.
1426 + */
1427 +static void ext3_xattr_rehash(struct ext3_xattr_header *header,
1428 +                             struct ext3_xattr_entry *entry)
1429 +{
1430 +       struct ext3_xattr_entry *here;
1431 +       __u32 hash = 0;
1432 +       
1433 +       ext3_xattr_hash_entry(header, entry);
1434 +       here = ENTRY(header+1);
1435 +       while (!IS_LAST_ENTRY(here)) {
1436 +               if (!here->e_hash) {
1437 +                       /* Block is not shared if an entry's hash value == 0 */
1438 +                       hash = 0;
1439 +                       break;
1440 +               }
1441 +               hash = (hash << BLOCK_HASH_SHIFT) ^
1442 +                      (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
1443 +                      le32_to_cpu(here->e_hash);
1444 +               here = EXT3_XATTR_NEXT(here);
1445 +       }
1446 +       header->h_hash = cpu_to_le32(hash);
1447 +}
1448 +
1449 +#undef BLOCK_HASH_SHIFT
1450 +
1451 +int __init
1452 +init_ext3_xattr(void)
1453 +{
1454 +       ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
1455 +               sizeof(struct mb_cache_entry) +
1456 +               sizeof(struct mb_cache_entry_index), 1, 61);
1457 +       if (!ext3_xattr_cache)
1458 +               return -ENOMEM;
1459 +
1460 +       return 0;
1461 +}
1462 +
1463 +void
1464 +exit_ext3_xattr(void)
1465 +{
1466 +       if (ext3_xattr_cache)
1467 +               mb_cache_destroy(ext3_xattr_cache);
1468 +       ext3_xattr_cache = NULL;
1469 +}
1470 +
1471 +#else  /* CONFIG_EXT3_FS_XATTR_SHARING */
1472 +
1473 +int __init
1474 +init_ext3_xattr(void)
1475 +{
1476 +       return 0;
1477 +}
1478 +
1479 +void
1480 +exit_ext3_xattr(void)
1481 +{
1482 +}
1483 +
1484 +#endif  /* CONFIG_EXT3_FS_XATTR_SHARING */
1485 --- linux-2.4.18/include/linux/ext3_fs.h~linux-2.4.18ea-0.8.26-2        2003-09-01 11:51:00.000000000 +0400
1486 +++ linux-2.4.18-alexey/include/linux/ext3_fs.h 2003-09-01 14:55:39.000000000 +0400
1487 @@ -63,8 +63,6 @@
1488   */
1489  #define        EXT3_BAD_INO             1      /* Bad blocks inode */
1490  #define EXT3_ROOT_INO           2      /* Root inode */
1491 -#define EXT3_ACL_IDX_INO        3      /* ACL inode */
1492 -#define EXT3_ACL_DATA_INO       4      /* ACL inode */
1493  #define EXT3_BOOT_LOADER_INO    5      /* Boot loader inode */
1494  #define EXT3_UNDEL_DIR_INO      6      /* Undelete directory inode */
1495  #define EXT3_RESIZE_INO                 7      /* Reserved group descriptors inode */
1496 @@ -94,7 +92,6 @@
1497  #else
1498  # define EXT3_BLOCK_SIZE(s)            (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
1499  #endif
1500 -#define EXT3_ACLE_PER_BLOCK(s)         (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
1501  #define        EXT3_ADDR_PER_BLOCK(s)          (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
1502  #ifdef __KERNEL__
1503  # define EXT3_BLOCK_SIZE_BITS(s)       ((s)->s_blocksize_bits)
1504 @@ -129,28 +126,6 @@
1505  #endif
1506  
1507  /*
1508 - * ACL structures
1509 - */
1510 -struct ext3_acl_header /* Header of Access Control Lists */
1511 -{
1512 -       __u32   aclh_size;
1513 -       __u32   aclh_file_count;
1514 -       __u32   aclh_acle_count;
1515 -       __u32   aclh_first_acle;
1516 -};
1517 -
1518 -struct ext3_acl_entry  /* Access Control List Entry */
1519 -{
1520 -       __u32   acle_size;
1521 -       __u16   acle_perms;     /* Access permissions */
1522 -       __u16   acle_type;      /* Type of entry */
1523 -       __u16   acle_tag;       /* User or group identity */
1524 -       __u16   acle_pad1;
1525 -       __u32   acle_next;      /* Pointer on next entry for the */
1526 -                                       /* same inode or on next free entry */
1527 -};
1528 -
1529 -/*
1530   * Structure of a blocks group descriptor
1531   */
1532  struct ext3_group_desc
1533 @@ -521,7 +496,7 @@ struct ext3_super_block {
1534  #define EXT3_FEATURE_INCOMPAT_RECOVER          0x0004 /* Needs recovery */
1535  #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV      0x0008 /* Journal device */
1536  
1537 -#define EXT3_FEATURE_COMPAT_SUPP       0
1538 +#define EXT3_FEATURE_COMPAT_SUPP       EXT3_FEATURE_COMPAT_EXT_ATTR
1539  #define EXT3_FEATURE_INCOMPAT_SUPP     (EXT3_FEATURE_INCOMPAT_FILETYPE| \
1540                                          EXT3_FEATURE_INCOMPAT_RECOVER)
1541  #define EXT3_FEATURE_RO_COMPAT_SUPP    (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
1542 @@ -623,6 +598,24 @@ struct dx_hash_info
1543  #define HASH_NB_ALWAYS         1
1544  
1545  
1546 +/* Defined for extended attributes */
1547 +#define CONFIG_EXT3_FS_XATTR y
1548 +#ifndef ENOATTR
1549 +#define ENOATTR ENODATA                /* No such attribute */
1550 +#endif
1551 +#ifndef ENOTSUP
1552 +#define ENOTSUP EOPNOTSUPP     /* Operation not supported */
1553 +#endif
1554 +#ifndef XATTR_NAME_MAX
1555 +#define XATTR_NAME_MAX   255   /* # chars in an extended attribute name */
1556 +#define XATTR_SIZE_MAX 65536   /* size of an extended attribute value (64k) */
1557 +#define XATTR_LIST_MAX 65536   /* size of extended attribute namelist (64k) */
1558 +#endif
1559 +#ifndef XATTR_CREATE
1560 +#define XATTR_CREATE   1       /* set value, fail if attr already exists */
1561 +#define XATTR_REPLACE  2       /* set value, fail if attr does not exist */
1562 +#endif
1563 +
1564  /*
1565   * Describe an inode's exact location on disk and in memory
1566   */
1567 @@ -704,6 +697,7 @@ extern void ext3_check_inodes_bitmap (st
1568  extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
1569  
1570  /* inode.c */
1571 +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
1572  extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
1573  extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
1574  
1575 --- linux-2.4.18/include/linux/ext3_jbd.h~linux-2.4.18ea-0.8.26-2       2003-08-29 16:53:17.000000000 +0400
1576 +++ linux-2.4.18-alexey/include/linux/ext3_jbd.h        2003-09-01 14:55:39.000000000 +0400
1577 @@ -30,13 +30,19 @@
1578  
1579  #define EXT3_SINGLEDATA_TRANS_BLOCKS   8
1580  
1581 +/* Extended attributes may touch two data buffers, two bitmap buffers,
1582 + * and two group and summaries. */
1583 +
1584 +#define EXT3_XATTR_TRANS_BLOCKS                8
1585 +
1586  /* Define the minimum size for a transaction which modifies data.  This
1587   * needs to take into account the fact that we may end up modifying two
1588   * quota files too (one for the group, one for the user quota).  The
1589   * superblock only gets updated once, of course, so don't bother
1590   * counting that again for the quota updates. */
1591  
1592 -#define EXT3_DATA_TRANS_BLOCKS         (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2)
1593 +#define EXT3_DATA_TRANS_BLOCKS         (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \
1594 +                                        EXT3_XATTR_TRANS_BLOCKS - 2)
1595  
1596  extern int ext3_writepage_trans_blocks(struct inode *inode);
1597  
1598 --- /dev/null   2003-01-30 13:24:37.000000000 +0300
1599 +++ linux-2.4.18-alexey/include/linux/ext3_xattr.h      2003-09-01 14:55:39.000000000 +0400
1600 @@ -0,0 +1,155 @@
1601 +/*
1602 +  File: linux/ext3_xattr.h
1603 +
1604 +  On-disk format of extended attributes for the ext3 filesystem.
1605 +
1606 +  (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
1607 +*/
1608 +
1609 +#include <linux/config.h>
1610 +#include <linux/init.h>
1611 +#include <linux/xattr.h>
1612 +
1613 +/* Magic value in attribute blocks */
1614 +#define EXT3_XATTR_MAGIC               0xEA020000
1615 +
1616 +/* Maximum number of references to one attribute block */
1617 +#define EXT3_XATTR_REFCOUNT_MAX                1024
1618 +
1619 +/* Name indexes */
1620 +#define EXT3_XATTR_INDEX_MAX                   10
1621 +#define EXT3_XATTR_INDEX_USER                  1
1622 +
1623 +struct ext3_xattr_header {
1624 +       __u32   h_magic;        /* magic number for identification */
1625 +       __u32   h_refcount;     /* reference count */
1626 +       __u32   h_blocks;       /* number of disk blocks used */
1627 +       __u32   h_hash;         /* hash value of all attributes */
1628 +       __u32   h_reserved[4];  /* zero right now */
1629 +};
1630 +
1631 +struct ext3_xattr_entry {
1632 +       __u8    e_name_len;     /* length of name */
1633 +       __u8    e_name_index;   /* attribute name index */
1634 +       __u16   e_value_offs;   /* offset in disk block of value */
1635 +       __u32   e_value_block;  /* disk block attribute is stored on (n/i) */
1636 +       __u32   e_value_size;   /* size of attribute value */
1637 +       __u32   e_hash;         /* hash value of name and value */
1638 +       char    e_name[0];      /* attribute name */
1639 +};
1640 +
1641 +#define EXT3_XATTR_PAD_BITS            2
1642 +#define EXT3_XATTR_PAD         (1<<EXT3_XATTR_PAD_BITS)
1643 +#define EXT3_XATTR_ROUND               (EXT3_XATTR_PAD-1)
1644 +#define EXT3_XATTR_LEN(name_len) \
1645 +       (((name_len) + EXT3_XATTR_ROUND + \
1646 +       sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
1647 +#define EXT3_XATTR_NEXT(entry) \
1648 +       ( (struct ext3_xattr_entry *)( \
1649 +         (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
1650 +#define EXT3_XATTR_SIZE(size) \
1651 +       (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
1652 +
1653 +#ifdef __KERNEL__
1654 +
1655 +# ifdef CONFIG_EXT3_FS_XATTR
1656 +
1657 +struct ext3_xattr_handler {
1658 +       char *prefix;
1659 +       size_t (*list)(char *list, struct inode *inode, const char *name,
1660 +                      int name_len);
1661 +       int (*get)(struct inode *inode, const char *name, void *buffer,
1662 +                  size_t size);
1663 +       int (*set)(struct inode *inode, const char *name, void *buffer,
1664 +                  size_t size, int flags);
1665 +};
1666 +
1667 +extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
1668 +extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
1669 +
1670 +extern int ext3_setxattr(struct dentry *, const char *, void *, size_t, int);
1671 +extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
1672 +extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
1673 +extern int ext3_removexattr(struct dentry *, const char *);
1674 +
1675 +extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
1676 +extern int ext3_xattr_list(struct inode *, char *, size_t);
1677 +extern int ext3_xattr_set(handle_t *handle, struct inode *, int, const char *, void *, size_t, int);
1678 +
1679 +extern void ext3_xattr_drop_inode(handle_t *, struct inode *);
1680 +extern void ext3_xattr_put_super(struct super_block *);
1681 +
1682 +extern int init_ext3_xattr(void) __init;
1683 +extern void exit_ext3_xattr(void);
1684 +
1685 +# else  /* CONFIG_EXT3_FS_XATTR */
1686 +#  define ext3_setxattr                NULL
1687 +#  define ext3_getxattr                NULL
1688 +#  define ext3_listxattr       NULL
1689 +#  define ext3_removexattr     NULL
1690 +
1691 +static inline int
1692 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
1693 +              void *buffer, size_t size, int flags)
1694 +{
1695 +       return -ENOTSUP;
1696 +}
1697 +
1698 +static inline int
1699 +ext3_xattr_list(struct inode *inode, void *buffer, size_t size, int flags)
1700 +{
1701 +       return -ENOTSUP;
1702 +}
1703 +
1704 +static inline int
1705 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
1706 +              const char *name, void *value, size_t size, int flags)
1707 +{
1708 +       return -ENOTSUP;
1709 +}
1710 +
1711 +static inline void
1712 +ext3_xattr_drop_inode(handle_t *handle, struct inode *inode)
1713 +{
1714 +}
1715 +
1716 +static inline void
1717 +ext3_xattr_put_super(struct super_block *sb)
1718 +{
1719 +}
1720 +
1721 +static inline int
1722 +init_ext3_xattr(void)
1723 +{
1724 +       return 0;
1725 +}
1726 +
1727 +static inline void
1728 +exit_ext3_xattr(void)
1729 +{
1730 +}
1731 +
1732 +# endif  /* CONFIG_EXT3_FS_XATTR */
1733 +
1734 +# ifdef CONFIG_EXT3_FS_XATTR_USER
1735 +
1736 +extern int init_ext3_xattr_user(void) __init;
1737 +extern void exit_ext3_xattr_user(void);
1738 +
1739 +# else  /* CONFIG_EXT3_FS_XATTR_USER */
1740 +
1741 +static inline int
1742 +init_ext3_xattr_user(void)
1743 +{
1744 +       return 0;
1745 +}
1746 +
1747 +static inline void
1748 +exit_ext3_xattr_user(void)
1749 +{
1750 +}
1751 +
1752 +#endif  /* CONFIG_EXT3_FS_XATTR_USER */
1753 +
1754 +#endif  /* __KERNEL__ */
1755 +
1756 --- /dev/null   2003-01-30 13:24:37.000000000 +0300
1757 +++ linux-2.4.18-alexey/include/linux/xattr.h   2003-09-01 14:55:39.000000000 +0400
1758 @@ -0,0 +1,15 @@
1759 +/*
1760 +  File: linux/xattr.h
1761 +
1762 +  Extended attributes handling.
1763 +
1764 +  Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
1765 +  Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
1766 +*/
1767 +#ifndef _LINUX_XATTR_H
1768 +#define _LINUX_XATTR_H
1769 +
1770 +#define XATTR_CREATE   1       /* set value, fail if attr already exists */
1771 +#define XATTR_REPLACE  2       /* set value, fail if attr does not exist */
1772 +
1773 +#endif /* _LINUX_XATTR_H */
1774
1775 _