1 Documentation/Configure.help | 66 ++
2 arch/alpha/defconfig | 7
3 arch/alpha/kernel/entry.S | 12
5 arch/arm/kernel/calls.S | 24
6 arch/i386/defconfig | 7
7 arch/ia64/defconfig | 7
8 arch/ia64/kernel/entry.S | 24
9 arch/m68k/defconfig | 7
10 arch/mips/defconfig | 7
11 arch/mips64/defconfig | 7
12 arch/ppc/defconfig | 14
13 arch/ppc64/kernel/misc.S | 2
14 arch/s390/defconfig | 7
15 arch/s390/kernel/entry.S | 24
16 arch/s390x/defconfig | 7
17 arch/s390x/kernel/entry.S | 24
18 arch/s390x/kernel/wrapper32.S | 92 +++
19 arch/sparc/defconfig | 7
20 arch/sparc/kernel/systbls.S | 10
21 arch/sparc64/defconfig | 7
22 arch/sparc64/kernel/systbls.S | 20
28 fs/ext2/inode.c | 34 -
31 fs/ext2/symlink.c | 14
32 fs/ext2/xattr.c | 1212 +++++++++++++++++++++++++++++++++++++++++
33 fs/ext2/xattr_user.c | 103 +++
37 fs/ext3/inode.c | 35 -
39 fs/ext3/super.c | 36 +
40 fs/ext3/symlink.c | 14
41 fs/ext3/xattr.c | 1225 ++++++++++++++++++++++++++++++++++++++++++
42 fs/ext3/xattr_user.c | 111 +++
43 fs/jfs/jfs_xattr.h | 6
45 fs/mbcache.c | 648 ++++++++++++++++++++++
46 include/asm-arm/unistd.h | 2
47 include/asm-ia64/unistd.h | 13
48 include/asm-ppc64/unistd.h | 2
49 include/asm-s390/unistd.h | 15
50 include/asm-s390x/unistd.h | 15
51 include/asm-sparc/unistd.h | 24
52 include/asm-sparc64/unistd.h | 24
53 include/linux/cache_def.h | 15
54 include/linux/errno.h | 4
55 include/linux/ext2_fs.h | 31 -
56 include/linux/ext2_xattr.h | 157 +++++
57 include/linux/ext3_fs.h | 31 -
58 include/linux/ext3_jbd.h | 8
59 include/linux/ext3_xattr.h | 157 +++++
60 include/linux/fs.h | 2
61 include/linux/mbcache.h | 69 ++
64 fs/ext3/ext3-exports.c | 14 +
65 64 files changed, 4355 insertions(+), 195 deletions(-)
67 Index: linux-2.4.22-vanilla/Documentation/Configure.help
68 ===================================================================
69 --- linux-2.4.22-vanilla.orig/Documentation/Configure.help 2003-11-03 23:41:26.000000000 +0300
70 +++ linux-2.4.22-vanilla/Documentation/Configure.help 2003-12-02 23:55:38.000000000 +0300
71 @@ -15613,6 +15613,39 @@
72 be compiled as a module, and so this could be dangerous. Most
73 everyone wants to say Y here.
75 +Ext2 extended attributes
77 + Extended attributes are name:value pairs associated with inodes by
78 + the kernel or by users (see the attr(5) manual page, or visit
79 + <http://acl.bestbits.at/> for details).
83 +Ext2 extended attribute block sharing
84 +CONFIG_EXT2_FS_XATTR_SHARING
85 + This options enables code for sharing identical extended attribute
86 + blocks among multiple inodes.
90 +Ext2 extended user attributes
91 +CONFIG_EXT2_FS_XATTR_USER
92 + This option enables extended user attributes on ext2. Processes can
93 + associate extended user attributes with inodes to store additional
94 + information such as the character encoding of files, etc. (see the
95 + attr(5) manual page, or visit <http://acl.bestbits.at/> for details).
99 +Ext2 trusted extended attributes
100 +CONFIG_EXT2_FS_XATTR_TRUSTED
101 + This option enables extended attributes on ext2 that are accessible
102 + (and visible) only to users capable of CAP_SYS_ADMIN. Usually this
103 + is only the super user. Trusted extended attributes are meant for
104 + implementing system/security services.
108 Ext3 journalling file system support (EXPERIMENTAL)
110 This is the journalling version of the Second extended file system
111 @@ -15645,6 +15678,39 @@
112 of your root partition (the one containing the directory /) cannot
113 be compiled as a module, and so this may be dangerous.
115 +Ext3 extended attributes
116 +CONFIG_EXT3_FS_XATTR
117 + Extended attributes are name:value pairs associated with inodes by
118 + the kernel or by users (see the attr(5) manual page, or visit
119 + <http://acl.bestbits.at/> for details).
123 +Ext3 extended attribute block sharing
124 +CONFIG_EXT3_FS_XATTR_SHARING
125 + This options enables code for sharing identical extended attribute
126 + blocks among multiple inodes.
130 +Ext3 extended user attributes
131 +CONFIG_EXT3_FS_XATTR_USER
132 + This option enables extended user attributes on ext3. Processes can
133 + associate extended user attributes with inodes to store additional
134 + information such as the character encoding of files, etc. (see the
135 + attr(5) manual page, or visit <http://acl.bestbits.at/> for details).
139 +Ext3 trusted extended attributes
140 +CONFIG_EXT3_FS_XATTR_TRUSTED
141 + This option enables extended attributes on ext3 that are accessible
142 + (and visible) only to users capable of CAP_SYS_ADMIN. Usually this
143 + is only the super user. Trusted extended attributes are meant for
144 + implementing system/security services.
148 Journal Block Device support (JBD for ext3) (EXPERIMENTAL)
150 This is a generic journalling layer for block devices. It is
151 Index: linux-2.4.22-vanilla/arch/alpha/defconfig
152 ===================================================================
153 --- linux-2.4.22-vanilla.orig/arch/alpha/defconfig 2003-11-03 23:41:26.000000000 +0300
154 +++ linux-2.4.22-vanilla/arch/alpha/defconfig 2003-12-02 23:55:38.000000000 +0300
157 # Automatically generated make config: don't edit
159 +CONFIG_EXT3_FS_XATTR=y
160 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
161 +# CONFIG_EXT3_FS_XATTR_USER is not set
162 +# CONFIG_EXT2_FS_XATTR is not set
163 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
164 +# CONFIG_EXT2_FS_XATTR_USER is not set
165 +# CONFIG_FS_MBCACHE is not set
167 # CONFIG_UID16 is not set
168 # CONFIG_RWSEM_GENERIC_SPINLOCK is not set
169 Index: linux-2.4.22-vanilla/arch/alpha/kernel/entry.S
170 ===================================================================
171 --- linux-2.4.22-vanilla.orig/arch/alpha/kernel/entry.S 2003-11-03 23:41:26.000000000 +0300
172 +++ linux-2.4.22-vanilla/arch/alpha/kernel/entry.S 2003-12-02 23:55:38.000000000 +0300
173 @@ -1154,6 +1154,18 @@
175 .quad sys_ni_syscall /* 380, sys_security */
178 + .quad sys_lsetxattr
179 + .quad sys_fsetxattr
180 + .quad sys_getxattr /* 385 */
181 + .quad sys_lgetxattr
182 + .quad sys_fgetxattr
183 + .quad sys_listxattr
184 + .quad sys_llistxattr
185 + .quad sys_flistxattr /* 390 */
186 + .quad sys_removexattr
187 + .quad sys_lremovexattr
188 + .quad sys_fremovexattr
190 /* Remember to update everything, kids. */
191 .ifne (. - sys_call_table) - (NR_SYSCALLS * 8)
192 Index: linux-2.4.22-vanilla/arch/arm/defconfig
193 ===================================================================
194 --- linux-2.4.22-vanilla.orig/arch/arm/defconfig 2003-11-03 23:41:26.000000000 +0300
195 +++ linux-2.4.22-vanilla/arch/arm/defconfig 2003-12-02 23:55:38.000000000 +0300
198 # Automatically generated make config: don't edit
200 +CONFIG_EXT3_FS_XATTR=y
201 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
202 +# CONFIG_EXT3_FS_XATTR_USER is not set
203 +# CONFIG_EXT2_FS_XATTR is not set
204 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
205 +# CONFIG_EXT2_FS_XATTR_USER is not set
206 +# CONFIG_FS_MBCACHE is not set
208 # CONFIG_EISA is not set
209 # CONFIG_SBUS is not set
210 Index: linux-2.4.22-vanilla/arch/arm/kernel/calls.S
211 ===================================================================
212 --- linux-2.4.22-vanilla.orig/arch/arm/kernel/calls.S 2003-11-03 23:41:26.000000000 +0300
213 +++ linux-2.4.22-vanilla/arch/arm/kernel/calls.S 2003-12-02 23:55:38.000000000 +0300
214 @@ -240,18 +240,18 @@
215 .long SYMBOL_NAME(sys_ni_syscall) /* Security */
216 .long SYMBOL_NAME(sys_gettid)
217 /* 225 */ .long SYMBOL_NAME(sys_readahead)
218 - .long SYMBOL_NAME(sys_ni_syscall) /* setxattr */
219 - .long SYMBOL_NAME(sys_ni_syscall) /* lsetxattr */
220 - .long SYMBOL_NAME(sys_ni_syscall) /* fsetxattr */
221 - .long SYMBOL_NAME(sys_ni_syscall) /* getxattr */
222 -/* 230 */ .long SYMBOL_NAME(sys_ni_syscall) /* lgetxattr */
223 - .long SYMBOL_NAME(sys_ni_syscall) /* fgetxattr */
224 - .long SYMBOL_NAME(sys_ni_syscall) /* listxattr */
225 - .long SYMBOL_NAME(sys_ni_syscall) /* llistxattr */
226 - .long SYMBOL_NAME(sys_ni_syscall) /* flistxattr */
227 -/* 235 */ .long SYMBOL_NAME(sys_ni_syscall) /* removexattr */
228 - .long SYMBOL_NAME(sys_ni_syscall) /* lremovexattr */
229 - .long SYMBOL_NAME(sys_ni_syscall) /* fremovexattr */
230 + .long SYMBOL_NAME(sys_setxattr)
231 + .long SYMBOL_NAME(sys_lsetxattr)
232 + .long SYMBOL_NAME(sys_fsetxattr)
233 + .long SYMBOL_NAME(sys_getxattr)
234 +/* 230 */ .long SYMBOL_NAME(sys_lgetxattr)
235 + .long SYMBOL_NAME(sys_fgetxattr)
236 + .long SYMBOL_NAME(sys_listxattr)
237 + .long SYMBOL_NAME(sys_llistxattr)
238 + .long SYMBOL_NAME(sys_flistxattr)
239 +/* 235 */ .long SYMBOL_NAME(sys_removexattr)
240 + .long SYMBOL_NAME(sys_lremovexattr)
241 + .long SYMBOL_NAME(sys_fremovexattr)
242 .long SYMBOL_NAME(sys_tkill)
243 .long SYMBOL_NAME(sys_ni_syscall) /* sendfile64 */
244 /* 240 */ .long SYMBOL_NAME(sys_ni_syscall) /* futex */
245 Index: linux-2.4.22-vanilla/arch/i386/defconfig
246 ===================================================================
247 --- linux-2.4.22-vanilla.orig/arch/i386/defconfig 2003-11-03 23:41:26.000000000 +0300
248 +++ linux-2.4.22-vanilla/arch/i386/defconfig 2003-12-02 23:55:38.000000000 +0300
251 # Automatically generated make config: don't edit
253 +CONFIG_EXT3_FS_XATTR=y
254 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
255 +# CONFIG_EXT3_FS_XATTR_USER is not set
256 +# CONFIG_EXT2_FS_XATTR is not set
257 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
258 +# CONFIG_EXT2_FS_XATTR_USER is not set
259 +# CONFIG_FS_MBCACHE is not set
262 # CONFIG_SBUS is not set
263 Index: linux-2.4.22-vanilla/arch/ia64/defconfig
264 ===================================================================
265 --- linux-2.4.22-vanilla.orig/arch/ia64/defconfig 2003-11-03 23:41:26.000000000 +0300
266 +++ linux-2.4.22-vanilla/arch/ia64/defconfig 2003-12-02 23:55:38.000000000 +0300
269 # Automatically generated make config: don't edit
271 +CONFIG_EXT3_FS_XATTR=y
272 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
273 +# CONFIG_EXT3_FS_XATTR_USER is not set
274 +# CONFIG_EXT2_FS_XATTR is not set
275 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
276 +# CONFIG_EXT2_FS_XATTR_USER is not set
277 +# CONFIG_FS_MBCACHE is not set
280 # Code maturity level options
281 Index: linux-2.4.22-vanilla/arch/m68k/defconfig
282 ===================================================================
283 --- linux-2.4.22-vanilla.orig/arch/m68k/defconfig 2003-11-03 23:41:26.000000000 +0300
284 +++ linux-2.4.22-vanilla/arch/m68k/defconfig 2003-12-02 23:55:38.000000000 +0300
287 # Automatically generated make config: don't edit
289 +CONFIG_EXT3_FS_XATTR=y
290 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
291 +# CONFIG_EXT3_FS_XATTR_USER is not set
292 +# CONFIG_EXT2_FS_XATTR is not set
293 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
294 +# CONFIG_EXT2_FS_XATTR_USER is not set
295 +# CONFIG_FS_MBCACHE is not set
299 Index: linux-2.4.22-vanilla/arch/mips/defconfig
300 ===================================================================
301 --- linux-2.4.22-vanilla.orig/arch/mips/defconfig 2003-11-03 23:41:26.000000000 +0300
302 +++ linux-2.4.22-vanilla/arch/mips/defconfig 2003-12-02 23:55:38.000000000 +0300
305 # Automatically generated make config: don't edit
307 +CONFIG_EXT3_FS_XATTR=y
308 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
309 +# CONFIG_EXT3_FS_XATTR_USER is not set
310 +# CONFIG_EXT2_FS_XATTR is not set
311 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
312 +# CONFIG_EXT2_FS_XATTR_USER is not set
313 +# CONFIG_FS_MBCACHE is not set
316 # CONFIG_MIPS64 is not set
317 Index: linux-2.4.22-vanilla/arch/mips64/defconfig
318 ===================================================================
319 --- linux-2.4.22-vanilla.orig/arch/mips64/defconfig 2003-11-03 23:41:26.000000000 +0300
320 +++ linux-2.4.22-vanilla/arch/mips64/defconfig 2003-12-02 23:55:38.000000000 +0300
323 # Automatically generated make config: don't edit
325 +CONFIG_EXT3_FS_XATTR=y
326 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
327 +# CONFIG_EXT3_FS_XATTR_USER is not set
328 +# CONFIG_EXT2_FS_XATTR is not set
329 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
330 +# CONFIG_EXT2_FS_XATTR_USER is not set
331 +# CONFIG_FS_MBCACHE is not set
333 # CONFIG_MIPS32 is not set
335 Index: linux-2.4.22-vanilla/arch/s390/defconfig
336 ===================================================================
337 --- linux-2.4.22-vanilla.orig/arch/s390/defconfig 2003-11-03 23:41:26.000000000 +0300
338 +++ linux-2.4.22-vanilla/arch/s390/defconfig 2003-12-02 23:55:38.000000000 +0300
341 # Automatically generated make config: don't edit
343 +CONFIG_EXT3_FS_XATTR=y
344 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
345 +# CONFIG_EXT3_FS_XATTR_USER is not set
346 +# CONFIG_EXT2_FS_XATTR is not set
347 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
348 +# CONFIG_EXT2_FS_XATTR_USER is not set
349 +# CONFIG_FS_MBCACHE is not set
350 # CONFIG_ISA is not set
351 # CONFIG_EISA is not set
352 # CONFIG_MCA is not set
353 Index: linux-2.4.22-vanilla/arch/s390/kernel/entry.S
354 ===================================================================
355 --- linux-2.4.22-vanilla.orig/arch/s390/kernel/entry.S 2003-11-03 23:41:26.000000000 +0300
356 +++ linux-2.4.22-vanilla/arch/s390/kernel/entry.S 2003-12-02 23:55:38.000000000 +0300
357 @@ -558,18 +558,18 @@
361 - .long sys_ni_syscall /* 224 - reserved for setxattr */
362 - .long sys_ni_syscall /* 225 - reserved for lsetxattr */
363 - .long sys_ni_syscall /* 226 - reserved for fsetxattr */
364 - .long sys_ni_syscall /* 227 - reserved for getxattr */
365 - .long sys_ni_syscall /* 228 - reserved for lgetxattr */
366 - .long sys_ni_syscall /* 229 - reserved for fgetxattr */
367 - .long sys_ni_syscall /* 230 - reserved for listxattr */
368 - .long sys_ni_syscall /* 231 - reserved for llistxattr */
369 - .long sys_ni_syscall /* 232 - reserved for flistxattr */
370 - .long sys_ni_syscall /* 233 - reserved for removexattr */
371 - .long sys_ni_syscall /* 234 - reserved for lremovexattr */
372 - .long sys_ni_syscall /* 235 - reserved for fremovexattr */
374 + .long sys_lsetxattr /* 225 */
375 + .long sys_fsetxattr
377 + .long sys_lgetxattr
378 + .long sys_fgetxattr
379 + .long sys_listxattr /* 230 */
380 + .long sys_llistxattr
381 + .long sys_flistxattr
382 + .long sys_removexattr
383 + .long sys_lremovexattr
384 + .long sys_fremovexattr /* 235 */
388 Index: linux-2.4.22-vanilla/arch/s390x/defconfig
389 ===================================================================
390 --- linux-2.4.22-vanilla.orig/arch/s390x/defconfig 2003-11-03 23:41:26.000000000 +0300
391 +++ linux-2.4.22-vanilla/arch/s390x/defconfig 2003-12-02 23:55:38.000000000 +0300
394 # Automatically generated make config: don't edit
396 +CONFIG_EXT3_FS_XATTR=y
397 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
398 +# CONFIG_EXT3_FS_XATTR_USER is not set
399 +# CONFIG_EXT2_FS_XATTR is not set
400 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
401 +# CONFIG_EXT2_FS_XATTR_USER is not set
402 +# CONFIG_FS_MBCACHE is not set
403 # CONFIG_ISA is not set
404 # CONFIG_EISA is not set
405 # CONFIG_MCA is not set
406 Index: linux-2.4.22-vanilla/arch/s390x/kernel/entry.S
407 ===================================================================
408 --- linux-2.4.22-vanilla.orig/arch/s390x/kernel/entry.S 2003-11-03 23:41:26.000000000 +0300
409 +++ linux-2.4.22-vanilla/arch/s390x/kernel/entry.S 2003-12-02 23:55:38.000000000 +0300
410 @@ -591,18 +591,18 @@
411 .long SYSCALL(sys_ni_syscall,sys32_fcntl64_wrapper)
412 .long SYSCALL(sys_readahead,sys32_readahead)
413 .long SYSCALL(sys_ni_syscall,sys_ni_syscall)
414 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 224 - reserved for setxattr */
415 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 225 - reserved for lsetxattr */
416 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 226 - reserved for fsetxattr */
417 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 227 - reserved for getxattr */
418 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 228 - reserved for lgetxattr */
419 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 229 - reserved for fgetxattr */
420 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 230 - reserved for listxattr */
421 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 231 - reserved for llistxattr */
422 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 232 - reserved for flistxattr */
423 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 233 - reserved for removexattr */
424 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 234 - reserved for lremovexattr */
425 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 235 - reserved for fremovexattr */
426 + .long SYSCALL(sys_setxattr,sys32_setxattr_wrapper)
427 + .long SYSCALL(sys_lsetxattr,sys32_lsetxattr_wrapper) /* 225 */
428 + .long SYSCALL(sys_fsetxattr,sys32_fsetxattr_wrapper)
429 + .long SYSCALL(sys_getxattr,sys32_getxattr_wrapper)
430 + .long SYSCALL(sys_lgetxattr,sys32_lgetxattr_wrapper)
431 + .long SYSCALL(sys_fgetxattr,sys32_fgetxattr_wrapper)
432 + .long SYSCALL(sys_listxattr,sys32_listxattr_wrapper) /* 230 */
433 + .long SYSCALL(sys_llistxattr,sys32_llistxattr_wrapper)
434 + .long SYSCALL(sys_flistxattr,sys32_flistxattr_wrapper)
435 + .long SYSCALL(sys_removexattr,sys32_removexattr_wrapper)
436 + .long SYSCALL(sys_lremovexattr,sys32_lremovexattr_wrapper)
437 + .long SYSCALL(sys_fremovexattr,sys32_fremovexattr_wrapper)/* 235 */
438 .long SYSCALL(sys_gettid,sys_gettid)
439 .long SYSCALL(sys_tkill,sys_tkill)
441 Index: linux-2.4.22-vanilla/arch/s390x/kernel/wrapper32.S
442 ===================================================================
443 --- linux-2.4.22-vanilla.orig/arch/s390x/kernel/wrapper32.S 2003-11-03 23:41:26.000000000 +0300
444 +++ linux-2.4.22-vanilla/arch/s390x/kernel/wrapper32.S 2003-12-02 23:55:38.000000000 +0300
445 @@ -1098,6 +1098,98 @@
447 jg sys32_fstat64 # branch to system call
449 + .globl sys32_setxattr_wrapper
450 +sys32_setxattr_wrapper:
451 + llgtr %r2,%r2 # char *
452 + llgtr %r3,%r3 # char *
453 + llgtr %r4,%r4 # void *
454 + llgfr %r5,%r5 # size_t
458 + .globl sys32_lsetxattr_wrapper
459 +sys32_lsetxattr_wrapper:
460 + llgtr %r2,%r2 # char *
461 + llgtr %r3,%r3 # char *
462 + llgtr %r4,%r4 # void *
463 + llgfr %r5,%r5 # size_t
467 + .globl sys32_fsetxattr_wrapper
468 +sys32_fsetxattr_wrapper:
470 + llgtr %r3,%r3 # char *
471 + llgtr %r4,%r4 # void *
472 + llgfr %r5,%r5 # size_t
476 + .globl sys32_getxattr_wrapper
477 +sys32_getxattr_wrapper:
478 + llgtr %r2,%r2 # char *
479 + llgtr %r3,%r3 # char *
480 + llgtr %r4,%r4 # void *
481 + llgfr %r5,%r5 # size_t
484 + .globl sys32_lgetxattr_wrapper
485 +sys32_lgetxattr_wrapper:
486 + llgtr %r2,%r2 # char *
487 + llgtr %r3,%r3 # char *
488 + llgtr %r4,%r4 # void *
489 + llgfr %r5,%r5 # size_t
492 + .globl sys32_fgetxattr_wrapper
493 +sys32_fgetxattr_wrapper:
495 + llgtr %r3,%r3 # char *
496 + llgtr %r4,%r4 # void *
497 + llgfr %r5,%r5 # size_t
500 + .globl sys32_listxattr_wrapper
501 +sys32_listxattr_wrapper:
502 + llgtr %r2,%r2 # char *
503 + llgtr %r3,%r3 # char *
504 + llgfr %r4,%r4 # size_t
507 + .globl sys32_llistxattr_wrapper
508 +sys32_llistxattr_wrapper:
509 + llgtr %r2,%r2 # char *
510 + llgtr %r3,%r3 # char *
511 + llgfr %r4,%r4 # size_t
514 + .globl sys32_flistxattr_wrapper
515 +sys32_flistxattr_wrapper:
517 + llgtr %r3,%r3 # char *
518 + llgfr %r4,%r4 # size_t
521 + .globl sys32_removexattr_wrapper
522 +sys32_removexattr_wrapper:
523 + llgtr %r2,%r2 # char *
524 + llgtr %r3,%r3 # char *
527 + .globl sys32_lremovexattr_wrapper
528 +sys32_lremovexattr_wrapper:
529 + llgtr %r2,%r2 # char *
530 + llgtr %r3,%r3 # char *
531 + jg sys_lremovexattr
533 + .globl sys32_fremovexattr_wrapper
534 +sys32_fremovexattr_wrapper:
536 + llgtr %r3,%r3 # char *
537 + jg sys_fremovexattr
541 .globl sys32_stime_wrapper
543 llgtr %r2,%r2 # int *
544 Index: linux-2.4.22-vanilla/arch/sparc64/defconfig
545 ===================================================================
546 --- linux-2.4.22-vanilla.orig/arch/sparc64/defconfig 2003-11-03 23:41:26.000000000 +0300
547 +++ linux-2.4.22-vanilla/arch/sparc64/defconfig 2003-12-02 23:55:38.000000000 +0300
550 # Automatically generated make config: don't edit
552 +CONFIG_EXT3_FS_XATTR=y
553 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
554 +# CONFIG_EXT3_FS_XATTR_USER is not set
555 +# CONFIG_EXT2_FS_XATTR is not set
556 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
557 +# CONFIG_EXT2_FS_XATTR_USER is not set
558 +# CONFIG_FS_MBCACHE is not set
561 # Code maturity level options
562 Index: linux-2.4.22-vanilla/fs/Config.in
563 ===================================================================
564 --- linux-2.4.22-vanilla.orig/fs/Config.in 2003-11-03 23:41:26.000000000 +0300
565 +++ linux-2.4.22-vanilla/fs/Config.in 2003-12-02 23:55:38.000000000 +0300
567 dep_tristate 'BFS file system support (EXPERIMENTAL)' CONFIG_BFS_FS $CONFIG_EXPERIMENTAL
569 tristate 'Ext3 journalling file system support' CONFIG_EXT3_FS
570 +dep_mbool ' Ext3 extended attributes' CONFIG_EXT3_FS_XATTR $CONFIG_EXT3_FS
571 +dep_bool ' Ext3 extended attribute block sharing' \
572 + CONFIG_EXT3_FS_XATTR_SHARING $CONFIG_EXT3_FS_XATTR
573 +dep_bool ' Ext3 extended user attributes' \
574 + CONFIG_EXT3_FS_XATTR_USER $CONFIG_EXT3_FS_XATTR
575 # CONFIG_JBD could be its own option (even modular), but until there are
576 # other users than ext3, we will simply make it be the same as CONFIG_EXT3_FS
577 # dep_tristate ' Journal Block Device support (JBD for ext3)' CONFIG_JBD $CONFIG_EXT3_FS
579 tristate 'ROM file system support' CONFIG_ROMFS_FS
581 tristate 'Second extended fs support' CONFIG_EXT2_FS
582 +dep_mbool ' Ext2 extended attributes' CONFIG_EXT2_FS_XATTR $CONFIG_EXT2_FS
583 +dep_bool ' Ext2 extended attribute block sharing' \
584 + CONFIG_EXT2_FS_XATTR_SHARING $CONFIG_EXT2_FS_XATTR
585 +dep_bool ' Ext2 extended user attributes' \
586 + CONFIG_EXT2_FS_XATTR_USER $CONFIG_EXT2_FS_XATTR
588 tristate 'System V/Xenix/V7/Coherent file system support' CONFIG_SYSV_FS
591 define_tristate CONFIG_ZISOFS_FS n
594 +# Meta block cache for Extended Attributes (ext2/ext3)
595 +#tristate 'Meta block cache' CONFIG_FS_MBCACHE
596 +define_tristate CONFIG_FS_MBCACHE y
598 mainmenu_option next_comment
599 comment 'Partition Types'
600 source fs/partitions/Config.in
601 Index: linux-2.4.22-vanilla/fs/Makefile
602 ===================================================================
603 --- linux-2.4.22-vanilla.orig/fs/Makefile 2003-12-02 23:55:36.000000000 +0300
604 +++ linux-2.4.22-vanilla/fs/Makefile 2003-12-02 23:55:38.000000000 +0300
607 obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
609 +export-objs += mbcache.o
610 +obj-$(CONFIG_FS_MBCACHE) += mbcache.o
612 # persistent filesystems
613 obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
615 Index: linux-2.4.22-vanilla/fs/ext2/Makefile
616 ===================================================================
617 --- linux-2.4.22-vanilla.orig/fs/ext2/Makefile 2003-11-03 23:41:26.000000000 +0300
618 +++ linux-2.4.22-vanilla/fs/ext2/Makefile 2003-12-02 23:55:38.000000000 +0300
620 ioctl.o namei.o super.o symlink.o
623 +export-objs += xattr.o
624 +obj-$(CONFIG_EXT2_FS_XATTR) += xattr.o
625 +obj-$(CONFIG_EXT2_FS_XATTR_USER) += xattr_user.o
627 include $(TOPDIR)/Rules.make
628 Index: linux-2.4.22-vanilla/fs/ext2/file.c
629 ===================================================================
630 --- linux-2.4.22-vanilla.orig/fs/ext2/file.c 2003-11-03 23:41:26.000000000 +0300
631 +++ linux-2.4.22-vanilla/fs/ext2/file.c 2003-12-02 23:55:38.000000000 +0300
634 #include <linux/fs.h>
635 #include <linux/ext2_fs.h>
636 +#include <linux/ext2_xattr.h>
637 #include <linux/sched.h>
642 struct inode_operations ext2_file_inode_operations = {
643 truncate: ext2_truncate,
644 + setxattr: ext2_setxattr,
645 + getxattr: ext2_getxattr,
646 + listxattr: ext2_listxattr,
647 + removexattr: ext2_removexattr,
649 Index: linux-2.4.22-vanilla/fs/ext2/ialloc.c
650 ===================================================================
651 --- linux-2.4.22-vanilla.orig/fs/ext2/ialloc.c 2003-11-03 23:41:26.000000000 +0300
652 +++ linux-2.4.22-vanilla/fs/ext2/ialloc.c 2003-12-02 23:55:38.000000000 +0300
654 #include <linux/config.h>
655 #include <linux/fs.h>
656 #include <linux/ext2_fs.h>
657 +#include <linux/ext2_xattr.h>
658 #include <linux/locks.h>
659 #include <linux/quotaops.h>
663 if (!is_bad_inode(inode)) {
664 /* Quota is already initialized in iput() */
665 + ext2_xattr_delete_inode(inode);
666 DQUOT_FREE_INODE(inode);
669 Index: linux-2.4.22-vanilla/fs/ext2/inode.c
670 ===================================================================
671 --- linux-2.4.22-vanilla.orig/fs/ext2/inode.c 2003-11-03 23:41:26.000000000 +0300
672 +++ linux-2.4.22-vanilla/fs/ext2/inode.c 2003-12-02 23:55:38.000000000 +0300
674 static int ext2_update_inode(struct inode * inode, int do_sync);
677 + * Test whether an inode is a fast symlink.
679 +static inline int ext2_inode_is_fast_symlink(struct inode *inode)
681 + int ea_blocks = inode->u.ext2_i.i_file_acl ?
682 + (inode->i_sb->s_blocksize >> 9) : 0;
684 + return (S_ISLNK(inode->i_mode) &&
685 + inode->i_blocks - ea_blocks == 0);
689 * Called at each iput()
691 void ext2_put_inode (struct inode * inode)
696 - if (is_bad_inode(inode) ||
697 - inode->i_ino == EXT2_ACL_IDX_INO ||
698 - inode->i_ino == EXT2_ACL_DATA_INO)
699 + if (is_bad_inode(inode))
701 inode->u.ext2_i.i_dtime = CURRENT_TIME;
702 mark_inode_dirty(inode);
704 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
705 S_ISLNK(inode->i_mode)))
707 + if (ext2_inode_is_fast_symlink(inode))
709 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
713 unsigned long offset;
714 struct ext2_group_desc * gdp;
716 - if ((inode->i_ino != EXT2_ROOT_INO && inode->i_ino != EXT2_ACL_IDX_INO &&
717 - inode->i_ino != EXT2_ACL_DATA_INO &&
718 + if ((inode->i_ino != EXT2_ROOT_INO &&
719 inode->i_ino < EXT2_FIRST_INO(inode->i_sb)) ||
720 inode->i_ino > le32_to_cpu(inode->i_sb->u.ext2_sb.s_es->s_inodes_count)) {
721 ext2_error (inode->i_sb, "ext2_read_inode",
722 @@ -989,10 +1000,7 @@
723 for (block = 0; block < EXT2_N_BLOCKS; block++)
724 inode->u.ext2_i.i_data[block] = raw_inode->i_block[block];
726 - if (inode->i_ino == EXT2_ACL_IDX_INO ||
727 - inode->i_ino == EXT2_ACL_DATA_INO)
728 - /* Nothing to do */ ;
729 - else if (S_ISREG(inode->i_mode)) {
730 + if (S_ISREG(inode->i_mode)) {
731 inode->i_op = &ext2_file_inode_operations;
732 inode->i_fop = &ext2_file_operations;
733 inode->i_mapping->a_ops = &ext2_aops;
734 @@ -1001,15 +1009,17 @@
735 inode->i_fop = &ext2_dir_operations;
736 inode->i_mapping->a_ops = &ext2_aops;
737 } else if (S_ISLNK(inode->i_mode)) {
738 - if (!inode->i_blocks)
739 + if (ext2_inode_is_fast_symlink(inode))
740 inode->i_op = &ext2_fast_symlink_inode_operations;
742 - inode->i_op = &page_symlink_inode_operations;
743 + inode->i_op = &ext2_symlink_inode_operations;
744 inode->i_mapping->a_ops = &ext2_aops;
748 + inode->i_op = &ext2_special_inode_operations;
749 init_special_inode(inode, inode->i_mode,
750 le32_to_cpu(raw_inode->i_block[0]));
753 inode->i_attr_flags = 0;
754 ext2_set_inode_flags(inode);
755 Index: linux-2.4.22-vanilla/fs/ext2/namei.c
756 ===================================================================
757 --- linux-2.4.22-vanilla.orig/fs/ext2/namei.c 2003-11-03 23:41:26.000000000 +0300
758 +++ linux-2.4.22-vanilla/fs/ext2/namei.c 2003-12-02 23:55:38.000000000 +0300
761 #include <linux/fs.h>
762 #include <linux/ext2_fs.h>
763 +#include <linux/ext2_xattr.h>
764 #include <linux/pagemap.h>
769 if (l > sizeof (inode->u.ext2_i.i_data)) {
771 - inode->i_op = &page_symlink_inode_operations;
772 + inode->i_op = &ext2_symlink_inode_operations;
773 inode->i_mapping->a_ops = &ext2_aops;
774 err = block_symlink(inode, symname, l);
780 + setxattr: ext2_setxattr,
781 + getxattr: ext2_getxattr,
782 + listxattr: ext2_listxattr,
783 + removexattr: ext2_removexattr,
786 +struct inode_operations ext2_special_inode_operations = {
787 + setxattr: ext2_setxattr,
788 + getxattr: ext2_getxattr,
789 + listxattr: ext2_listxattr,
790 + removexattr: ext2_removexattr,
792 Index: linux-2.4.22-vanilla/fs/ext2/super.c
793 ===================================================================
794 --- linux-2.4.22-vanilla.orig/fs/ext2/super.c 2003-11-03 23:41:26.000000000 +0300
795 +++ linux-2.4.22-vanilla/fs/ext2/super.c 2003-12-02 23:55:38.000000000 +0300
797 #include <linux/string.h>
798 #include <linux/fs.h>
799 #include <linux/ext2_fs.h>
800 +#include <linux/ext2_xattr.h>
801 #include <linux/slab.h>
802 #include <linux/init.h>
803 #include <linux/locks.h>
808 + ext2_xattr_put_super(sb);
809 if (!(sb->s_flags & MS_RDONLY)) {
810 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
813 this_char = strtok (NULL, ",")) {
814 if ((value = strchr (this_char, '=')) != NULL)
816 +#ifdef CONFIG_EXT2_FS_XATTR_USER
817 + if (!strcmp (this_char, "user_xattr"))
818 + set_opt (*mount_options, XATTR_USER);
819 + else if (!strcmp (this_char, "nouser_xattr"))
820 + clear_opt (*mount_options, XATTR_USER);
823 if (!strcmp (this_char, "bsddf"))
824 clear_opt (*mount_options, MINIX_DF);
825 else if (!strcmp (this_char, "nouid32")) {
827 blocksize = BLOCK_SIZE;
829 sb->u.ext2_sb.s_mount_opt = 0;
830 +#ifdef CONFIG_EXT2_FS_XATTR_USER
831 + /* set_opt (sb->u.ext2_sb.s_mount_opt, XATTR_USER); */
833 if (!parse_options ((char *) data, &sb_block, &resuid, &resgid,
834 &sb->u.ext2_sb.s_mount_opt)) {
836 @@ -813,12 +825,27 @@
838 static int __init init_ext2_fs(void)
840 - return register_filesystem(&ext2_fs_type);
841 + int error = init_ext2_xattr();
844 + error = init_ext2_xattr_user();
847 + error = register_filesystem(&ext2_fs_type);
851 + exit_ext2_xattr_user();
857 static void __exit exit_ext2_fs(void)
859 unregister_filesystem(&ext2_fs_type);
860 + exit_ext2_xattr_user();
865 Index: linux-2.4.22-vanilla/fs/ext2/symlink.c
866 ===================================================================
867 --- linux-2.4.22-vanilla.orig/fs/ext2/symlink.c 2003-11-03 23:41:26.000000000 +0300
868 +++ linux-2.4.22-vanilla/fs/ext2/symlink.c 2003-12-02 23:55:38.000000000 +0300
871 #include <linux/fs.h>
872 #include <linux/ext2_fs.h>
873 +#include <linux/ext2_xattr.h>
875 static int ext2_readlink(struct dentry *dentry, char *buffer, int buflen)
878 return vfs_follow_link(nd, s);
881 +struct inode_operations ext2_symlink_inode_operations = {
882 + readlink: page_readlink,
883 + follow_link: page_follow_link,
884 + setxattr: ext2_setxattr,
885 + getxattr: ext2_getxattr,
886 + listxattr: ext2_listxattr,
887 + removexattr: ext2_removexattr,
890 struct inode_operations ext2_fast_symlink_inode_operations = {
891 readlink: ext2_readlink,
892 follow_link: ext2_follow_link,
893 + setxattr: ext2_setxattr,
894 + getxattr: ext2_getxattr,
895 + listxattr: ext2_listxattr,
896 + removexattr: ext2_removexattr,
898 Index: linux-2.4.22-vanilla/fs/ext2/xattr.c
899 ===================================================================
900 --- linux-2.4.22-vanilla.orig/fs/ext2/xattr.c 2003-12-02 23:55:38.000000000 +0300
901 +++ linux-2.4.22-vanilla/fs/ext2/xattr.c 2003-12-02 23:55:38.000000000 +0300
904 + * linux/fs/ext2/xattr.c
906 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
908 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
909 + * Extended attributes for symlinks and special files added per
910 + * suggestion of Luka Renko <luka.renko@hermes.si>.
914 + * Extended attributes are stored on disk blocks allocated outside of
915 + * any inode. The i_file_acl field is then made to point to this allocated
916 + * block. If all extended attributes of an inode are identical, these
917 + * inodes may share the same extended attribute block. Such situations
918 + * are automatically detected by keeping a cache of recent attribute block
919 + * numbers and hashes over the block's contents in memory.
922 + * Extended attribute block layout:
924 + * +------------------+
927 + * | entry 2 | | growing downwards
929 + * | four null bytes |
932 + * | value 3 | | growing upwards
934 + * +------------------+
936 + * The block header is followed by multiple entry descriptors. These entry
937 + * descriptors are variable in size, and alligned to EXT2_XATTR_PAD
938 + * byte boundaries. The entry descriptors are sorted by attribute name,
939 + * so that two extended attribute blocks can be compared efficiently.
941 + * Attribute values are aligned to the end of the block, stored in
942 + * no specific order. They are also padded to EXT2_XATTR_PAD byte
943 + * boundaries. No additional gaps are left between them.
947 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
948 + * the xattr inode operations are called, so we are guaranteed that only one
949 + * processes accesses extended attributes of an inode at any time.
951 + * For writing we also grab the ext2_xattr_sem semaphore. This ensures that
952 + * only a single process is modifying an extended attribute block, even
953 + * if the block is shared among inodes.
955 + * Note for porting to 2.5
956 + * -----------------------
957 + * The BKL will no longer be held in the xattr inode operations.
960 +#include <linux/module.h>
961 +#include <linux/locks.h>
962 +#include <linux/slab.h>
963 +#include <linux/fs.h>
964 +#include <linux/ext2_fs.h>
965 +#include <linux/ext2_xattr.h>
966 +#include <linux/mbcache.h>
967 +#include <linux/quotaops.h>
968 +#include <asm/semaphore.h>
969 +#include <linux/compatmac.h>
971 +/* These symbols may be needed by a module. */
972 +EXPORT_SYMBOL(ext2_xattr_register);
973 +EXPORT_SYMBOL(ext2_xattr_unregister);
974 +EXPORT_SYMBOL(ext2_xattr_get);
975 +EXPORT_SYMBOL(ext2_xattr_list);
976 +EXPORT_SYMBOL(ext2_xattr_set);
978 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
979 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
982 +#define HDR(bh) ((struct ext2_xattr_header *)((bh)->b_data))
983 +#define ENTRY(ptr) ((struct ext2_xattr_entry *)(ptr))
984 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
985 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
987 +#ifdef EXT2_XATTR_DEBUG
988 +# define ea_idebug(inode, f...) do { \
989 + printk(KERN_DEBUG "inode %s:%ld: ", \
990 + kdevname(inode->i_dev), inode->i_ino); \
994 +# define ea_bdebug(bh, f...) do { \
995 + printk(KERN_DEBUG "block %s:%ld: ", \
996 + kdevname(bh->b_dev), bh->b_blocknr); \
1001 +# define ea_idebug(f...)
1002 +# define ea_bdebug(f...)
1005 +static int ext2_xattr_set2(struct inode *, struct buffer_head *,
1006 + struct ext2_xattr_header *);
1008 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1010 +static int ext2_xattr_cache_insert(struct buffer_head *);
1011 +static struct buffer_head *ext2_xattr_cache_find(struct inode *,
1012 + struct ext2_xattr_header *);
1013 +static void ext2_xattr_cache_remove(struct buffer_head *);
1014 +static void ext2_xattr_rehash(struct ext2_xattr_header *,
1015 + struct ext2_xattr_entry *);
1017 +static struct mb_cache *ext2_xattr_cache;
1020 +# define ext2_xattr_cache_insert(bh) 0
1021 +# define ext2_xattr_cache_find(inode, header) NULL
1022 +# define ext2_xattr_cache_remove(bh) while(0) {}
1023 +# define ext2_xattr_rehash(header, entry) while(0) {}
1027 + * If a file system does not share extended attributes among inodes,
1028 + * we should not need the ext2_xattr_sem semaphore. However, the
1029 + * filesystem may still contain shared blocks, so we always take
1033 +DECLARE_MUTEX(ext2_xattr_sem);
1036 +ext2_xattr_new_block(struct inode *inode, int * errp, int force)
1038 + struct super_block *sb = inode->i_sb;
1039 + int goal = le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block) +
1040 + EXT2_I(inode)->i_block_group * EXT2_BLOCKS_PER_GROUP(sb);
1042 + /* How can we enforce the allocation? */
1043 + int block = ext2_new_block(inode, goal, 0, 0, errp);
1046 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
1052 +ext2_xattr_quota_alloc(struct inode *inode, int force)
1054 + /* How can we enforce the allocation? */
1056 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
1058 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
1060 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
1068 +ext2_xattr_quota_free(struct inode *inode)
1070 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
1071 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1075 +ext2_xattr_free_block(struct inode * inode, unsigned long block)
1077 + ext2_free_blocks(inode, block, 1);
1078 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1082 +# define ext2_xattr_quota_free(inode) \
1083 + DQUOT_FREE_BLOCK(inode, 1)
1084 +# define ext2_xattr_free_block(inode, block) \
1085 + ext2_free_blocks(inode, block, 1)
1088 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
1090 +static inline struct buffer_head *
1091 +sb_bread(struct super_block *sb, int block)
1093 + return bread(sb->s_dev, block, sb->s_blocksize);
1096 +static inline struct buffer_head *
1097 +sb_getblk(struct super_block *sb, int block)
1099 + return getblk(sb->s_dev, block, sb->s_blocksize);
1104 +struct ext2_xattr_handler *ext2_xattr_handlers[EXT2_XATTR_INDEX_MAX];
1105 +rwlock_t ext2_handler_lock = RW_LOCK_UNLOCKED;
1108 +ext2_xattr_register(int name_index, struct ext2_xattr_handler *handler)
1110 + int error = -EINVAL;
1112 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1113 + write_lock(&ext2_handler_lock);
1114 + if (!ext2_xattr_handlers[name_index-1]) {
1115 + ext2_xattr_handlers[name_index-1] = handler;
1118 + write_unlock(&ext2_handler_lock);
1124 +ext2_xattr_unregister(int name_index, struct ext2_xattr_handler *handler)
1126 + if (name_index > 0 || name_index <= EXT2_XATTR_INDEX_MAX) {
1127 + write_lock(&ext2_handler_lock);
1128 + ext2_xattr_handlers[name_index-1] = NULL;
1129 + write_unlock(&ext2_handler_lock);
1133 +static inline const char *
1134 +strcmp_prefix(const char *a, const char *a_prefix)
1136 + while (*a_prefix && *a == *a_prefix) {
1140 + return *a_prefix ? NULL : a;
1144 + * Decode the extended attribute name, and translate it into
1145 + * the name_index and name suffix.
1147 +static struct ext2_xattr_handler *
1148 +ext2_xattr_resolve_name(const char **name)
1150 + struct ext2_xattr_handler *handler = NULL;
1155 + read_lock(&ext2_handler_lock);
1156 + for (i=0; i<EXT2_XATTR_INDEX_MAX; i++) {
1157 + if (ext2_xattr_handlers[i]) {
1158 + const char *n = strcmp_prefix(*name,
1159 + ext2_xattr_handlers[i]->prefix);
1161 + handler = ext2_xattr_handlers[i];
1167 + read_unlock(&ext2_handler_lock);
1171 +static inline struct ext2_xattr_handler *
1172 +ext2_xattr_handler(int name_index)
1174 + struct ext2_xattr_handler *handler = NULL;
1175 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1176 + read_lock(&ext2_handler_lock);
1177 + handler = ext2_xattr_handlers[name_index-1];
1178 + read_unlock(&ext2_handler_lock);
1184 + * Inode operation getxattr()
1186 + * dentry->d_inode->i_sem down
1187 + * BKL held [before 2.5.x]
1190 +ext2_getxattr(struct dentry *dentry, const char *name,
1191 + void *buffer, size_t size)
1193 + struct ext2_xattr_handler *handler;
1194 + struct inode *inode = dentry->d_inode;
1196 + handler = ext2_xattr_resolve_name(&name);
1199 + return handler->get(inode, name, buffer, size);
1203 + * Inode operation listxattr()
1205 + * dentry->d_inode->i_sem down
1206 + * BKL held [before 2.5.x]
1209 +ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
1211 + return ext2_xattr_list(dentry->d_inode, buffer, size);
1215 + * Inode operation setxattr()
1217 + * dentry->d_inode->i_sem down
1218 + * BKL held [before 2.5.x]
1221 +ext2_setxattr(struct dentry *dentry, const char *name,
1222 + const void *value, size_t size, int flags)
1224 + struct ext2_xattr_handler *handler;
1225 + struct inode *inode = dentry->d_inode;
1228 + value = ""; /* empty EA, do not remove */
1229 + handler = ext2_xattr_resolve_name(&name);
1232 + return handler->set(inode, name, value, size, flags);
1236 + * Inode operation removexattr()
1238 + * dentry->d_inode->i_sem down
1239 + * BKL held [before 2.5.x]
1242 +ext2_removexattr(struct dentry *dentry, const char *name)
1244 + struct ext2_xattr_handler *handler;
1245 + struct inode *inode = dentry->d_inode;
1247 + handler = ext2_xattr_resolve_name(&name);
1250 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
1254 + * ext2_xattr_get()
1256 + * Copy an extended attribute into the buffer
1257 + * provided, or compute the buffer size required.
1258 + * Buffer is NULL to compute the size of the buffer required.
1260 + * Returns a negative error number on failure, or the number of bytes
1261 + * used / required on success.
1264 +ext2_xattr_get(struct inode *inode, int name_index, const char *name,
1265 + void *buffer, size_t buffer_size)
1267 + struct buffer_head *bh = NULL;
1268 + struct ext2_xattr_entry *entry;
1269 + unsigned int block, size;
1271 + int name_len, error;
1273 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
1274 + name_index, name, buffer, (long)buffer_size);
1278 + if (!EXT2_I(inode)->i_file_acl)
1280 + block = EXT2_I(inode)->i_file_acl;
1281 + ea_idebug(inode, "reading block %d", block);
1282 + bh = sb_bread(inode->i_sb, block);
1285 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1286 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1287 + end = bh->b_data + bh->b_size;
1288 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1289 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1290 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
1291 + "inode %ld: bad block %d", inode->i_ino, block);
1295 + /* find named attribute */
1296 + name_len = strlen(name);
1299 + if (name_len > 255)
1301 + entry = FIRST_ENTRY(bh);
1302 + while (!IS_LAST_ENTRY(entry)) {
1303 + struct ext2_xattr_entry *next =
1304 + EXT2_XATTR_NEXT(entry);
1305 + if ((char *)next >= end)
1307 + if (name_index == entry->e_name_index &&
1308 + name_len == entry->e_name_len &&
1309 + memcmp(name, entry->e_name, name_len) == 0)
1313 + /* Check the remaining name entries */
1314 + while (!IS_LAST_ENTRY(entry)) {
1315 + struct ext2_xattr_entry *next =
1316 + EXT2_XATTR_NEXT(entry);
1317 + if ((char *)next >= end)
1321 + if (ext2_xattr_cache_insert(bh))
1322 + ea_idebug(inode, "cache insert failed");
1326 + /* check the buffer size */
1327 + if (entry->e_value_block != 0)
1329 + size = le32_to_cpu(entry->e_value_size);
1330 + if (size > inode->i_sb->s_blocksize ||
1331 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
1334 + if (ext2_xattr_cache_insert(bh))
1335 + ea_idebug(inode, "cache insert failed");
1338 + if (size > buffer_size)
1340 + /* return value of attribute */
1341 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
1353 + * ext2_xattr_list()
1355 + * Copy a list of attribute names into the buffer
1356 + * provided, or compute the buffer size required.
1357 + * Buffer is NULL to compute the size of the buffer required.
1359 + * Returns a negative error number on failure, or the number of bytes
1360 + * used / required on success.
1363 +ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
1365 + struct buffer_head *bh = NULL;
1366 + struct ext2_xattr_entry *entry;
1367 + unsigned int block, size = 0;
1371 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
1372 + buffer, (long)buffer_size);
1374 + if (!EXT2_I(inode)->i_file_acl)
1376 + block = EXT2_I(inode)->i_file_acl;
1377 + ea_idebug(inode, "reading block %d", block);
1378 + bh = sb_bread(inode->i_sb, block);
1381 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1382 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1383 + end = bh->b_data + bh->b_size;
1384 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1385 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1386 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
1387 + "inode %ld: bad block %d", inode->i_ino, block);
1391 + /* compute the size required for the list of attribute names */
1392 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1393 + entry = EXT2_XATTR_NEXT(entry)) {
1394 + struct ext2_xattr_handler *handler;
1395 + struct ext2_xattr_entry *next =
1396 + EXT2_XATTR_NEXT(entry);
1397 + if ((char *)next >= end)
1400 + handler = ext2_xattr_handler(entry->e_name_index);
1402 + size += handler->list(NULL, inode, entry->e_name,
1403 + entry->e_name_len);
1406 + if (ext2_xattr_cache_insert(bh))
1407 + ea_idebug(inode, "cache insert failed");
1413 + if (size > buffer_size)
1417 + /* list the attribute names */
1419 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1420 + entry = EXT2_XATTR_NEXT(entry)) {
1421 + struct ext2_xattr_handler *handler;
1423 + handler = ext2_xattr_handler(entry->e_name_index);
1425 + buf += handler->list(buf, inode, entry->e_name,
1426 + entry->e_name_len);
1437 + * If the EXT2_FEATURE_COMPAT_EXT_ATTR feature of this file system is
1438 + * not set, set it.
1440 +static void ext2_xattr_update_super_block(struct super_block *sb)
1442 + if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
1446 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
1447 + EXT2_SB(sb)->s_feature_compat |= EXT2_FEATURE_COMPAT_EXT_ATTR;
1449 + EXT2_SB(sb)->s_es->s_feature_compat |=
1450 + cpu_to_le32(EXT2_FEATURE_COMPAT_EXT_ATTR);
1452 + mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
1457 + * ext2_xattr_set()
1459 + * Create, replace or remove an extended attribute for this inode. Buffer
1460 + * is NULL to remove an existing extended attribute, and non-NULL to
1461 + * either replace an existing extended attribute, or create a new extended
1462 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
1463 + * specify that an extended attribute must exist and must not exist
1464 + * previous to the call, respectively.
1466 + * Returns 0, or a negative error number on failure.
1469 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
1470 + const void *value, size_t value_len, int flags)
1472 + struct super_block *sb = inode->i_sb;
1473 + struct buffer_head *bh = NULL;
1474 + struct ext2_xattr_header *header = NULL;
1475 + struct ext2_xattr_entry *here, *last;
1476 + unsigned int name_len;
1477 + int block = EXT2_I(inode)->i_file_acl;
1478 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
1482 + * header -- Points either into bh, or to a temporarily
1483 + * allocated buffer.
1484 + * here -- The named entry found, or the place for inserting, within
1485 + * the block pointed to by header.
1486 + * last -- Points right after the last named entry within the block
1487 + * pointed to by header.
1488 + * min_offs -- The offset of the first value (values are aligned
1489 + * towards the end of the block).
1490 + * end -- Points right after the block pointed to by header.
1493 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
1494 + name_index, name, value, (long)value_len);
1496 + if (IS_RDONLY(inode))
1498 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1500 + if (value == NULL)
1504 + name_len = strlen(name);
1505 + if (name_len > 255 || value_len > sb->s_blocksize)
1507 + down(&ext2_xattr_sem);
1510 + /* The inode already has an extended attribute block. */
1512 + bh = sb_bread(sb, block);
1516 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1517 + atomic_read(&(bh->b_count)),
1518 + le32_to_cpu(HDR(bh)->h_refcount));
1520 + end = bh->b_data + bh->b_size;
1521 + if (header->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1522 + header->h_blocks != cpu_to_le32(1)) {
1523 +bad_block: ext2_error(sb, "ext2_xattr_set",
1524 + "inode %ld: bad block %d", inode->i_ino, block);
1528 + /* Find the named attribute. */
1529 + here = FIRST_ENTRY(bh);
1530 + while (!IS_LAST_ENTRY(here)) {
1531 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(here);
1532 + if ((char *)next >= end)
1534 + if (!here->e_value_block && here->e_value_size) {
1535 + int offs = le16_to_cpu(here->e_value_offs);
1536 + if (offs < min_offs)
1539 + not_found = name_index - here->e_name_index;
1541 + not_found = name_len - here->e_name_len;
1543 + not_found = memcmp(name, here->e_name,name_len);
1544 + if (not_found <= 0)
1549 + /* We still need to compute min_offs and last. */
1550 + while (!IS_LAST_ENTRY(last)) {
1551 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(last);
1552 + if ((char *)next >= end)
1554 + if (!last->e_value_block && last->e_value_size) {
1555 + int offs = le16_to_cpu(last->e_value_offs);
1556 + if (offs < min_offs)
1562 + /* Check whether we have enough space left. */
1563 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
1565 + /* We will use a new extended attribute block. */
1566 + free = sb->s_blocksize -
1567 + sizeof(struct ext2_xattr_header) - sizeof(__u32);
1568 + here = last = NULL; /* avoid gcc uninitialized warning. */
1572 + /* Request to remove a nonexistent attribute? */
1574 + if (flags & XATTR_REPLACE)
1577 + if (value == NULL)
1580 + free -= EXT2_XATTR_LEN(name_len);
1582 + /* Request to create an existing attribute? */
1584 + if (flags & XATTR_CREATE)
1586 + if (!here->e_value_block && here->e_value_size) {
1587 + unsigned int size = le32_to_cpu(here->e_value_size);
1589 + if (le16_to_cpu(here->e_value_offs) + size >
1590 + sb->s_blocksize || size > sb->s_blocksize)
1592 + free += EXT2_XATTR_SIZE(size);
1595 + free -= EXT2_XATTR_SIZE(value_len);
1600 + /* Here we know that we can set the new attribute. */
1603 + if (header->h_refcount == cpu_to_le32(1)) {
1604 + ea_bdebug(bh, "modifying in-place");
1605 + ext2_xattr_cache_remove(bh);
1609 + ea_bdebug(bh, "cloning");
1610 + header = kmalloc(bh->b_size, GFP_KERNEL);
1612 + if (header == NULL)
1614 + memcpy(header, HDR(bh), bh->b_size);
1615 + header->h_refcount = cpu_to_le32(1);
1616 + offset = (char *)header - bh->b_data;
1617 + here = ENTRY((char *)here + offset);
1618 + last = ENTRY((char *)last + offset);
1621 + /* Allocate a buffer where we construct the new block. */
1622 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
1624 + if (header == NULL)
1626 + memset(header, 0, sb->s_blocksize);
1627 + end = (char *)header + sb->s_blocksize;
1628 + header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC);
1629 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
1630 + last = here = ENTRY(header+1);
1634 + /* Insert the new name. */
1635 + int size = EXT2_XATTR_LEN(name_len);
1636 + int rest = (char *)last - (char *)here;
1637 + memmove((char *)here + size, here, rest);
1638 + memset(here, 0, size);
1639 + here->e_name_index = name_index;
1640 + here->e_name_len = name_len;
1641 + memcpy(here->e_name, name, name_len);
1643 + /* Remove the old value. */
1644 + if (!here->e_value_block && here->e_value_size) {
1645 + char *first_val = (char *)header + min_offs;
1646 + int offs = le16_to_cpu(here->e_value_offs);
1647 + char *val = (char *)header + offs;
1648 + size_t size = EXT2_XATTR_SIZE(
1649 + le32_to_cpu(here->e_value_size));
1650 + memmove(first_val + size, first_val, val - first_val);
1651 + memset(first_val, 0, size);
1652 + here->e_value_offs = 0;
1655 + /* Adjust all value offsets. */
1656 + last = ENTRY(header+1);
1657 + while (!IS_LAST_ENTRY(last)) {
1658 + int o = le16_to_cpu(last->e_value_offs);
1659 + if (!last->e_value_block && o < offs)
1660 + last->e_value_offs =
1661 + cpu_to_le16(o + size);
1662 + last = EXT2_XATTR_NEXT(last);
1665 + if (value == NULL) {
1666 + /* Remove this attribute. */
1667 + if (EXT2_XATTR_NEXT(ENTRY(header+1)) == last) {
1668 + /* This block is now empty. */
1669 + error = ext2_xattr_set2(inode, bh, NULL);
1672 + /* Remove the old name. */
1673 + int size = EXT2_XATTR_LEN(name_len);
1674 + last = ENTRY((char *)last - size);
1675 + memmove(here, (char*)here + size,
1676 + (char*)last - (char*)here);
1677 + memset(last, 0, size);
1682 + if (value != NULL) {
1683 + /* Insert the new value. */
1684 + here->e_value_size = cpu_to_le32(value_len);
1686 + size_t size = EXT2_XATTR_SIZE(value_len);
1687 + char *val = (char *)header + min_offs - size;
1688 + here->e_value_offs =
1689 + cpu_to_le16((char *)val - (char *)header);
1690 + memset(val + size - EXT2_XATTR_PAD, 0,
1691 + EXT2_XATTR_PAD); /* Clear the pad bytes. */
1692 + memcpy(val, value, value_len);
1695 + ext2_xattr_rehash(header, here);
1697 + error = ext2_xattr_set2(inode, bh, header);
1701 + if (!(bh && header == HDR(bh)))
1703 + up(&ext2_xattr_sem);
1709 + * Second half of ext2_xattr_set(): Update the file system.
1712 +ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
1713 + struct ext2_xattr_header *header)
1715 + struct super_block *sb = inode->i_sb;
1716 + struct buffer_head *new_bh = NULL;
1720 + new_bh = ext2_xattr_cache_find(inode, header);
1723 + * We found an identical block in the cache.
1724 + * The old block will be released after updating
1727 + ea_bdebug(old_bh, "reusing block %ld",
1728 + new_bh->b_blocknr);
1731 + if (ext2_xattr_quota_alloc(inode, 1))
1734 + HDR(new_bh)->h_refcount = cpu_to_le32(
1735 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
1736 + ea_bdebug(new_bh, "refcount now=%d",
1737 + le32_to_cpu(HDR(new_bh)->h_refcount));
1738 + } else if (old_bh && header == HDR(old_bh)) {
1739 + /* Keep this block. */
1741 + (void)ext2_xattr_cache_insert(new_bh);
1743 + /* We need to allocate a new block */
1744 + int force = EXT2_I(inode)->i_file_acl != 0;
1745 + int block = ext2_xattr_new_block(inode, &error, force);
1748 + ea_idebug(inode, "creating block %d", block);
1750 + new_bh = sb_getblk(sb, block);
1752 + ext2_xattr_free_block(inode, block);
1756 + lock_buffer(new_bh);
1757 + memcpy(new_bh->b_data, header, new_bh->b_size);
1758 + mark_buffer_uptodate(new_bh, 1);
1759 + unlock_buffer(new_bh);
1760 + (void)ext2_xattr_cache_insert(new_bh);
1762 + ext2_xattr_update_super_block(sb);
1764 + mark_buffer_dirty(new_bh);
1765 + if (IS_SYNC(inode)) {
1766 + ll_rw_block(WRITE, 1, &new_bh);
1767 + wait_on_buffer(new_bh);
1769 + if (buffer_req(new_bh) && !buffer_uptodate(new_bh))
1774 + /* Update the inode. */
1775 + EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
1776 + inode->i_ctime = CURRENT_TIME;
1777 + if (IS_SYNC(inode)) {
1778 + error = ext2_sync_inode (inode);
1782 + mark_inode_dirty(inode);
1785 + if (old_bh && old_bh != new_bh) {
1787 + * If there was an old block, and we are not still using it,
1788 + * we now release the old block.
1790 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
1792 + if (refcount == 1) {
1793 + /* Free the old block. */
1794 + ea_bdebug(old_bh, "freeing");
1795 + ext2_xattr_free_block(inode, old_bh->b_blocknr);
1796 + mark_buffer_clean(old_bh);
1798 + /* Decrement the refcount only. */
1800 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
1801 + ext2_xattr_quota_free(inode);
1802 + mark_buffer_dirty(old_bh);
1803 + ea_bdebug(old_bh, "refcount now=%d", refcount);
1808 + if (old_bh != new_bh)
1815 + * ext2_xattr_delete_inode()
1817 + * Free extended attribute resources associated with this inode. This
1818 + * is called immediately before an inode is freed.
1821 +ext2_xattr_delete_inode(struct inode *inode)
1823 + struct buffer_head *bh;
1824 + unsigned int block = EXT2_I(inode)->i_file_acl;
1828 + down(&ext2_xattr_sem);
1830 + bh = sb_bread(inode->i_sb, block);
1832 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1833 + "inode %ld: block %d read error", inode->i_ino, block);
1836 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
1837 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1838 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1839 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1840 + "inode %ld: bad block %d", inode->i_ino, block);
1843 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
1844 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
1845 + ext2_xattr_cache_remove(bh);
1846 + ext2_xattr_free_block(inode, block);
1850 + HDR(bh)->h_refcount = cpu_to_le32(
1851 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
1852 + mark_buffer_dirty(bh);
1853 + if (IS_SYNC(inode)) {
1854 + ll_rw_block(WRITE, 1, &bh);
1855 + wait_on_buffer(bh);
1857 + ext2_xattr_quota_free(inode);
1859 + EXT2_I(inode)->i_file_acl = 0;
1863 + up(&ext2_xattr_sem);
1867 + * ext2_xattr_put_super()
1869 + * This is called when a file system is unmounted.
1872 +ext2_xattr_put_super(struct super_block *sb)
1874 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1875 + mb_cache_shrink(ext2_xattr_cache, sb->s_dev);
1879 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1882 + * ext2_xattr_cache_insert()
1884 + * Create a new entry in the extended attribute cache, and insert
1885 + * it unless such an entry is already in the cache.
1887 + * Returns 0, or a negative error number on failure.
1890 +ext2_xattr_cache_insert(struct buffer_head *bh)
1892 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
1893 + struct mb_cache_entry *ce;
1896 + ce = mb_cache_entry_alloc(ext2_xattr_cache);
1899 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
1901 + mb_cache_entry_free(ce);
1902 + if (error == -EBUSY) {
1903 + ea_bdebug(bh, "already in cache (%d cache entries)",
1904 + atomic_read(&ext2_xattr_cache->c_entry_count));
1908 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
1909 + atomic_read(&ext2_xattr_cache->c_entry_count));
1910 + mb_cache_entry_release(ce);
1916 + * ext2_xattr_cmp()
1918 + * Compare two extended attribute blocks for equality.
1920 + * Returns 0 if the blocks are equal, 1 if they differ, and
1921 + * a negative error number on errors.
1924 +ext2_xattr_cmp(struct ext2_xattr_header *header1,
1925 + struct ext2_xattr_header *header2)
1927 + struct ext2_xattr_entry *entry1, *entry2;
1929 + entry1 = ENTRY(header1+1);
1930 + entry2 = ENTRY(header2+1);
1931 + while (!IS_LAST_ENTRY(entry1)) {
1932 + if (IS_LAST_ENTRY(entry2))
1934 + if (entry1->e_hash != entry2->e_hash ||
1935 + entry1->e_name_len != entry2->e_name_len ||
1936 + entry1->e_value_size != entry2->e_value_size ||
1937 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1939 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1941 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1942 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1943 + le32_to_cpu(entry1->e_value_size)))
1946 + entry1 = EXT2_XATTR_NEXT(entry1);
1947 + entry2 = EXT2_XATTR_NEXT(entry2);
1949 + if (!IS_LAST_ENTRY(entry2))
1955 + * ext2_xattr_cache_find()
1957 + * Find an identical extended attribute block.
1959 + * Returns a pointer to the block found, or NULL if such a block was
1960 + * not found or an error occurred.
1962 +static struct buffer_head *
1963 +ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
1965 + __u32 hash = le32_to_cpu(header->h_hash);
1966 + struct mb_cache_entry *ce;
1968 + if (!header->h_hash)
1969 + return NULL; /* never share */
1970 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
1971 + ce = mb_cache_entry_find_first(ext2_xattr_cache, 0, inode->i_dev, hash);
1973 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
1976 + ext2_error(inode->i_sb, "ext2_xattr_cache_find",
1977 + "inode %ld: block %ld read error",
1978 + inode->i_ino, ce->e_block);
1979 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
1980 + EXT2_XATTR_REFCOUNT_MAX) {
1981 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
1982 + le32_to_cpu(HDR(bh)->h_refcount),
1983 + EXT2_XATTR_REFCOUNT_MAX);
1984 + } else if (!ext2_xattr_cmp(header, HDR(bh))) {
1985 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
1986 + mb_cache_entry_release(ce);
1990 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
1996 + * ext2_xattr_cache_remove()
1998 + * Remove the cache entry of a block from the cache. Called when a
1999 + * block becomes invalid.
2002 +ext2_xattr_cache_remove(struct buffer_head *bh)
2004 + struct mb_cache_entry *ce;
2006 + ce = mb_cache_entry_get(ext2_xattr_cache, bh->b_dev, bh->b_blocknr);
2008 + ea_bdebug(bh, "removing (%d cache entries remaining)",
2009 + atomic_read(&ext2_xattr_cache->c_entry_count)-1);
2010 + mb_cache_entry_free(ce);
2012 + ea_bdebug(bh, "no cache entry");
2015 +#define NAME_HASH_SHIFT 5
2016 +#define VALUE_HASH_SHIFT 16
2019 + * ext2_xattr_hash_entry()
2021 + * Compute the hash of an extended attribute.
2023 +static inline void ext2_xattr_hash_entry(struct ext2_xattr_header *header,
2024 + struct ext2_xattr_entry *entry)
2027 + char *name = entry->e_name;
2030 + for (n=0; n < entry->e_name_len; n++) {
2031 + hash = (hash << NAME_HASH_SHIFT) ^
2032 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
2036 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
2037 + __u32 *value = (__u32 *)((char *)header +
2038 + le16_to_cpu(entry->e_value_offs));
2039 + for (n = (le32_to_cpu(entry->e_value_size) +
2040 + EXT2_XATTR_ROUND) >> EXT2_XATTR_PAD_BITS; n; n--) {
2041 + hash = (hash << VALUE_HASH_SHIFT) ^
2042 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
2043 + le32_to_cpu(*value++);
2046 + entry->e_hash = cpu_to_le32(hash);
2049 +#undef NAME_HASH_SHIFT
2050 +#undef VALUE_HASH_SHIFT
2052 +#define BLOCK_HASH_SHIFT 16
2055 + * ext2_xattr_rehash()
2057 + * Re-compute the extended attribute hash value after an entry has changed.
2059 +static void ext2_xattr_rehash(struct ext2_xattr_header *header,
2060 + struct ext2_xattr_entry *entry)
2062 + struct ext2_xattr_entry *here;
2065 + ext2_xattr_hash_entry(header, entry);
2066 + here = ENTRY(header+1);
2067 + while (!IS_LAST_ENTRY(here)) {
2068 + if (!here->e_hash) {
2069 + /* Block is not shared if an entry's hash value == 0 */
2073 + hash = (hash << BLOCK_HASH_SHIFT) ^
2074 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
2075 + le32_to_cpu(here->e_hash);
2076 + here = EXT2_XATTR_NEXT(here);
2078 + header->h_hash = cpu_to_le32(hash);
2081 +#undef BLOCK_HASH_SHIFT
2084 +init_ext2_xattr(void)
2086 + ext2_xattr_cache = mb_cache_create("ext2_xattr", NULL,
2087 + sizeof(struct mb_cache_entry) +
2088 + sizeof(struct mb_cache_entry_index), 1, 61);
2089 + if (!ext2_xattr_cache)
2096 +exit_ext2_xattr(void)
2098 + mb_cache_destroy(ext2_xattr_cache);
2101 +#else /* CONFIG_EXT2_FS_XATTR_SHARING */
2104 +init_ext2_xattr(void)
2110 +exit_ext2_xattr(void)
2114 +#endif /* CONFIG_EXT2_FS_XATTR_SHARING */
2115 Index: linux-2.4.22-vanilla/fs/ext2/xattr_user.c
2116 ===================================================================
2117 --- linux-2.4.22-vanilla.orig/fs/ext2/xattr_user.c 2003-12-02 23:55:38.000000000 +0300
2118 +++ linux-2.4.22-vanilla/fs/ext2/xattr_user.c 2003-12-02 23:55:38.000000000 +0300
2121 + * linux/fs/ext2/xattr_user.c
2122 + * Handler for extended user attributes.
2124 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2127 +#include <linux/module.h>
2128 +#include <linux/string.h>
2129 +#include <linux/fs.h>
2130 +#include <linux/ext2_fs.h>
2131 +#include <linux/ext2_xattr.h>
2133 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2134 +# include <linux/ext2_acl.h>
2137 +#define XATTR_USER_PREFIX "user."
2140 +ext2_xattr_user_list(char *list, struct inode *inode,
2141 + const char *name, int name_len)
2143 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
2145 + if (!test_opt(inode->i_sb, XATTR_USER))
2149 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
2150 + memcpy(list+prefix_len, name, name_len);
2151 + list[prefix_len + name_len] = '\0';
2153 + return prefix_len + name_len + 1;
2157 +ext2_xattr_user_get(struct inode *inode, const char *name,
2158 + void *buffer, size_t size)
2162 + if (strcmp(name, "") == 0)
2164 + if (!test_opt(inode->i_sb, XATTR_USER))
2166 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2167 + error = ext2_permission_locked(inode, MAY_READ);
2169 + error = permission(inode, MAY_READ);
2174 + return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name,
2179 +ext2_xattr_user_set(struct inode *inode, const char *name,
2180 + const void *value, size_t size, int flags)
2184 + if (strcmp(name, "") == 0)
2186 + if (!test_opt(inode->i_sb, XATTR_USER))
2188 + if ( !S_ISREG(inode->i_mode) &&
2189 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
2191 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2192 + error = ext2_permission_locked(inode, MAY_WRITE);
2194 + error = permission(inode, MAY_WRITE);
2199 + return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name,
2200 + value, size, flags);
2203 +struct ext2_xattr_handler ext2_xattr_user_handler = {
2204 + prefix: XATTR_USER_PREFIX,
2205 + list: ext2_xattr_user_list,
2206 + get: ext2_xattr_user_get,
2207 + set: ext2_xattr_user_set,
2211 +init_ext2_xattr_user(void)
2213 + return ext2_xattr_register(EXT2_XATTR_INDEX_USER,
2214 + &ext2_xattr_user_handler);
2218 +exit_ext2_xattr_user(void)
2220 + ext2_xattr_unregister(EXT2_XATTR_INDEX_USER,
2221 + &ext2_xattr_user_handler);
2223 Index: linux-2.4.22-vanilla/fs/ext3/Makefile
2224 ===================================================================
2225 --- linux-2.4.22-vanilla.orig/fs/ext3/Makefile 2003-12-02 23:55:37.000000000 +0300
2226 +++ linux-2.4.22-vanilla/fs/ext3/Makefile 2003-12-02 23:55:38.000000000 +0300
2229 -# Makefile for the linux ext2-filesystem routines.
2230 +# Makefile for the linux ext3-filesystem routines.
2232 # Note! Dependencies are done automagically by 'make dep', which also
2233 # removes any old dependencies. DON'T put your own dependencies here
2238 -export-objs := super.o inode.o
2239 +export-objs := ext3-exports.o
2241 obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
2242 - ioctl.o namei.o super.o symlink.o hash.o
2243 + ioctl.o namei.o super.o symlink.o hash.o ext3-exports.o
2244 obj-m := $(O_TARGET)
2246 +export-objs += xattr.o
2247 +obj-$(CONFIG_EXT3_FS_XATTR) += xattr.o
2248 +obj-$(CONFIG_EXT3_FS_XATTR_USER) += xattr_user.o
2250 include $(TOPDIR)/Rules.make
2251 Index: linux-2.4.22-vanilla/fs/ext3/file.c
2252 ===================================================================
2253 --- linux-2.4.22-vanilla.orig/fs/ext3/file.c 2003-12-02 23:55:37.000000000 +0300
2254 +++ linux-2.4.22-vanilla/fs/ext3/file.c 2003-12-02 23:55:38.000000000 +0300
2256 #include <linux/locks.h>
2257 #include <linux/jbd.h>
2258 #include <linux/ext3_fs.h>
2259 +#include <linux/ext3_xattr.h>
2260 #include <linux/ext3_jbd.h>
2261 #include <linux/smp_lock.h>
2264 struct inode_operations ext3_file_inode_operations = {
2265 truncate: ext3_truncate, /* BKL held */
2266 setattr: ext3_setattr, /* BKL held */
2267 + setxattr: ext3_setxattr, /* BKL held */
2268 + getxattr: ext3_getxattr, /* BKL held */
2269 + listxattr: ext3_listxattr, /* BKL held */
2270 + removexattr: ext3_removexattr, /* BKL held */
2273 Index: linux-2.4.22-vanilla/fs/ext3/ialloc.c
2274 ===================================================================
2275 --- linux-2.4.22-vanilla.orig/fs/ext3/ialloc.c 2003-11-03 23:41:26.000000000 +0300
2276 +++ linux-2.4.22-vanilla/fs/ext3/ialloc.c 2003-12-02 23:55:38.000000000 +0300
2278 #include <linux/jbd.h>
2279 #include <linux/ext3_fs.h>
2280 #include <linux/ext3_jbd.h>
2281 +#include <linux/ext3_xattr.h>
2282 #include <linux/stat.h>
2283 #include <linux/string.h>
2284 #include <linux/locks.h>
2286 * as writing the quota to disk may need the lock as well.
2289 + ext3_xattr_delete_inode(handle, inode);
2290 DQUOT_FREE_INODE(inode);
2293 Index: linux-2.4.22-vanilla/fs/ext3/inode.c
2294 ===================================================================
2295 --- linux-2.4.22-vanilla.orig/fs/ext3/inode.c 2003-11-03 23:41:26.000000000 +0300
2296 +++ linux-2.4.22-vanilla/fs/ext3/inode.c 2003-12-02 23:55:38.000000000 +0300
2299 #undef SEARCH_FROM_ZERO
2302 + * Test whether an inode is a fast symlink.
2304 +static inline int ext3_inode_is_fast_symlink(struct inode *inode)
2306 + int ea_blocks = inode->u.ext3_i.i_file_acl ?
2307 + (inode->i_sb->s_blocksize >> 9) : 0;
2309 + return (S_ISLNK(inode->i_mode) &&
2310 + inode->i_blocks - ea_blocks == 0);
2313 /* The ext3 forget function must perform a revoke if we are freeing data
2314 * which has been journaled. Metadata (eg. indirect blocks) must be
2315 * revoked in all cases.
2317 * still needs to be revoked.
2320 -static int ext3_forget(handle_t *handle, int is_metadata,
2321 +int ext3_forget(handle_t *handle, int is_metadata,
2322 struct inode *inode, struct buffer_head *bh,
2329 - if (is_bad_inode(inode) ||
2330 - inode->i_ino == EXT3_ACL_IDX_INO ||
2331 - inode->i_ino == EXT3_ACL_DATA_INO)
2332 + if (is_bad_inode(inode))
2336 @@ -1870,6 +1880,8 @@
2337 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
2338 S_ISLNK(inode->i_mode)))
2340 + if (ext3_inode_is_fast_symlink(inode))
2342 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2345 @@ -2017,8 +2029,6 @@
2346 struct ext3_group_desc * gdp;
2348 if ((inode->i_ino != EXT3_ROOT_INO &&
2349 - inode->i_ino != EXT3_ACL_IDX_INO &&
2350 - inode->i_ino != EXT3_ACL_DATA_INO &&
2351 inode->i_ino != EXT3_JOURNAL_INO &&
2352 inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
2353 inode->i_ino > le32_to_cpu(
2354 @@ -2159,10 +2169,7 @@
2355 inode->u.ext3_i.i_data[block] = iloc.raw_inode->i_block[block];
2356 INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan);
2358 - if (inode->i_ino == EXT3_ACL_IDX_INO ||
2359 - inode->i_ino == EXT3_ACL_DATA_INO)
2360 - /* Nothing to do */ ;
2361 - else if (S_ISREG(inode->i_mode)) {
2362 + if (S_ISREG(inode->i_mode)) {
2363 inode->i_op = &ext3_file_inode_operations;
2364 inode->i_fop = &ext3_file_operations;
2365 inode->i_mapping->a_ops = &ext3_aops;
2366 @@ -2170,15 +2177,17 @@
2367 inode->i_op = &ext3_dir_inode_operations;
2368 inode->i_fop = &ext3_dir_operations;
2369 } else if (S_ISLNK(inode->i_mode)) {
2370 - if (!inode->i_blocks)
2371 + if (ext3_inode_is_fast_symlink(inode))
2372 inode->i_op = &ext3_fast_symlink_inode_operations;
2374 - inode->i_op = &page_symlink_inode_operations;
2375 + inode->i_op = &ext3_symlink_inode_operations;
2376 inode->i_mapping->a_ops = &ext3_aops;
2380 + inode->i_op = &ext3_special_inode_operations;
2381 init_special_inode(inode, inode->i_mode,
2382 le32_to_cpu(iloc.raw_inode->i_block[0]));
2385 ext3_set_inode_flags(inode);
2387 Index: linux-2.4.22-vanilla/fs/ext3/namei.c
2388 ===================================================================
2389 --- linux-2.4.22-vanilla.orig/fs/ext3/namei.c 2003-12-02 23:55:37.000000000 +0300
2390 +++ linux-2.4.22-vanilla/fs/ext3/namei.c 2003-12-02 23:55:38.000000000 +0300
2392 #include <linux/sched.h>
2393 #include <linux/ext3_fs.h>
2394 #include <linux/ext3_jbd.h>
2395 +#include <linux/ext3_xattr.h>
2396 #include <linux/fcntl.h>
2397 #include <linux/stat.h>
2398 #include <linux/string.h>
2399 @@ -1613,7 +1614,7 @@
2403 - inode = ext3_new_inode (handle, dir, S_IFDIR);
2404 + inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
2405 err = PTR_ERR(inode);
2408 @@ -1621,7 +1622,6 @@
2409 inode->i_op = &ext3_dir_inode_operations;
2410 inode->i_fop = &ext3_dir_operations;
2411 inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
2412 - inode->i_blocks = 0;
2413 dir_block = ext3_bread (handle, inode, 0, 1, &err);
2415 inode->i_nlink--; /* is this nlink == 0? */
2416 @@ -1648,9 +1648,6 @@
2417 BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
2418 ext3_journal_dirty_metadata(handle, dir_block);
2420 - inode->i_mode = S_IFDIR | mode;
2421 - if (dir->i_mode & S_ISGID)
2422 - inode->i_mode |= S_ISGID;
2423 ext3_mark_inode_dirty(handle, inode);
2424 err = ext3_add_entry (handle, dentry, inode);
2426 @@ -2019,7 +2016,7 @@
2429 if (l > sizeof (EXT3_I(inode)->i_data)) {
2430 - inode->i_op = &page_symlink_inode_operations;
2431 + inode->i_op = &ext3_symlink_inode_operations;
2432 inode->i_mapping->a_ops = &ext3_aops;
2434 * block_symlink() calls back into ext3_prepare/commit_write.
2435 @@ -2244,4 +2241,16 @@
2436 rmdir: ext3_rmdir, /* BKL held */
2437 mknod: ext3_mknod, /* BKL held */
2438 rename: ext3_rename, /* BKL held */
2439 + setxattr: ext3_setxattr, /* BKL held */
2440 + getxattr: ext3_getxattr, /* BKL held */
2441 + listxattr: ext3_listxattr, /* BKL held */
2442 + removexattr: ext3_removexattr, /* BKL held */
2445 +struct inode_operations ext3_special_inode_operations = {
2446 + setxattr: ext3_setxattr, /* BKL held */
2447 + getxattr: ext3_getxattr, /* BKL held */
2448 + listxattr: ext3_listxattr, /* BKL held */
2449 + removexattr: ext3_removexattr, /* BKL held */
2452 Index: linux-2.4.22-vanilla/fs/ext3/super.c
2453 ===================================================================
2454 --- linux-2.4.22-vanilla.orig/fs/ext3/super.c 2003-12-02 23:55:37.000000000 +0300
2455 +++ linux-2.4.22-vanilla/fs/ext3/super.c 2003-12-02 23:56:03.000000000 +0300
2457 #include <linux/jbd.h>
2458 #include <linux/ext3_fs.h>
2459 #include <linux/ext3_jbd.h>
2460 +#include <linux/ext3_xattr.h>
2461 #include <linux/slab.h>
2462 #include <linux/init.h>
2463 #include <linux/locks.h>
2465 kdev_t j_dev = sbi->s_journal->j_dev;
2468 + ext3_xattr_put_super(sb);
2469 journal_destroy(sbi->s_journal);
2470 if (!(sb->s_flags & MS_RDONLY)) {
2471 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
2475 unsigned long *mount_options = &sbi->s_mount_opt;
2477 uid_t *resuid = &sbi->s_resuid;
2478 gid_t *resgid = &sbi->s_resgid;
2480 @@ -517,6 +520,13 @@
2481 this_char = strtok (NULL, ",")) {
2482 if ((value = strchr (this_char, '=')) != NULL)
2484 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2485 + if (!strcmp (this_char, "user_xattr"))
2486 + set_opt (*mount_options, XATTR_USER);
2487 + else if (!strcmp (this_char, "nouser_xattr"))
2488 + clear_opt (*mount_options, XATTR_USER);
2491 if (!strcmp (this_char, "bsddf"))
2492 clear_opt (*mount_options, MINIX_DF);
2493 else if (!strcmp (this_char, "nouid32")) {
2494 @@ -934,6 +944,12 @@
2495 sbi->s_mount_opt = 0;
2496 sbi->s_resuid = EXT3_DEF_RESUID;
2497 sbi->s_resgid = EXT3_DEF_RESGID;
2499 + /* Default extended attribute flags */
2500 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2501 + /* set_opt(sbi->s_mount_opt, XATTR_USER); */
2504 if (!parse_options ((char *) data, &sb_block, sbi, &journal_inum, 0)) {
2507 @@ -1822,22 +1838,35 @@
2509 static int __init init_ext3_fs(void)
2513 init_dquot_operations(&ext3_qops);
2514 old_sync_dquot = ext3_qops.sync_dquot;
2515 ext3_qops.sync_dquot = ext3_sync_dquot;
2517 - return register_filesystem(&ext3_fs_type);
2518 + error = init_ext3_xattr();
2521 + error = init_ext3_xattr_user();
2524 + error = register_filesystem(&ext3_fs_type);
2528 + exit_ext3_xattr_user();
2530 + exit_ext3_xattr();
2534 static void __exit exit_ext3_fs(void)
2536 unregister_filesystem(&ext3_fs_type);
2537 + exit_ext3_xattr_user();
2538 + exit_ext3_xattr();
2541 -EXPORT_SYMBOL(ext3_force_commit);
2542 -EXPORT_SYMBOL(ext3_bread);
2544 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
2545 MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
2546 MODULE_LICENSE("GPL");
2547 Index: linux-2.4.22-vanilla/fs/ext3/symlink.c
2548 ===================================================================
2549 --- linux-2.4.22-vanilla.orig/fs/ext3/symlink.c 2003-11-03 23:41:26.000000000 +0300
2550 +++ linux-2.4.22-vanilla/fs/ext3/symlink.c 2003-12-02 23:55:38.000000000 +0300
2552 #include <linux/fs.h>
2553 #include <linux/jbd.h>
2554 #include <linux/ext3_fs.h>
2555 +#include <linux/ext3_xattr.h>
2557 static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen)
2560 return vfs_follow_link(nd, s);
2563 +struct inode_operations ext3_symlink_inode_operations = {
2564 + readlink: page_readlink, /* BKL not held. Don't need */
2565 + follow_link: page_follow_link, /* BKL not held. Don't need */
2566 + setxattr: ext3_setxattr, /* BKL held */
2567 + getxattr: ext3_getxattr, /* BKL held */
2568 + listxattr: ext3_listxattr, /* BKL held */
2569 + removexattr: ext3_removexattr, /* BKL held */
2572 struct inode_operations ext3_fast_symlink_inode_operations = {
2573 readlink: ext3_readlink, /* BKL not held. Don't need */
2574 follow_link: ext3_follow_link, /* BKL not held. Don't need */
2575 + setxattr: ext3_setxattr, /* BKL held */
2576 + getxattr: ext3_getxattr, /* BKL held */
2577 + listxattr: ext3_listxattr, /* BKL held */
2578 + removexattr: ext3_removexattr, /* BKL held */
2580 Index: linux-2.4.22-vanilla/fs/ext3/xattr.c
2581 ===================================================================
2582 --- linux-2.4.22-vanilla.orig/fs/ext3/xattr.c 2003-12-02 23:55:38.000000000 +0300
2583 +++ linux-2.4.22-vanilla/fs/ext3/xattr.c 2003-12-02 23:55:38.000000000 +0300
2586 + * linux/fs/ext3/xattr.c
2588 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2590 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
2591 + * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
2592 + * Extended attributes for symlinks and special files added per
2593 + * suggestion of Luka Renko <luka.renko@hermes.si>.
2597 + * Extended attributes are stored on disk blocks allocated outside of
2598 + * any inode. The i_file_acl field is then made to point to this allocated
2599 + * block. If all extended attributes of an inode are identical, these
2600 + * inodes may share the same extended attribute block. Such situations
2601 + * are automatically detected by keeping a cache of recent attribute block
2602 + * numbers and hashes over the block's contents in memory.
2605 + * Extended attribute block layout:
2607 + * +------------------+
2610 + * | entry 2 | | growing downwards
2612 + * | four null bytes |
2615 + * | value 3 | | growing upwards
2617 + * +------------------+
2619 + * The block header is followed by multiple entry descriptors. These entry
2620 + * descriptors are variable in size, and alligned to EXT3_XATTR_PAD
2621 + * byte boundaries. The entry descriptors are sorted by attribute name,
2622 + * so that two extended attribute blocks can be compared efficiently.
2624 + * Attribute values are aligned to the end of the block, stored in
2625 + * no specific order. They are also padded to EXT3_XATTR_PAD byte
2626 + * boundaries. No additional gaps are left between them.
2628 + * Locking strategy
2629 + * ----------------
2630 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
2631 + * the xattr inode operations are called, so we are guaranteed that only one
2632 + * processes accesses extended attributes of an inode at any time.
2634 + * For writing we also grab the ext3_xattr_sem semaphore. This ensures that
2635 + * only a single process is modifying an extended attribute block, even
2636 + * if the block is shared among inodes.
2638 + * Note for porting to 2.5
2639 + * -----------------------
2640 + * The BKL will no longer be held in the xattr inode operations.
2643 +#include <linux/module.h>
2644 +#include <linux/fs.h>
2645 +#include <linux/locks.h>
2646 +#include <linux/slab.h>
2647 +#include <linux/ext3_jbd.h>
2648 +#include <linux/ext3_fs.h>
2649 +#include <linux/ext3_xattr.h>
2650 +#include <linux/mbcache.h>
2651 +#include <linux/quotaops.h>
2652 +#include <asm/semaphore.h>
2653 +#include <linux/compatmac.h>
2655 +#define EXT3_EA_USER "user."
2657 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
2658 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
2661 +#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data))
2662 +#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr))
2663 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
2664 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
2666 +#ifdef EXT3_XATTR_DEBUG
2667 +# define ea_idebug(inode, f...) do { \
2668 + printk(KERN_DEBUG "inode %s:%ld: ", \
2669 + kdevname(inode->i_dev), inode->i_ino); \
2673 +# define ea_bdebug(bh, f...) do { \
2674 + printk(KERN_DEBUG "block %s:%ld: ", \
2675 + kdevname(bh->b_dev), bh->b_blocknr); \
2680 +# define ea_idebug(f...)
2681 +# define ea_bdebug(f...)
2684 +static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *,
2685 + struct ext3_xattr_header *);
2687 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
2689 +static int ext3_xattr_cache_insert(struct buffer_head *);
2690 +static struct buffer_head *ext3_xattr_cache_find(struct inode *,
2691 + struct ext3_xattr_header *);
2692 +static void ext3_xattr_cache_remove(struct buffer_head *);
2693 +static void ext3_xattr_rehash(struct ext3_xattr_header *,
2694 + struct ext3_xattr_entry *);
2696 +static struct mb_cache *ext3_xattr_cache;
2699 +# define ext3_xattr_cache_insert(bh) 0
2700 +# define ext3_xattr_cache_find(inode, header) NULL
2701 +# define ext3_xattr_cache_remove(bh) while(0) {}
2702 +# define ext3_xattr_rehash(header, entry) while(0) {}
2706 + * If a file system does not share extended attributes among inodes,
2707 + * we should not need the ext3_xattr_sem semaphore. However, the
2708 + * filesystem may still contain shared blocks, so we always take
2712 +DECLARE_MUTEX(ext3_xattr_sem);
2715 +ext3_xattr_new_block(handle_t *handle, struct inode *inode,
2716 + int * errp, int force)
2718 + struct super_block *sb = inode->i_sb;
2719 + int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
2720 + EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb);
2722 + /* How can we enforce the allocation? */
2723 + int block = ext3_new_block(handle, inode, goal, 0, 0, errp);
2726 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2732 +ext3_xattr_quota_alloc(struct inode *inode, int force)
2734 + /* How can we enforce the allocation? */
2736 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
2738 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2740 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
2748 +ext3_xattr_quota_free(struct inode *inode)
2750 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
2751 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2755 +ext3_xattr_free_block(handle_t *handle, struct inode * inode,
2756 + unsigned long block)
2758 + ext3_free_blocks(handle, inode, block, 1);
2759 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2763 +# define ext3_xattr_quota_free(inode) \
2764 + DQUOT_FREE_BLOCK(inode, 1)
2765 +# define ext3_xattr_free_block(handle, inode, block) \
2766 + ext3_free_blocks(handle, inode, block, 1)
2769 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
2771 +static inline struct buffer_head *
2772 +sb_bread(struct super_block *sb, int block)
2774 + return bread(sb->s_dev, block, sb->s_blocksize);
2777 +static inline struct buffer_head *
2778 +sb_getblk(struct super_block *sb, int block)
2780 + return getblk(sb->s_dev, block, sb->s_blocksize);
2785 +struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
2786 +rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
2789 +ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
2791 + int error = -EINVAL;
2793 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2794 + write_lock(&ext3_handler_lock);
2795 + if (!ext3_xattr_handlers[name_index-1]) {
2796 + ext3_xattr_handlers[name_index-1] = handler;
2799 + write_unlock(&ext3_handler_lock);
2805 +ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
2807 + if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
2808 + write_lock(&ext3_handler_lock);
2809 + ext3_xattr_handlers[name_index-1] = NULL;
2810 + write_unlock(&ext3_handler_lock);
2814 +static inline const char *
2815 +strcmp_prefix(const char *a, const char *a_prefix)
2817 + while (*a_prefix && *a == *a_prefix) {
2821 + return *a_prefix ? NULL : a;
2825 + * Decode the extended attribute name, and translate it into
2826 + * the name_index and name suffix.
2828 +static inline struct ext3_xattr_handler *
2829 +ext3_xattr_resolve_name(const char **name)
2831 + struct ext3_xattr_handler *handler = NULL;
2836 + read_lock(&ext3_handler_lock);
2837 + for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
2838 + if (ext3_xattr_handlers[i]) {
2839 + const char *n = strcmp_prefix(*name,
2840 + ext3_xattr_handlers[i]->prefix);
2842 + handler = ext3_xattr_handlers[i];
2848 + read_unlock(&ext3_handler_lock);
2852 +static inline struct ext3_xattr_handler *
2853 +ext3_xattr_handler(int name_index)
2855 + struct ext3_xattr_handler *handler = NULL;
2856 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2857 + read_lock(&ext3_handler_lock);
2858 + handler = ext3_xattr_handlers[name_index-1];
2859 + read_unlock(&ext3_handler_lock);
2865 + * Inode operation getxattr()
2867 + * dentry->d_inode->i_sem down
2868 + * BKL held [before 2.5.x]
2871 +ext3_getxattr(struct dentry *dentry, const char *name,
2872 + void *buffer, size_t size)
2874 + struct ext3_xattr_handler *handler;
2875 + struct inode *inode = dentry->d_inode;
2877 + handler = ext3_xattr_resolve_name(&name);
2880 + return handler->get(inode, name, buffer, size);
2884 + * Inode operation listxattr()
2886 + * dentry->d_inode->i_sem down
2887 + * BKL held [before 2.5.x]
2890 +ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
2892 + return ext3_xattr_list(dentry->d_inode, buffer, size);
2896 + * Inode operation setxattr()
2898 + * dentry->d_inode->i_sem down
2899 + * BKL held [before 2.5.x]
2902 +ext3_setxattr(struct dentry *dentry, const char *name,
2903 + const void *value, size_t size, int flags)
2905 + struct ext3_xattr_handler *handler;
2906 + struct inode *inode = dentry->d_inode;
2909 + value = ""; /* empty EA, do not remove */
2910 + handler = ext3_xattr_resolve_name(&name);
2913 + return handler->set(inode, name, value, size, flags);
2917 + * Inode operation removexattr()
2919 + * dentry->d_inode->i_sem down
2920 + * BKL held [before 2.5.x]
2923 +ext3_removexattr(struct dentry *dentry, const char *name)
2925 + struct ext3_xattr_handler *handler;
2926 + struct inode *inode = dentry->d_inode;
2928 + handler = ext3_xattr_resolve_name(&name);
2931 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
2935 + * ext3_xattr_get()
2937 + * Copy an extended attribute into the buffer
2938 + * provided, or compute the buffer size required.
2939 + * Buffer is NULL to compute the size of the buffer required.
2941 + * Returns a negative error number on failure, or the number of bytes
2942 + * used / required on success.
2945 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
2946 + void *buffer, size_t buffer_size)
2948 + struct buffer_head *bh = NULL;
2949 + struct ext3_xattr_entry *entry;
2950 + unsigned int block, size;
2952 + int name_len, error;
2954 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
2955 + name_index, name, buffer, (long)buffer_size);
2959 + if (!EXT3_I(inode)->i_file_acl)
2961 + block = EXT3_I(inode)->i_file_acl;
2962 + ea_idebug(inode, "reading block %d", block);
2963 + bh = sb_bread(inode->i_sb, block);
2966 + ea_bdebug(bh, "b_count=%d, refcount=%d",
2967 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
2968 + end = bh->b_data + bh->b_size;
2969 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
2970 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
2971 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_get",
2972 + "inode %ld: bad block %d", inode->i_ino, block);
2976 + /* find named attribute */
2977 + name_len = strlen(name);
2980 + if (name_len > 255)
2982 + entry = FIRST_ENTRY(bh);
2983 + while (!IS_LAST_ENTRY(entry)) {
2984 + struct ext3_xattr_entry *next =
2985 + EXT3_XATTR_NEXT(entry);
2986 + if ((char *)next >= end)
2988 + if (name_index == entry->e_name_index &&
2989 + name_len == entry->e_name_len &&
2990 + memcmp(name, entry->e_name, name_len) == 0)
2994 + /* Check the remaining name entries */
2995 + while (!IS_LAST_ENTRY(entry)) {
2996 + struct ext3_xattr_entry *next =
2997 + EXT3_XATTR_NEXT(entry);
2998 + if ((char *)next >= end)
3002 + if (ext3_xattr_cache_insert(bh))
3003 + ea_idebug(inode, "cache insert failed");
3007 + /* check the buffer size */
3008 + if (entry->e_value_block != 0)
3010 + size = le32_to_cpu(entry->e_value_size);
3011 + if (size > inode->i_sb->s_blocksize ||
3012 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
3015 + if (ext3_xattr_cache_insert(bh))
3016 + ea_idebug(inode, "cache insert failed");
3019 + if (size > buffer_size)
3021 + /* return value of attribute */
3022 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
3034 + * ext3_xattr_list()
3036 + * Copy a list of attribute names into the buffer
3037 + * provided, or compute the buffer size required.
3038 + * Buffer is NULL to compute the size of the buffer required.
3040 + * Returns a negative error number on failure, or the number of bytes
3041 + * used / required on success.
3044 +ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
3046 + struct buffer_head *bh = NULL;
3047 + struct ext3_xattr_entry *entry;
3048 + unsigned int block, size = 0;
3052 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
3053 + buffer, (long)buffer_size);
3055 + if (!EXT3_I(inode)->i_file_acl)
3057 + block = EXT3_I(inode)->i_file_acl;
3058 + ea_idebug(inode, "reading block %d", block);
3059 + bh = sb_bread(inode->i_sb, block);
3062 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3063 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
3064 + end = bh->b_data + bh->b_size;
3065 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3066 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3067 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_list",
3068 + "inode %ld: bad block %d", inode->i_ino, block);
3072 + /* compute the size required for the list of attribute names */
3073 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
3074 + entry = EXT3_XATTR_NEXT(entry)) {
3075 + struct ext3_xattr_handler *handler;
3076 + struct ext3_xattr_entry *next =
3077 + EXT3_XATTR_NEXT(entry);
3078 + if ((char *)next >= end)
3081 + handler = ext3_xattr_handler(entry->e_name_index);
3083 + size += handler->list(NULL, inode, entry->e_name,
3084 + entry->e_name_len);
3087 + if (ext3_xattr_cache_insert(bh))
3088 + ea_idebug(inode, "cache insert failed");
3094 + if (size > buffer_size)
3098 + /* list the attribute names */
3100 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
3101 + entry = EXT3_XATTR_NEXT(entry)) {
3102 + struct ext3_xattr_handler *handler;
3104 + handler = ext3_xattr_handler(entry->e_name_index);
3106 + buf += handler->list(buf, inode, entry->e_name,
3107 + entry->e_name_len);
3118 + * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is
3119 + * not set, set it.
3121 +static void ext3_xattr_update_super_block(handle_t *handle,
3122 + struct super_block *sb)
3124 + if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
3128 + ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
3129 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
3130 + EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR;
3132 + EXT3_SB(sb)->s_es->s_feature_compat |=
3133 + cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
3135 + ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
3140 + * ext3_xattr_set()
3142 + * Create, replace or remove an extended attribute for this inode. Buffer
3143 + * is NULL to remove an existing extended attribute, and non-NULL to
3144 + * either replace an existing extended attribute, or create a new extended
3145 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
3146 + * specify that an extended attribute must exist and must not exist
3147 + * previous to the call, respectively.
3149 + * Returns 0, or a negative error number on failure.
3152 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
3153 + const char *name, const void *value, size_t value_len, int flags)
3155 + struct super_block *sb = inode->i_sb;
3156 + struct buffer_head *bh = NULL;
3157 + struct ext3_xattr_header *header = NULL;
3158 + struct ext3_xattr_entry *here, *last;
3159 + unsigned int name_len;
3160 + int block = EXT3_I(inode)->i_file_acl;
3161 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
3165 + * header -- Points either into bh, or to a temporarily
3166 + * allocated buffer.
3167 + * here -- The named entry found, or the place for inserting, within
3168 + * the block pointed to by header.
3169 + * last -- Points right after the last named entry within the block
3170 + * pointed to by header.
3171 + * min_offs -- The offset of the first value (values are aligned
3172 + * towards the end of the block).
3173 + * end -- Points right after the block pointed to by header.
3176 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
3177 + name_index, name, value, (long)value_len);
3179 + if (IS_RDONLY(inode))
3181 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3183 + if (value == NULL)
3187 + name_len = strlen(name);
3188 + if (name_len > 255 || value_len > sb->s_blocksize)
3190 + down(&ext3_xattr_sem);
3193 + /* The inode already has an extended attribute block. */
3194 + bh = sb_bread(sb, block);
3198 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3199 + atomic_read(&(bh->b_count)),
3200 + le32_to_cpu(HDR(bh)->h_refcount));
3202 + end = bh->b_data + bh->b_size;
3203 + if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3204 + header->h_blocks != cpu_to_le32(1)) {
3205 +bad_block: ext3_error(sb, "ext3_xattr_set",
3206 + "inode %ld: bad block %d", inode->i_ino, block);
3210 + /* Find the named attribute. */
3211 + here = FIRST_ENTRY(bh);
3212 + while (!IS_LAST_ENTRY(here)) {
3213 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here);
3214 + if ((char *)next >= end)
3216 + if (!here->e_value_block && here->e_value_size) {
3217 + int offs = le16_to_cpu(here->e_value_offs);
3218 + if (offs < min_offs)
3221 + not_found = name_index - here->e_name_index;
3223 + not_found = name_len - here->e_name_len;
3225 + not_found = memcmp(name, here->e_name,name_len);
3226 + if (not_found <= 0)
3231 + /* We still need to compute min_offs and last. */
3232 + while (!IS_LAST_ENTRY(last)) {
3233 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last);
3234 + if ((char *)next >= end)
3236 + if (!last->e_value_block && last->e_value_size) {
3237 + int offs = le16_to_cpu(last->e_value_offs);
3238 + if (offs < min_offs)
3244 + /* Check whether we have enough space left. */
3245 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
3247 + /* We will use a new extended attribute block. */
3248 + free = sb->s_blocksize -
3249 + sizeof(struct ext3_xattr_header) - sizeof(__u32);
3250 + here = last = NULL; /* avoid gcc uninitialized warning. */
3254 + /* Request to remove a nonexistent attribute? */
3256 + if (flags & XATTR_REPLACE)
3259 + if (value == NULL)
3262 + free -= EXT3_XATTR_LEN(name_len);
3264 + /* Request to create an existing attribute? */
3266 + if (flags & XATTR_CREATE)
3268 + if (!here->e_value_block && here->e_value_size) {
3269 + unsigned int size = le32_to_cpu(here->e_value_size);
3271 + if (le16_to_cpu(here->e_value_offs) + size >
3272 + sb->s_blocksize || size > sb->s_blocksize)
3274 + free += EXT3_XATTR_SIZE(size);
3277 + free -= EXT3_XATTR_SIZE(value_len);
3282 + /* Here we know that we can set the new attribute. */
3285 + if (header->h_refcount == cpu_to_le32(1)) {
3286 + ea_bdebug(bh, "modifying in-place");
3287 + ext3_xattr_cache_remove(bh);
3288 + error = ext3_journal_get_write_access(handle, bh);
3294 + ea_bdebug(bh, "cloning");
3295 + header = kmalloc(bh->b_size, GFP_KERNEL);
3297 + if (header == NULL)
3299 + memcpy(header, HDR(bh), bh->b_size);
3300 + header->h_refcount = cpu_to_le32(1);
3301 + offset = (char *)header - bh->b_data;
3302 + here = ENTRY((char *)here + offset);
3303 + last = ENTRY((char *)last + offset);
3306 + /* Allocate a buffer where we construct the new block. */
3307 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
3309 + if (header == NULL)
3311 + memset(header, 0, sb->s_blocksize);
3312 + end = (char *)header + sb->s_blocksize;
3313 + header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
3314 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
3315 + last = here = ENTRY(header+1);
3319 + /* Insert the new name. */
3320 + int size = EXT3_XATTR_LEN(name_len);
3321 + int rest = (char *)last - (char *)here;
3322 + memmove((char *)here + size, here, rest);
3323 + memset(here, 0, size);
3324 + here->e_name_index = name_index;
3325 + here->e_name_len = name_len;
3326 + memcpy(here->e_name, name, name_len);
3328 + /* Remove the old value. */
3329 + if (!here->e_value_block && here->e_value_size) {
3330 + char *first_val = (char *)header + min_offs;
3331 + int offs = le16_to_cpu(here->e_value_offs);
3332 + char *val = (char *)header + offs;
3333 + size_t size = EXT3_XATTR_SIZE(
3334 + le32_to_cpu(here->e_value_size));
3335 + memmove(first_val + size, first_val, val - first_val);
3336 + memset(first_val, 0, size);
3337 + here->e_value_offs = 0;
3340 + /* Adjust all value offsets. */
3341 + last = ENTRY(header+1);
3342 + while (!IS_LAST_ENTRY(last)) {
3343 + int o = le16_to_cpu(last->e_value_offs);
3344 + if (!last->e_value_block && o < offs)
3345 + last->e_value_offs =
3346 + cpu_to_le16(o + size);
3347 + last = EXT3_XATTR_NEXT(last);
3350 + if (value == NULL) {
3351 + /* Remove this attribute. */
3352 + if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) {
3353 + /* This block is now empty. */
3354 + error = ext3_xattr_set2(handle, inode, bh,NULL);
3357 + /* Remove the old name. */
3358 + int size = EXT3_XATTR_LEN(name_len);
3359 + last = ENTRY((char *)last - size);
3360 + memmove(here, (char*)here + size,
3361 + (char*)last - (char*)here);
3362 + memset(last, 0, size);
3367 + if (value != NULL) {
3368 + /* Insert the new value. */
3369 + here->e_value_size = cpu_to_le32(value_len);
3371 + size_t size = EXT3_XATTR_SIZE(value_len);
3372 + char *val = (char *)header + min_offs - size;
3373 + here->e_value_offs =
3374 + cpu_to_le16((char *)val - (char *)header);
3375 + memset(val + size - EXT3_XATTR_PAD, 0,
3376 + EXT3_XATTR_PAD); /* Clear the pad bytes. */
3377 + memcpy(val, value, value_len);
3380 + ext3_xattr_rehash(header, here);
3382 + error = ext3_xattr_set2(handle, inode, bh, header);
3386 + if (!(bh && header == HDR(bh)))
3388 + up(&ext3_xattr_sem);
3394 + * Second half of ext3_xattr_set(): Update the file system.
3397 +ext3_xattr_set2(handle_t *handle, struct inode *inode,
3398 + struct buffer_head *old_bh, struct ext3_xattr_header *header)
3400 + struct super_block *sb = inode->i_sb;
3401 + struct buffer_head *new_bh = NULL;
3405 + new_bh = ext3_xattr_cache_find(inode, header);
3408 + * We found an identical block in the cache.
3409 + * The old block will be released after updating
3412 + ea_bdebug(old_bh, "reusing block %ld",
3413 + new_bh->b_blocknr);
3416 + if (ext3_xattr_quota_alloc(inode, 1))
3419 + error = ext3_journal_get_write_access(handle, new_bh);
3422 + HDR(new_bh)->h_refcount = cpu_to_le32(
3423 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
3424 + ea_bdebug(new_bh, "refcount now=%d",
3425 + le32_to_cpu(HDR(new_bh)->h_refcount));
3426 + } else if (old_bh && header == HDR(old_bh)) {
3427 + /* Keep this block. */
3429 + (void)ext3_xattr_cache_insert(new_bh);
3431 + /* We need to allocate a new block */
3432 + int force = EXT3_I(inode)->i_file_acl != 0;
3433 + int block = ext3_xattr_new_block(handle, inode,
3437 + ea_idebug(inode, "creating block %d", block);
3439 + new_bh = sb_getblk(sb, block);
3441 +getblk_failed: ext3_xattr_free_block(handle, inode, block);
3445 + lock_buffer(new_bh);
3446 + error = ext3_journal_get_create_access(handle, new_bh);
3448 + unlock_buffer(new_bh);
3449 + goto getblk_failed;
3451 + memcpy(new_bh->b_data, header, new_bh->b_size);
3452 + mark_buffer_uptodate(new_bh, 1);
3453 + unlock_buffer(new_bh);
3454 + (void)ext3_xattr_cache_insert(new_bh);
3456 + ext3_xattr_update_super_block(handle, sb);
3458 + error = ext3_journal_dirty_metadata(handle, new_bh);
3463 + /* Update the inode. */
3464 + EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
3465 + inode->i_ctime = CURRENT_TIME;
3466 + ext3_mark_inode_dirty(handle, inode);
3467 + if (IS_SYNC(inode))
3468 + handle->h_sync = 1;
3471 + if (old_bh && old_bh != new_bh) {
3473 + * If there was an old block, and we are not still using it,
3474 + * we now release the old block.
3476 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
3478 + error = ext3_journal_get_write_access(handle, old_bh);
3481 + if (refcount == 1) {
3482 + /* Free the old block. */
3483 + ea_bdebug(old_bh, "freeing");
3484 + ext3_xattr_free_block(handle, inode, old_bh->b_blocknr);
3486 + /* ext3_forget() calls bforget() for us, but we
3487 + let our caller release old_bh, so we need to
3488 + duplicate the handle before. */
3490 + ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr);
3492 + /* Decrement the refcount only. */
3494 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
3495 + ext3_xattr_quota_free(inode);
3496 + ext3_journal_dirty_metadata(handle, old_bh);
3497 + ea_bdebug(old_bh, "refcount now=%d", refcount);
3502 + if (old_bh != new_bh)
3509 + * ext3_xattr_delete_inode()
3511 + * Free extended attribute resources associated with this inode. This
3512 + * is called immediately before an inode is freed.
3515 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
3517 + struct buffer_head *bh;
3518 + unsigned int block = EXT3_I(inode)->i_file_acl;
3522 + down(&ext3_xattr_sem);
3524 + bh = sb_bread(inode->i_sb, block);
3526 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3527 + "inode %ld: block %d read error", inode->i_ino, block);
3530 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
3531 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3532 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3533 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3534 + "inode %ld: bad block %d", inode->i_ino, block);
3537 + ext3_journal_get_write_access(handle, bh);
3538 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
3539 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
3540 + ext3_xattr_cache_remove(bh);
3541 + ext3_xattr_free_block(handle, inode, block);
3542 + ext3_forget(handle, 1, inode, bh, block);
3545 + HDR(bh)->h_refcount = cpu_to_le32(
3546 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
3547 + ext3_journal_dirty_metadata(handle, bh);
3548 + if (IS_SYNC(inode))
3549 + handle->h_sync = 1;
3550 + ext3_xattr_quota_free(inode);
3552 + EXT3_I(inode)->i_file_acl = 0;
3556 + up(&ext3_xattr_sem);
3560 + * ext3_xattr_put_super()
3562 + * This is called when a file system is unmounted.
3565 +ext3_xattr_put_super(struct super_block *sb)
3567 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3568 + mb_cache_shrink(ext3_xattr_cache, sb->s_dev);
3572 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3575 + * ext3_xattr_cache_insert()
3577 + * Create a new entry in the extended attribute cache, and insert
3578 + * it unless such an entry is already in the cache.
3580 + * Returns 0, or a negative error number on failure.
3583 +ext3_xattr_cache_insert(struct buffer_head *bh)
3585 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
3586 + struct mb_cache_entry *ce;
3589 + ce = mb_cache_entry_alloc(ext3_xattr_cache);
3592 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
3594 + mb_cache_entry_free(ce);
3595 + if (error == -EBUSY) {
3596 + ea_bdebug(bh, "already in cache (%d cache entries)",
3597 + atomic_read(&ext3_xattr_cache->c_entry_count));
3601 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
3602 + atomic_read(&ext3_xattr_cache->c_entry_count));
3603 + mb_cache_entry_release(ce);
3609 + * ext3_xattr_cmp()
3611 + * Compare two extended attribute blocks for equality.
3613 + * Returns 0 if the blocks are equal, 1 if they differ, and
3614 + * a negative error number on errors.
3617 +ext3_xattr_cmp(struct ext3_xattr_header *header1,
3618 + struct ext3_xattr_header *header2)
3620 + struct ext3_xattr_entry *entry1, *entry2;
3622 + entry1 = ENTRY(header1+1);
3623 + entry2 = ENTRY(header2+1);
3624 + while (!IS_LAST_ENTRY(entry1)) {
3625 + if (IS_LAST_ENTRY(entry2))
3627 + if (entry1->e_hash != entry2->e_hash ||
3628 + entry1->e_name_len != entry2->e_name_len ||
3629 + entry1->e_value_size != entry2->e_value_size ||
3630 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
3632 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
3634 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
3635 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
3636 + le32_to_cpu(entry1->e_value_size)))
3639 + entry1 = EXT3_XATTR_NEXT(entry1);
3640 + entry2 = EXT3_XATTR_NEXT(entry2);
3642 + if (!IS_LAST_ENTRY(entry2))
3648 + * ext3_xattr_cache_find()
3650 + * Find an identical extended attribute block.
3652 + * Returns a pointer to the block found, or NULL if such a block was
3653 + * not found or an error occurred.
3655 +static struct buffer_head *
3656 +ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header)
3658 + __u32 hash = le32_to_cpu(header->h_hash);
3659 + struct mb_cache_entry *ce;
3661 + if (!header->h_hash)
3662 + return NULL; /* never share */
3663 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
3664 + ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash);
3666 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
3669 + ext3_error(inode->i_sb, "ext3_xattr_cache_find",
3670 + "inode %ld: block %ld read error",
3671 + inode->i_ino, ce->e_block);
3672 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
3673 + EXT3_XATTR_REFCOUNT_MAX) {
3674 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
3675 + le32_to_cpu(HDR(bh)->h_refcount),
3676 + EXT3_XATTR_REFCOUNT_MAX);
3677 + } else if (!ext3_xattr_cmp(header, HDR(bh))) {
3678 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
3679 + mb_cache_entry_release(ce);
3683 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
3689 + * ext3_xattr_cache_remove()
3691 + * Remove the cache entry of a block from the cache. Called when a
3692 + * block becomes invalid.
3695 +ext3_xattr_cache_remove(struct buffer_head *bh)
3697 + struct mb_cache_entry *ce;
3699 + ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr);
3701 + ea_bdebug(bh, "removing (%d cache entries remaining)",
3702 + atomic_read(&ext3_xattr_cache->c_entry_count)-1);
3703 + mb_cache_entry_free(ce);
3705 + ea_bdebug(bh, "no cache entry");
3708 +#define NAME_HASH_SHIFT 5
3709 +#define VALUE_HASH_SHIFT 16
3712 + * ext3_xattr_hash_entry()
3714 + * Compute the hash of an extended attribute.
3716 +static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
3717 + struct ext3_xattr_entry *entry)
3720 + char *name = entry->e_name;
3723 + for (n=0; n < entry->e_name_len; n++) {
3724 + hash = (hash << NAME_HASH_SHIFT) ^
3725 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
3729 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
3730 + __u32 *value = (__u32 *)((char *)header +
3731 + le16_to_cpu(entry->e_value_offs));
3732 + for (n = (le32_to_cpu(entry->e_value_size) +
3733 + EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
3734 + hash = (hash << VALUE_HASH_SHIFT) ^
3735 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
3736 + le32_to_cpu(*value++);
3739 + entry->e_hash = cpu_to_le32(hash);
3742 +#undef NAME_HASH_SHIFT
3743 +#undef VALUE_HASH_SHIFT
3745 +#define BLOCK_HASH_SHIFT 16
3748 + * ext3_xattr_rehash()
3750 + * Re-compute the extended attribute hash value after an entry has changed.
3752 +static void ext3_xattr_rehash(struct ext3_xattr_header *header,
3753 + struct ext3_xattr_entry *entry)
3755 + struct ext3_xattr_entry *here;
3758 + ext3_xattr_hash_entry(header, entry);
3759 + here = ENTRY(header+1);
3760 + while (!IS_LAST_ENTRY(here)) {
3761 + if (!here->e_hash) {
3762 + /* Block is not shared if an entry's hash value == 0 */
3766 + hash = (hash << BLOCK_HASH_SHIFT) ^
3767 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
3768 + le32_to_cpu(here->e_hash);
3769 + here = EXT3_XATTR_NEXT(here);
3771 + header->h_hash = cpu_to_le32(hash);
3774 +#undef BLOCK_HASH_SHIFT
3777 +init_ext3_xattr(void)
3779 + ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
3780 + sizeof(struct mb_cache_entry) +
3781 + sizeof(struct mb_cache_entry_index), 1, 61);
3782 + if (!ext3_xattr_cache)
3789 +exit_ext3_xattr(void)
3791 + if (ext3_xattr_cache)
3792 + mb_cache_destroy(ext3_xattr_cache);
3793 + ext3_xattr_cache = NULL;
3796 +#else /* CONFIG_EXT3_FS_XATTR_SHARING */
3799 +init_ext3_xattr(void)
3805 +exit_ext3_xattr(void)
3809 +#endif /* CONFIG_EXT3_FS_XATTR_SHARING */
3810 Index: linux-2.4.22-vanilla/fs/ext3/xattr_user.c
3811 ===================================================================
3812 --- linux-2.4.22-vanilla.orig/fs/ext3/xattr_user.c 2003-12-02 23:55:38.000000000 +0300
3813 +++ linux-2.4.22-vanilla/fs/ext3/xattr_user.c 2003-12-02 23:55:39.000000000 +0300
3816 + * linux/fs/ext3/xattr_user.c
3817 + * Handler for extended user attributes.
3819 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
3822 +#include <linux/module.h>
3823 +#include <linux/string.h>
3824 +#include <linux/fs.h>
3825 +#include <linux/ext3_jbd.h>
3826 +#include <linux/ext3_fs.h>
3827 +#include <linux/ext3_xattr.h>
3829 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3830 +# include <linux/ext3_acl.h>
3833 +#define XATTR_USER_PREFIX "user."
3836 +ext3_xattr_user_list(char *list, struct inode *inode,
3837 + const char *name, int name_len)
3839 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
3841 + if (!test_opt(inode->i_sb, XATTR_USER))
3845 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
3846 + memcpy(list+prefix_len, name, name_len);
3847 + list[prefix_len + name_len] = '\0';
3849 + return prefix_len + name_len + 1;
3853 +ext3_xattr_user_get(struct inode *inode, const char *name,
3854 + void *buffer, size_t size)
3858 + if (strcmp(name, "") == 0)
3860 + if (!test_opt(inode->i_sb, XATTR_USER))
3862 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3863 + error = ext3_permission_locked(inode, MAY_READ);
3865 + error = permission(inode, MAY_READ);
3870 + return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name,
3875 +ext3_xattr_user_set(struct inode *inode, const char *name,
3876 + const void *value, size_t size, int flags)
3881 + if (strcmp(name, "") == 0)
3883 + if (!test_opt(inode->i_sb, XATTR_USER))
3885 + if ( !S_ISREG(inode->i_mode) &&
3886 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
3888 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3889 + error = ext3_permission_locked(inode, MAY_WRITE);
3891 + error = permission(inode, MAY_WRITE);
3896 + handle = ext3_journal_start(inode, EXT3_XATTR_TRANS_BLOCKS);
3897 + if (IS_ERR(handle))
3898 + return PTR_ERR(handle);
3899 + error = ext3_xattr_set(handle, inode, EXT3_XATTR_INDEX_USER, name,
3900 + value, size, flags);
3901 + ext3_journal_stop(handle, inode);
3906 +struct ext3_xattr_handler ext3_xattr_user_handler = {
3907 + prefix: XATTR_USER_PREFIX,
3908 + list: ext3_xattr_user_list,
3909 + get: ext3_xattr_user_get,
3910 + set: ext3_xattr_user_set,
3914 +init_ext3_xattr_user(void)
3916 + return ext3_xattr_register(EXT3_XATTR_INDEX_USER,
3917 + &ext3_xattr_user_handler);
3921 +exit_ext3_xattr_user(void)
3923 + ext3_xattr_unregister(EXT3_XATTR_INDEX_USER,
3924 + &ext3_xattr_user_handler);
3926 Index: linux-2.4.22-vanilla/fs/jfs/jfs_xattr.h
3927 ===================================================================
3928 --- linux-2.4.22-vanilla.orig/fs/jfs/jfs_xattr.h 2003-11-03 23:41:26.000000000 +0300
3929 +++ linux-2.4.22-vanilla/fs/jfs/jfs_xattr.h 2003-12-02 23:55:39.000000000 +0300
3931 #define END_EALIST(ealist) \
3932 ((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist)))
3934 -extern int __jfs_setxattr(struct inode *, const char *, void *, size_t, int);
3935 -extern int jfs_setxattr(struct dentry *, const char *, void *, size_t, int);
3936 +extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t,
3938 +extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
3940 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
3941 extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
3942 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
3943 Index: linux-2.4.22-vanilla/fs/jfs/xattr.c
3944 ===================================================================
3945 --- linux-2.4.22-vanilla.orig/fs/jfs/xattr.c 2003-11-03 23:41:26.000000000 +0300
3946 +++ linux-2.4.22-vanilla/fs/jfs/xattr.c 2003-12-02 23:55:39.000000000 +0300
3950 static int can_set_xattr(struct inode *inode, const char *name,
3951 - void *value, size_t value_len)
3952 + const void *value, size_t value_len)
3954 if (IS_RDONLY(inode))
3957 return permission(inode, MAY_WRITE);
3960 -int __jfs_setxattr(struct inode *inode, const char *name, void *value,
3961 +int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
3962 size_t value_len, int flags)
3964 struct jfs_ea_list *ealist;
3969 -int jfs_setxattr(struct dentry *dentry, const char *name, void *value,
3970 +int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
3971 size_t value_len, int flags)
3973 if (value == NULL) { /* empty EA, do not remove */
3974 Index: linux-2.4.22-vanilla/fs/mbcache.c
3975 ===================================================================
3976 --- linux-2.4.22-vanilla.orig/fs/mbcache.c 2003-12-02 23:55:38.000000000 +0300
3977 +++ linux-2.4.22-vanilla/fs/mbcache.c 2003-12-02 23:55:39.000000000 +0300
3980 + * linux/fs/mbcache.c
3981 + * (C) 2001-2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
3985 + * Filesystem Meta Information Block Cache (mbcache)
3987 + * The mbcache caches blocks of block devices that need to be located
3988 + * by their device/block number, as well as by other criteria (such
3989 + * as the block's contents).
3991 + * There can only be one cache entry in a cache per device and block number.
3992 + * Additional indexes need not be unique in this sense. The number of
3993 + * additional indexes (=other criteria) can be hardwired at compile time
3994 + * or specified at cache create time.
3996 + * Each cache entry is of fixed size. An entry may be `valid' or `invalid'
3997 + * in the cache. A valid entry is in the main hash tables of the cache,
3998 + * and may also be in the lru list. An invalid entry is not in any hashes
4001 + * A valid cache entry is only in the lru list if no handles refer to it.
4002 + * Invalid cache entries will be freed when the last handle to the cache
4003 + * entry is released. Entries that cannot be freed immediately are put
4004 + * back on the lru list.
4007 +#include <linux/kernel.h>
4008 +#include <linux/module.h>
4010 +#include <linux/fs.h>
4011 +#include <linux/slab.h>
4012 +#include <linux/sched.h>
4013 +#include <linux/cache_def.h>
4014 +#include <linux/version.h>
4015 +#include <linux/init.h>
4016 +#include <linux/mbcache.h>
4019 +#ifdef MB_CACHE_DEBUG
4020 +# define mb_debug(f...) do { \
4021 + printk(KERN_DEBUG f); \
4024 +#define mb_assert(c) do { if (!(c)) \
4025 + printk(KERN_ERR "assertion " #c " failed\n"); \
4028 +# define mb_debug(f...) do { } while(0)
4029 +# define mb_assert(c) do { } while(0)
4031 +#define mb_error(f...) do { \
4032 + printk(KERN_ERR f); \
4036 +MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>");
4037 +MODULE_DESCRIPTION("Meta block cache (for extended attributes)");
4038 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
4039 +MODULE_LICENSE("GPL");
4042 +EXPORT_SYMBOL(mb_cache_create);
4043 +EXPORT_SYMBOL(mb_cache_shrink);
4044 +EXPORT_SYMBOL(mb_cache_destroy);
4045 +EXPORT_SYMBOL(mb_cache_entry_alloc);
4046 +EXPORT_SYMBOL(mb_cache_entry_insert);
4047 +EXPORT_SYMBOL(mb_cache_entry_release);
4048 +EXPORT_SYMBOL(mb_cache_entry_takeout);
4049 +EXPORT_SYMBOL(mb_cache_entry_free);
4050 +EXPORT_SYMBOL(mb_cache_entry_dup);
4051 +EXPORT_SYMBOL(mb_cache_entry_get);
4052 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
4053 +EXPORT_SYMBOL(mb_cache_entry_find_first);
4054 +EXPORT_SYMBOL(mb_cache_entry_find_next);
4059 + * Global data: list of all mbcache's, lru list, and a spinlock for
4060 + * accessing cache data structures on SMP machines. The lru list is
4061 + * global across all mbcaches.
4064 +static LIST_HEAD(mb_cache_list);
4065 +static LIST_HEAD(mb_cache_lru_list);
4066 +static spinlock_t mb_cache_spinlock = SPIN_LOCK_UNLOCKED;
4069 +mb_cache_indexes(struct mb_cache *cache)
4071 +#ifdef MB_CACHE_INDEXES_COUNT
4072 + return MB_CACHE_INDEXES_COUNT;
4074 + return cache->c_indexes_count;
4079 + * What the mbcache registers as to get shrunk dynamically.
4083 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask);
4085 +static struct cache_definition mb_cache_definition = {
4087 + mb_cache_memory_pressure
4092 +__mb_cache_entry_is_hashed(struct mb_cache_entry *ce)
4094 + return !list_empty(&ce->e_block_list);
4099 +__mb_cache_entry_unhash(struct mb_cache_entry *ce)
4103 + if (__mb_cache_entry_is_hashed(ce)) {
4104 + list_del_init(&ce->e_block_list);
4105 + for (n=0; n<mb_cache_indexes(ce->e_cache); n++)
4106 + list_del(&ce->e_indexes[n].o_list);
4112 +__mb_cache_entry_forget(struct mb_cache_entry *ce, int gfp_mask)
4114 + struct mb_cache *cache = ce->e_cache;
4116 + mb_assert(atomic_read(&ce->e_used) == 0);
4117 + if (cache->c_op.free && cache->c_op.free(ce, gfp_mask)) {
4118 + /* free failed -- put back on the lru list
4119 + for freeing later. */
4120 + spin_lock(&mb_cache_spinlock);
4121 + list_add(&ce->e_lru_list, &mb_cache_lru_list);
4122 + spin_unlock(&mb_cache_spinlock);
4124 + kmem_cache_free(cache->c_entry_cache, ce);
4125 + atomic_dec(&cache->c_entry_count);
4131 +__mb_cache_entry_release_unlock(struct mb_cache_entry *ce)
4133 + if (atomic_dec_and_test(&ce->e_used)) {
4134 + if (__mb_cache_entry_is_hashed(ce))
4135 + list_add_tail(&ce->e_lru_list, &mb_cache_lru_list);
4137 + spin_unlock(&mb_cache_spinlock);
4138 + __mb_cache_entry_forget(ce, GFP_KERNEL);
4142 + spin_unlock(&mb_cache_spinlock);
4147 + * mb_cache_memory_pressure() memory pressure callback
4149 + * This function is called by the kernel memory management when memory
4152 + * @priority: Amount by which to shrink the cache (0 = highes priority)
4153 + * @gfp_mask: (ignored)
4156 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask)
4158 + LIST_HEAD(free_list);
4159 + struct list_head *l, *ltmp;
4162 + spin_lock(&mb_cache_spinlock);
4163 + list_for_each(l, &mb_cache_list) {
4164 + struct mb_cache *cache =
4165 + list_entry(l, struct mb_cache, c_cache_list);
4166 + mb_debug("cache %s (%d)", cache->c_name,
4167 + atomic_read(&cache->c_entry_count));
4168 + count += atomic_read(&cache->c_entry_count);
4170 + mb_debug("trying to free %d of %d entries",
4171 + count / (priority ? priority : 1), count);
4173 + count /= priority;
4174 + while (count-- && !list_empty(&mb_cache_lru_list)) {
4175 + struct mb_cache_entry *ce =
4176 + list_entry(mb_cache_lru_list.next,
4177 + struct mb_cache_entry, e_lru_list);
4178 + list_del(&ce->e_lru_list);
4179 + __mb_cache_entry_unhash(ce);
4180 + list_add_tail(&ce->e_lru_list, &free_list);
4182 + spin_unlock(&mb_cache_spinlock);
4183 + list_for_each_safe(l, ltmp, &free_list) {
4184 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4185 + e_lru_list), gfp_mask);
4191 + * mb_cache_create() create a new cache
4193 + * All entries in one cache are equal size. Cache entries may be from
4194 + * multiple devices. If this is the first mbcache created, registers
4195 + * the cache with kernel memory management. Returns NULL if no more
4196 + * memory was available.
4198 + * @name: name of the cache (informal)
4199 + * @cache_op: contains the callback called when freeing a cache entry
4200 + * @entry_size: The size of a cache entry, including
4201 + * struct mb_cache_entry
4202 + * @indexes_count: number of additional indexes in the cache. Must equal
4203 + * MB_CACHE_INDEXES_COUNT if the number of indexes is
4205 + * @bucket_count: number of hash buckets
4208 +mb_cache_create(const char *name, struct mb_cache_op *cache_op,
4209 + size_t entry_size, int indexes_count, int bucket_count)
4212 + struct mb_cache *cache = NULL;
4214 + if(entry_size < sizeof(struct mb_cache_entry) +
4215 + indexes_count * sizeof(struct mb_cache_entry_index))
4218 + MOD_INC_USE_COUNT;
4219 + cache = kmalloc(sizeof(struct mb_cache) +
4220 + indexes_count * sizeof(struct list_head), GFP_KERNEL);
4223 + cache->c_name = name;
4224 + cache->c_op.free = NULL;
4226 + cache->c_op.free = cache_op->free;
4227 + atomic_set(&cache->c_entry_count, 0);
4228 + cache->c_bucket_count = bucket_count;
4229 +#ifdef MB_CACHE_INDEXES_COUNT
4230 + mb_assert(indexes_count == MB_CACHE_INDEXES_COUNT);
4232 + cache->c_indexes_count = indexes_count;
4234 + cache->c_block_hash = kmalloc(bucket_count * sizeof(struct list_head),
4236 + if (!cache->c_block_hash)
4238 + for (n=0; n<bucket_count; n++)
4239 + INIT_LIST_HEAD(&cache->c_block_hash[n]);
4240 + for (m=0; m<indexes_count; m++) {
4241 + cache->c_indexes_hash[m] = kmalloc(bucket_count *
4242 + sizeof(struct list_head),
4244 + if (!cache->c_indexes_hash[m])
4246 + for (n=0; n<bucket_count; n++)
4247 + INIT_LIST_HEAD(&cache->c_indexes_hash[m][n]);
4249 + cache->c_entry_cache = kmem_cache_create(name, entry_size, 0,
4250 + 0 /*SLAB_POISON | SLAB_RED_ZONE*/, NULL, NULL);
4251 + if (!cache->c_entry_cache)
4254 + spin_lock(&mb_cache_spinlock);
4255 + list_add(&cache->c_cache_list, &mb_cache_list);
4256 + spin_unlock(&mb_cache_spinlock);
4262 + kfree(cache->c_indexes_hash[m]);
4263 + if (cache->c_block_hash)
4264 + kfree(cache->c_block_hash);
4267 + MOD_DEC_USE_COUNT;
4273 + * mb_cache_shrink()
4275 + * Removes all cache entires of a device from the cache. All cache entries
4276 + * currently in use cannot be freed, and thus remain in the cache.
4278 + * @cache: which cache to shrink
4279 + * @dev: which device's cache entries to shrink
4282 +mb_cache_shrink(struct mb_cache *cache, kdev_t dev)
4284 + LIST_HEAD(free_list);
4285 + struct list_head *l, *ltmp;
4287 + spin_lock(&mb_cache_spinlock);
4288 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4289 + struct mb_cache_entry *ce =
4290 + list_entry(l, struct mb_cache_entry, e_lru_list);
4291 + if (ce->e_dev == dev) {
4292 + list_del(&ce->e_lru_list);
4293 + list_add_tail(&ce->e_lru_list, &free_list);
4294 + __mb_cache_entry_unhash(ce);
4297 + spin_unlock(&mb_cache_spinlock);
4298 + list_for_each_safe(l, ltmp, &free_list) {
4299 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4300 + e_lru_list), GFP_KERNEL);
4306 + * mb_cache_destroy()
4308 + * Shrinks the cache to its minimum possible size (hopefully 0 entries),
4309 + * and then destroys it. If this was the last mbcache, un-registers the
4310 + * mbcache from kernel memory management.
4313 +mb_cache_destroy(struct mb_cache *cache)
4315 + LIST_HEAD(free_list);
4316 + struct list_head *l, *ltmp;
4319 + spin_lock(&mb_cache_spinlock);
4320 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4321 + struct mb_cache_entry *ce =
4322 + list_entry(l, struct mb_cache_entry, e_lru_list);
4323 + if (ce->e_cache == cache) {
4324 + list_del(&ce->e_lru_list);
4325 + list_add_tail(&ce->e_lru_list, &free_list);
4326 + __mb_cache_entry_unhash(ce);
4329 + list_del(&cache->c_cache_list);
4330 + spin_unlock(&mb_cache_spinlock);
4331 + list_for_each_safe(l, ltmp, &free_list) {
4332 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4333 + e_lru_list), GFP_KERNEL);
4336 + if (atomic_read(&cache->c_entry_count) > 0) {
4337 + mb_error("cache %s: %d orphaned entries",
4339 + atomic_read(&cache->c_entry_count));
4342 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
4343 + /* We don't have kmem_cache_destroy() in 2.2.x */
4344 + kmem_cache_shrink(cache->c_entry_cache);
4346 + kmem_cache_destroy(cache->c_entry_cache);
4348 + for (n=0; n < mb_cache_indexes(cache); n++)
4349 + kfree(cache->c_indexes_hash[n]);
4350 + kfree(cache->c_block_hash);
4353 + MOD_DEC_USE_COUNT;
4358 + * mb_cache_entry_alloc()
4360 + * Allocates a new cache entry. The new entry will not be valid initially,
4361 + * and thus cannot be looked up yet. It should be filled with data, and
4362 + * then inserted into the cache using mb_cache_entry_insert(). Returns NULL
4363 + * if no more memory was available.
4365 +struct mb_cache_entry *
4366 +mb_cache_entry_alloc(struct mb_cache *cache)
4368 + struct mb_cache_entry *ce;
4370 + atomic_inc(&cache->c_entry_count);
4371 + ce = kmem_cache_alloc(cache->c_entry_cache, GFP_KERNEL);
4373 + INIT_LIST_HEAD(&ce->e_lru_list);
4374 + INIT_LIST_HEAD(&ce->e_block_list);
4375 + ce->e_cache = cache;
4376 + atomic_set(&ce->e_used, 1);
4383 + * mb_cache_entry_insert()
4385 + * Inserts an entry that was allocated using mb_cache_entry_alloc() into
4386 + * the cache. After this, the cache entry can be looked up, but is not yet
4387 + * in the lru list as the caller still holds a handle to it. Returns 0 on
4388 + * success, or -EBUSY if a cache entry for that device + inode exists
4389 + * already (this may happen after a failed lookup, if another process has
4390 + * inserted the same cache entry in the meantime).
4392 + * @dev: device the cache entry belongs to
4393 + * @block: block number
4394 + * @keys: array of additional keys. There must be indexes_count entries
4395 + * in the array (as specified when creating the cache).
4398 +mb_cache_entry_insert(struct mb_cache_entry *ce, kdev_t dev,
4399 + unsigned long block, unsigned int keys[])
4401 + struct mb_cache *cache = ce->e_cache;
4402 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4403 + struct list_head *l;
4404 + int error = -EBUSY, n;
4406 + spin_lock(&mb_cache_spinlock);
4407 + list_for_each(l, &cache->c_block_hash[bucket]) {
4408 + struct mb_cache_entry *ce =
4409 + list_entry(l, struct mb_cache_entry, e_block_list);
4410 + if (ce->e_dev == dev && ce->e_block == block)
4413 + __mb_cache_entry_unhash(ce);
4415 + ce->e_block = block;
4416 + list_add(&ce->e_block_list, &cache->c_block_hash[bucket]);
4417 + for (n=0; n<mb_cache_indexes(cache); n++) {
4418 + ce->e_indexes[n].o_key = keys[n];
4419 + bucket = keys[n] % cache->c_bucket_count;
4420 + list_add(&ce->e_indexes[n].o_list,
4421 + &cache->c_indexes_hash[n][bucket]);
4424 + spin_unlock(&mb_cache_spinlock);
4430 + * mb_cache_entry_release()
4432 + * Release a handle to a cache entry. When the last handle to a cache entry
4433 + * is released it is either freed (if it is invalid) or otherwise inserted
4434 + * in to the lru list.
4437 +mb_cache_entry_release(struct mb_cache_entry *ce)
4439 + spin_lock(&mb_cache_spinlock);
4440 + __mb_cache_entry_release_unlock(ce);
4445 + * mb_cache_entry_takeout()
4447 + * Take a cache entry out of the cache, making it invalid. The entry can later
4448 + * be re-inserted using mb_cache_entry_insert(), or released using
4449 + * mb_cache_entry_release().
4452 +mb_cache_entry_takeout(struct mb_cache_entry *ce)
4454 + spin_lock(&mb_cache_spinlock);
4455 + mb_assert(list_empty(&ce->e_lru_list));
4456 + __mb_cache_entry_unhash(ce);
4457 + spin_unlock(&mb_cache_spinlock);
4462 + * mb_cache_entry_free()
4464 + * This is equivalent to the sequence mb_cache_entry_takeout() --
4465 + * mb_cache_entry_release().
4468 +mb_cache_entry_free(struct mb_cache_entry *ce)
4470 + spin_lock(&mb_cache_spinlock);
4471 + mb_assert(list_empty(&ce->e_lru_list));
4472 + __mb_cache_entry_unhash(ce);
4473 + __mb_cache_entry_release_unlock(ce);
4478 + * mb_cache_entry_dup()
4480 + * Duplicate a handle to a cache entry (does not duplicate the cache entry
4481 + * itself). After the call, both the old and the new handle must be released.
4483 +struct mb_cache_entry *
4484 +mb_cache_entry_dup(struct mb_cache_entry *ce)
4486 + atomic_inc(&ce->e_used);
4492 + * mb_cache_entry_get()
4494 + * Get a cache entry by device / block number. (There can only be one entry
4495 + * in the cache per device and block.) Returns NULL if no such cache entry
4498 +struct mb_cache_entry *
4499 +mb_cache_entry_get(struct mb_cache *cache, kdev_t dev, unsigned long block)
4501 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4502 + struct list_head *l;
4503 + struct mb_cache_entry *ce;
4505 + spin_lock(&mb_cache_spinlock);
4506 + list_for_each(l, &cache->c_block_hash[bucket]) {
4507 + ce = list_entry(l, struct mb_cache_entry, e_block_list);
4508 + if (ce->e_dev == dev && ce->e_block == block) {
4509 + if (!list_empty(&ce->e_lru_list))
4510 + list_del_init(&ce->e_lru_list);
4511 + atomic_inc(&ce->e_used);
4518 + spin_unlock(&mb_cache_spinlock);
4522 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
4524 +static struct mb_cache_entry *
4525 +__mb_cache_entry_find(struct list_head *l, struct list_head *head,
4526 + int index, kdev_t dev, unsigned int key)
4528 + while (l != head) {
4529 + struct mb_cache_entry *ce =
4530 + list_entry(l, struct mb_cache_entry,
4531 + e_indexes[index].o_list);
4532 + if (ce->e_dev == dev && ce->e_indexes[index].o_key == key) {
4533 + if (!list_empty(&ce->e_lru_list))
4534 + list_del_init(&ce->e_lru_list);
4535 + atomic_inc(&ce->e_used);
4545 + * mb_cache_entry_find_first()
4547 + * Find the first cache entry on a given device with a certain key in
4548 + * an additional index. Additonal matches can be found with
4549 + * mb_cache_entry_find_next(). Returns NULL if no match was found.
4551 + * @cache: the cache to search
4552 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4553 + * @dev: the device the cache entry should belong to
4554 + * @key: the key in the index
4556 +struct mb_cache_entry *
4557 +mb_cache_entry_find_first(struct mb_cache *cache, int index, kdev_t dev,
4560 + unsigned int bucket = key % cache->c_bucket_count;
4561 + struct list_head *l;
4562 + struct mb_cache_entry *ce;
4564 + mb_assert(index < mb_cache_indexes(cache));
4565 + spin_lock(&mb_cache_spinlock);
4566 + l = cache->c_indexes_hash[index][bucket].next;
4567 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4569 + spin_unlock(&mb_cache_spinlock);
4575 + * mb_cache_entry_find_next()
4577 + * Find the next cache entry on a given device with a certain key in an
4578 + * additional index. Returns NULL if no match could be found. The previous
4579 + * entry is atomatically released, so that mb_cache_entry_find_next() can
4580 + * be called like this:
4582 + * entry = mb_cache_entry_find_first();
4585 + * entry = mb_cache_entry_find_next(entry, ...);
4588 + * @prev: The previous match
4589 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4590 + * @dev: the device the cache entry should belong to
4591 + * @key: the key in the index
4593 +struct mb_cache_entry *
4594 +mb_cache_entry_find_next(struct mb_cache_entry *prev, int index, kdev_t dev,
4597 + struct mb_cache *cache = prev->e_cache;
4598 + unsigned int bucket = key % cache->c_bucket_count;
4599 + struct list_head *l;
4600 + struct mb_cache_entry *ce;
4602 + mb_assert(index < mb_cache_indexes(cache));
4603 + spin_lock(&mb_cache_spinlock);
4604 + l = prev->e_indexes[index].o_list.next;
4605 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4607 + __mb_cache_entry_release_unlock(prev);
4611 +#endif /* !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0) */
4613 +static int __init init_mbcache(void)
4615 + register_cache(&mb_cache_definition);
4619 +static void __exit exit_mbcache(void)
4621 + unregister_cache(&mb_cache_definition);
4624 +module_init(init_mbcache)
4625 +module_exit(exit_mbcache)
4627 Index: linux-2.4.22-vanilla/include/asm-arm/unistd.h
4628 ===================================================================
4629 --- linux-2.4.22-vanilla.orig/include/asm-arm/unistd.h 2003-11-03 23:41:26.000000000 +0300
4630 +++ linux-2.4.22-vanilla/include/asm-arm/unistd.h 2003-12-02 23:55:39.000000000 +0300
4632 #define __NR_security (__NR_SYSCALL_BASE+223)
4633 #define __NR_gettid (__NR_SYSCALL_BASE+224)
4634 #define __NR_readahead (__NR_SYSCALL_BASE+225)
4635 -#if 0 /* allocated in 2.5 */
4636 #define __NR_setxattr (__NR_SYSCALL_BASE+226)
4637 #define __NR_lsetxattr (__NR_SYSCALL_BASE+227)
4638 #define __NR_fsetxattr (__NR_SYSCALL_BASE+228)
4640 #define __NR_removexattr (__NR_SYSCALL_BASE+235)
4641 #define __NR_lremovexattr (__NR_SYSCALL_BASE+236)
4642 #define __NR_fremovexattr (__NR_SYSCALL_BASE+237)
4644 #define __NR_tkill (__NR_SYSCALL_BASE+238)
4645 #if 0 /* allocated in 2.5 */
4646 #define __NR_sendfile64 (__NR_SYSCALL_BASE+239)
4647 Index: linux-2.4.22-vanilla/include/asm-ppc64/unistd.h
4648 ===================================================================
4649 --- linux-2.4.22-vanilla.orig/include/asm-ppc64/unistd.h 2003-11-03 23:41:26.000000000 +0300
4650 +++ linux-2.4.22-vanilla/include/asm-ppc64/unistd.h 2003-12-02 23:55:39.000000000 +0300
4652 #define __NR_mincore 206
4653 #define __NR_gettid 207
4654 #define __NR_tkill 208
4656 #define __NR_setxattr 209
4657 #define __NR_lsetxattr 210
4658 #define __NR_fsetxattr 211
4660 #define __NR_removexattr 218
4661 #define __NR_lremovexattr 219
4662 #define __NR_fremovexattr 220
4663 +#if 0 /* Reserved syscalls */
4664 #define __NR_futex 221
4665 #define __NR_sched_setaffinity 222
4666 #define __NR_sched_getaffinity 223
4667 Index: linux-2.4.22-vanilla/include/asm-s390/unistd.h
4668 ===================================================================
4669 --- linux-2.4.22-vanilla.orig/include/asm-s390/unistd.h 2003-11-03 23:41:26.000000000 +0300
4670 +++ linux-2.4.22-vanilla/include/asm-s390/unistd.h 2003-12-02 23:55:39.000000000 +0300
4671 @@ -213,9 +213,18 @@
4672 #define __NR_getdents64 220
4673 #define __NR_fcntl64 221
4674 #define __NR_readahead 222
4676 - * Numbers 224-235 are reserved for posix acl
4678 +#define __NR_setxattr 224
4679 +#define __NR_lsetxattr 225
4680 +#define __NR_fsetxattr 226
4681 +#define __NR_getxattr 227
4682 +#define __NR_lgetxattr 228
4683 +#define __NR_fgetxattr 229
4684 +#define __NR_listxattr 230
4685 +#define __NR_llistxattr 231
4686 +#define __NR_flistxattr 232
4687 +#define __NR_removexattr 233
4688 +#define __NR_lremovexattr 234
4689 +#define __NR_fremovexattr 235
4690 #define __NR_gettid 236
4691 #define __NR_tkill 237
4693 Index: linux-2.4.22-vanilla/include/asm-s390x/unistd.h
4694 ===================================================================
4695 --- linux-2.4.22-vanilla.orig/include/asm-s390x/unistd.h 2003-11-03 23:41:26.000000000 +0300
4696 +++ linux-2.4.22-vanilla/include/asm-s390x/unistd.h 2003-12-02 23:55:39.000000000 +0300
4697 @@ -181,9 +181,18 @@
4698 #define __NR_mincore 218
4699 #define __NR_madvise 219
4700 #define __NR_readahead 222
4702 - * Numbers 224-235 are reserved for posix acl
4704 +#define __NR_setxattr 224
4705 +#define __NR_lsetxattr 225
4706 +#define __NR_fsetxattr 226
4707 +#define __NR_getxattr 227
4708 +#define __NR_lgetxattr 228
4709 +#define __NR_fgetxattr 229
4710 +#define __NR_listxattr 230
4711 +#define __NR_llistxattr 231
4712 +#define __NR_flistxattr 232
4713 +#define __NR_removexattr 233
4714 +#define __NR_lremovexattr 234
4715 +#define __NR_fremovexattr 235
4716 #define __NR_gettid 236
4717 #define __NR_tkill 237
4719 Index: linux-2.4.22-vanilla/include/linux/cache_def.h
4720 ===================================================================
4721 --- linux-2.4.22-vanilla.orig/include/linux/cache_def.h 2003-12-02 23:55:38.000000000 +0300
4722 +++ linux-2.4.22-vanilla/include/linux/cache_def.h 2003-12-02 23:55:39.000000000 +0300
4725 + * linux/cache_def.h
4726 + * Handling of caches defined in drivers, filesystems, ...
4728 + * Copyright (C) 2002 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
4731 +struct cache_definition {
4733 + void (*shrink)(int, unsigned int);
4734 + struct list_head link;
4737 +extern void register_cache(struct cache_definition *);
4738 +extern void unregister_cache(struct cache_definition *);
4739 Index: linux-2.4.22-vanilla/include/linux/errno.h
4740 ===================================================================
4741 --- linux-2.4.22-vanilla.orig/include/linux/errno.h 2003-11-03 23:41:26.000000000 +0300
4742 +++ linux-2.4.22-vanilla/include/linux/errno.h 2003-12-02 23:55:39.000000000 +0300
4747 +/* Defined for extended attributes */
4748 +#define ENOATTR ENODATA /* No such attribute */
4749 +#define ENOTSUP EOPNOTSUPP /* Operation not supported */
4752 Index: linux-2.4.22-vanilla/include/linux/ext2_fs.h
4753 ===================================================================
4754 --- linux-2.4.22-vanilla.orig/include/linux/ext2_fs.h 2003-11-03 23:41:26.000000000 +0300
4755 +++ linux-2.4.22-vanilla/include/linux/ext2_fs.h 2003-12-02 23:55:39.000000000 +0300
4758 #define EXT2_BAD_INO 1 /* Bad blocks inode */
4759 #define EXT2_ROOT_INO 2 /* Root inode */
4760 -#define EXT2_ACL_IDX_INO 3 /* ACL inode */
4761 -#define EXT2_ACL_DATA_INO 4 /* ACL inode */
4762 #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
4763 #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
4767 # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
4769 -#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
4770 #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
4772 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
4773 @@ -121,28 +118,6 @@
4779 -struct ext2_acl_header /* Header of Access Control Lists */
4782 - __u32 aclh_file_count;
4783 - __u32 aclh_acle_count;
4784 - __u32 aclh_first_acle;
4787 -struct ext2_acl_entry /* Access Control List Entry */
4790 - __u16 acle_perms; /* Access permissions */
4791 - __u16 acle_type; /* Type of entry */
4792 - __u16 acle_tag; /* User or group identity */
4794 - __u32 acle_next; /* Pointer on next entry for the */
4795 - /* same inode or on next free entry */
4799 * Structure of a blocks group descriptor
4801 struct ext2_group_desc
4803 #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
4804 #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
4805 #define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
4806 +#define EXT2_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
4808 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
4809 #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
4813 #define EXT2_SB(sb) (&((sb)->u.ext2_sb))
4814 +#define EXT2_I(inode) (&((inode)->u.ext2_i))
4816 /* Assume that user mode programs are passing in an ext2fs superblock, not
4817 * a kernel struct super_block. This will allow us to call the feature-test
4819 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
4820 #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
4822 -#define EXT2_FEATURE_COMPAT_SUPP 0
4823 +#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
4824 #define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE
4825 #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
4826 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
4827 @@ -624,8 +601,10 @@
4830 extern struct inode_operations ext2_dir_inode_operations;
4831 +extern struct inode_operations ext2_special_inode_operations;
4834 +extern struct inode_operations ext2_symlink_inode_operations;
4835 extern struct inode_operations ext2_fast_symlink_inode_operations;
4837 #endif /* __KERNEL__ */
4838 Index: linux-2.4.22-vanilla/include/linux/ext2_xattr.h
4839 ===================================================================
4840 --- linux-2.4.22-vanilla.orig/include/linux/ext2_xattr.h 2003-12-02 23:55:38.000000000 +0300
4841 +++ linux-2.4.22-vanilla/include/linux/ext2_xattr.h 2003-12-02 23:55:39.000000000 +0300
4844 + File: linux/ext2_xattr.h
4846 + On-disk format of extended attributes for the ext2 filesystem.
4848 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
4851 +#include <linux/config.h>
4852 +#include <linux/init.h>
4853 +#include <linux/xattr.h>
4855 +/* Magic value in attribute blocks */
4856 +#define EXT2_XATTR_MAGIC 0xEA020000
4858 +/* Maximum number of references to one attribute block */
4859 +#define EXT2_XATTR_REFCOUNT_MAX 1024
4862 +#define EXT2_XATTR_INDEX_MAX 10
4863 +#define EXT2_XATTR_INDEX_USER 1
4864 +#define EXT2_XATTR_INDEX_POSIX_ACL_ACCESS 2
4865 +#define EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT 3
4867 +struct ext2_xattr_header {
4868 + __u32 h_magic; /* magic number for identification */
4869 + __u32 h_refcount; /* reference count */
4870 + __u32 h_blocks; /* number of disk blocks used */
4871 + __u32 h_hash; /* hash value of all attributes */
4872 + __u32 h_reserved[4]; /* zero right now */
4875 +struct ext2_xattr_entry {
4876 + __u8 e_name_len; /* length of name */
4877 + __u8 e_name_index; /* attribute name index */
4878 + __u16 e_value_offs; /* offset in disk block of value */
4879 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
4880 + __u32 e_value_size; /* size of attribute value */
4881 + __u32 e_hash; /* hash value of name and value */
4882 + char e_name[0]; /* attribute name */
4885 +#define EXT2_XATTR_PAD_BITS 2
4886 +#define EXT2_XATTR_PAD (1<<EXT2_XATTR_PAD_BITS)
4887 +#define EXT2_XATTR_ROUND (EXT2_XATTR_PAD-1)
4888 +#define EXT2_XATTR_LEN(name_len) \
4889 + (((name_len) + EXT2_XATTR_ROUND + \
4890 + sizeof(struct ext2_xattr_entry)) & ~EXT2_XATTR_ROUND)
4891 +#define EXT2_XATTR_NEXT(entry) \
4892 + ( (struct ext2_xattr_entry *)( \
4893 + (char *)(entry) + EXT2_XATTR_LEN((entry)->e_name_len)) )
4894 +#define EXT2_XATTR_SIZE(size) \
4895 + (((size) + EXT2_XATTR_ROUND) & ~EXT2_XATTR_ROUND)
4899 +# ifdef CONFIG_EXT2_FS_XATTR
4901 +struct ext2_xattr_handler {
4903 + size_t (*list)(char *list, struct inode *inode, const char *name,
4905 + int (*get)(struct inode *inode, const char *name, void *buffer,
4907 + int (*set)(struct inode *inode, const char *name, const void *buffer,
4908 + size_t size, int flags);
4911 +extern int ext2_xattr_register(int, struct ext2_xattr_handler *);
4912 +extern void ext2_xattr_unregister(int, struct ext2_xattr_handler *);
4914 +extern int ext2_setxattr(struct dentry *, const char *, const void *, size_t, int);
4915 +extern ssize_t ext2_getxattr(struct dentry *, const char *, void *, size_t);
4916 +extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
4917 +extern int ext2_removexattr(struct dentry *, const char *);
4919 +extern int ext2_xattr_get(struct inode *, int, const char *, void *, size_t);
4920 +extern int ext2_xattr_list(struct inode *, char *, size_t);
4921 +extern int ext2_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
4923 +extern void ext2_xattr_delete_inode(struct inode *);
4924 +extern void ext2_xattr_put_super(struct super_block *);
4926 +extern int init_ext2_xattr(void) __init;
4927 +extern void exit_ext2_xattr(void);
4929 +# else /* CONFIG_EXT2_FS_XATTR */
4930 +# define ext2_setxattr NULL
4931 +# define ext2_getxattr NULL
4932 +# define ext2_listxattr NULL
4933 +# define ext2_removexattr NULL
4936 +ext2_xattr_get(struct inode *inode, int name_index,
4937 + const char *name, void *buffer, size_t size)
4943 +ext2_xattr_list(struct inode *inode, char *buffer, size_t size)
4949 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
4950 + const void *value, size_t size, int flags)
4956 +ext2_xattr_delete_inode(struct inode *inode)
4961 +ext2_xattr_put_super(struct super_block *sb)
4966 +init_ext2_xattr(void)
4972 +exit_ext2_xattr(void)
4976 +# endif /* CONFIG_EXT2_FS_XATTR */
4978 +# ifdef CONFIG_EXT2_FS_XATTR_USER
4980 +extern int init_ext2_xattr_user(void) __init;
4981 +extern void exit_ext2_xattr_user(void);
4983 +# else /* CONFIG_EXT2_FS_XATTR_USER */
4986 +init_ext2_xattr_user(void)
4992 +exit_ext2_xattr_user(void)
4996 +# endif /* CONFIG_EXT2_FS_XATTR_USER */
4998 +#endif /* __KERNEL__ */
5000 Index: linux-2.4.22-vanilla/include/linux/ext3_fs.h
5001 ===================================================================
5002 --- linux-2.4.22-vanilla.orig/include/linux/ext3_fs.h 2003-12-02 23:55:37.000000000 +0300
5003 +++ linux-2.4.22-vanilla/include/linux/ext3_fs.h 2003-12-02 23:55:39.000000000 +0300
5006 #define EXT3_BAD_INO 1 /* Bad blocks inode */
5007 #define EXT3_ROOT_INO 2 /* Root inode */
5008 -#define EXT3_ACL_IDX_INO 3 /* ACL inode */
5009 -#define EXT3_ACL_DATA_INO 4 /* ACL inode */
5010 #define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
5011 #define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
5012 #define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
5015 # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
5017 -#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
5018 #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
5020 # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
5021 @@ -129,28 +126,6 @@
5027 -struct ext3_acl_header /* Header of Access Control Lists */
5030 - __u32 aclh_file_count;
5031 - __u32 aclh_acle_count;
5032 - __u32 aclh_first_acle;
5035 -struct ext3_acl_entry /* Access Control List Entry */
5038 - __u16 acle_perms; /* Access permissions */
5039 - __u16 acle_type; /* Type of entry */
5040 - __u16 acle_tag; /* User or group identity */
5042 - __u32 acle_next; /* Pointer on next entry for the */
5043 - /* same inode or on next free entry */
5047 * Structure of a blocks group descriptor
5049 struct ext3_group_desc
5051 #define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */
5052 #define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */
5053 #define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
5054 +#define EXT3_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
5056 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
5057 #ifndef _LINUX_EXT2_FS_H
5059 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
5060 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
5062 -#define EXT3_FEATURE_COMPAT_SUPP 0
5063 +#define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
5064 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
5065 EXT3_FEATURE_INCOMPAT_RECOVER)
5066 #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
5068 extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
5071 +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
5072 extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
5073 extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
5075 @@ -773,8 +750,10 @@
5078 extern struct inode_operations ext3_dir_inode_operations;
5079 +extern struct inode_operations ext3_special_inode_operations;
5082 +extern struct inode_operations ext3_symlink_inode_operations;
5083 extern struct inode_operations ext3_fast_symlink_inode_operations;
5086 Index: linux-2.4.22-vanilla/include/linux/ext3_jbd.h
5087 ===================================================================
5088 --- linux-2.4.22-vanilla.orig/include/linux/ext3_jbd.h 2003-12-02 23:55:37.000000000 +0300
5089 +++ linux-2.4.22-vanilla/include/linux/ext3_jbd.h 2003-12-02 23:55:39.000000000 +0300
5092 #define EXT3_SINGLEDATA_TRANS_BLOCKS 8U
5094 +/* Extended attributes may touch two data buffers, two bitmap buffers,
5095 + * and two group and summaries. */
5097 +#define EXT3_XATTR_TRANS_BLOCKS 8
5099 /* Define the minimum size for a transaction which modifies data. This
5100 * needs to take into account the fact that we may end up modifying two
5101 * quota files too (one for the group, one for the user quota). The
5102 * superblock only gets updated once, of course, so don't bother
5103 * counting that again for the quota updates. */
5105 -#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2)
5106 +#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \
5107 + EXT3_XATTR_TRANS_BLOCKS - 2)
5109 extern int ext3_writepage_trans_blocks(struct inode *inode);
5111 Index: linux-2.4.22-vanilla/include/linux/ext3_xattr.h
5112 ===================================================================
5113 --- linux-2.4.22-vanilla.orig/include/linux/ext3_xattr.h 2003-12-02 23:55:38.000000000 +0300
5114 +++ linux-2.4.22-vanilla/include/linux/ext3_xattr.h 2003-12-02 23:55:39.000000000 +0300
5117 + File: linux/ext3_xattr.h
5119 + On-disk format of extended attributes for the ext3 filesystem.
5121 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5124 +#include <linux/config.h>
5125 +#include <linux/init.h>
5126 +#include <linux/xattr.h>
5128 +/* Magic value in attribute blocks */
5129 +#define EXT3_XATTR_MAGIC 0xEA020000
5131 +/* Maximum number of references to one attribute block */
5132 +#define EXT3_XATTR_REFCOUNT_MAX 1024
5135 +#define EXT3_XATTR_INDEX_MAX 10
5136 +#define EXT3_XATTR_INDEX_USER 1
5137 +#define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS 2
5138 +#define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT 3
5140 +struct ext3_xattr_header {
5141 + __u32 h_magic; /* magic number for identification */
5142 + __u32 h_refcount; /* reference count */
5143 + __u32 h_blocks; /* number of disk blocks used */
5144 + __u32 h_hash; /* hash value of all attributes */
5145 + __u32 h_reserved[4]; /* zero right now */
5148 +struct ext3_xattr_entry {
5149 + __u8 e_name_len; /* length of name */
5150 + __u8 e_name_index; /* attribute name index */
5151 + __u16 e_value_offs; /* offset in disk block of value */
5152 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
5153 + __u32 e_value_size; /* size of attribute value */
5154 + __u32 e_hash; /* hash value of name and value */
5155 + char e_name[0]; /* attribute name */
5158 +#define EXT3_XATTR_PAD_BITS 2
5159 +#define EXT3_XATTR_PAD (1<<EXT3_XATTR_PAD_BITS)
5160 +#define EXT3_XATTR_ROUND (EXT3_XATTR_PAD-1)
5161 +#define EXT3_XATTR_LEN(name_len) \
5162 + (((name_len) + EXT3_XATTR_ROUND + \
5163 + sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
5164 +#define EXT3_XATTR_NEXT(entry) \
5165 + ( (struct ext3_xattr_entry *)( \
5166 + (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
5167 +#define EXT3_XATTR_SIZE(size) \
5168 + (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
5172 +# ifdef CONFIG_EXT3_FS_XATTR
5174 +struct ext3_xattr_handler {
5176 + size_t (*list)(char *list, struct inode *inode, const char *name,
5178 + int (*get)(struct inode *inode, const char *name, void *buffer,
5180 + int (*set)(struct inode *inode, const char *name, const void *buffer,
5181 + size_t size, int flags);
5184 +extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
5185 +extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
5187 +extern int ext3_setxattr(struct dentry *, const char *, const void *, size_t, int);
5188 +extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
5189 +extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
5190 +extern int ext3_removexattr(struct dentry *, const char *);
5192 +extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
5193 +extern int ext3_xattr_list(struct inode *, char *, size_t);
5194 +extern int ext3_xattr_set(handle_t *handle, struct inode *, int, const char *, const void *, size_t, int);
5196 +extern void ext3_xattr_delete_inode(handle_t *, struct inode *);
5197 +extern void ext3_xattr_put_super(struct super_block *);
5199 +extern int init_ext3_xattr(void) __init;
5200 +extern void exit_ext3_xattr(void);
5202 +# else /* CONFIG_EXT3_FS_XATTR */
5203 +# define ext3_setxattr NULL
5204 +# define ext3_getxattr NULL
5205 +# define ext3_listxattr NULL
5206 +# define ext3_removexattr NULL
5209 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
5210 + void *buffer, size_t size)
5216 +ext3_xattr_list(struct inode *inode, void *buffer, size_t size)
5222 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
5223 + const char *name, const void *value, size_t size, int flags)
5229 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
5234 +ext3_xattr_put_super(struct super_block *sb)
5239 +init_ext3_xattr(void)
5245 +exit_ext3_xattr(void)
5249 +# endif /* CONFIG_EXT3_FS_XATTR */
5251 +# ifdef CONFIG_EXT3_FS_XATTR_USER
5253 +extern int init_ext3_xattr_user(void) __init;
5254 +extern void exit_ext3_xattr_user(void);
5256 +# else /* CONFIG_EXT3_FS_XATTR_USER */
5259 +init_ext3_xattr_user(void)
5265 +exit_ext3_xattr_user(void)
5269 +#endif /* CONFIG_EXT3_FS_XATTR_USER */
5271 +#endif /* __KERNEL__ */
5273 Index: linux-2.4.22-vanilla/include/linux/fs.h
5274 ===================================================================
5275 --- linux-2.4.22-vanilla.orig/include/linux/fs.h 2003-12-02 23:55:35.000000000 +0300
5276 +++ linux-2.4.22-vanilla/include/linux/fs.h 2003-12-02 23:55:39.000000000 +0300
5278 int (*setattr) (struct dentry *, struct iattr *);
5279 int (*setattr_raw) (struct inode *, struct iattr *);
5280 int (*getattr) (struct dentry *, struct iattr *);
5281 - int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
5282 + int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
5283 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
5284 ssize_t (*listxattr) (struct dentry *, char *, size_t);
5285 int (*removexattr) (struct dentry *, const char *);
5286 Index: linux-2.4.22-vanilla/include/linux/mbcache.h
5287 ===================================================================
5288 --- linux-2.4.22-vanilla.orig/include/linux/mbcache.h 2003-12-02 23:55:38.000000000 +0300
5289 +++ linux-2.4.22-vanilla/include/linux/mbcache.h 2003-12-02 23:55:39.000000000 +0300
5292 + File: linux/mbcache.h
5294 + (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
5297 +/* Hardwire the number of additional indexes */
5298 +#define MB_CACHE_INDEXES_COUNT 1
5300 +struct mb_cache_entry;
5302 +struct mb_cache_op {
5303 + int (*free)(struct mb_cache_entry *, int);
5307 + struct list_head c_cache_list;
5308 + const char *c_name;
5309 + struct mb_cache_op c_op;
5310 + atomic_t c_entry_count;
5311 + int c_bucket_count;
5312 +#ifndef MB_CACHE_INDEXES_COUNT
5313 + int c_indexes_count;
5315 + kmem_cache_t *c_entry_cache;
5316 + struct list_head *c_block_hash;
5317 + struct list_head *c_indexes_hash[0];
5320 +struct mb_cache_entry_index {
5321 + struct list_head o_list;
5322 + unsigned int o_key;
5325 +struct mb_cache_entry {
5326 + struct list_head e_lru_list;
5327 + struct mb_cache *e_cache;
5330 + unsigned long e_block;
5331 + struct list_head e_block_list;
5332 + struct mb_cache_entry_index e_indexes[0];
5335 +/* Functions on caches */
5337 +struct mb_cache * mb_cache_create(const char *, struct mb_cache_op *, size_t,
5339 +void mb_cache_shrink(struct mb_cache *, kdev_t);
5340 +void mb_cache_destroy(struct mb_cache *);
5342 +/* Functions on cache entries */
5344 +struct mb_cache_entry *mb_cache_entry_alloc(struct mb_cache *);
5345 +int mb_cache_entry_insert(struct mb_cache_entry *, kdev_t, unsigned long,
5347 +void mb_cache_entry_rehash(struct mb_cache_entry *, unsigned int[]);
5348 +void mb_cache_entry_release(struct mb_cache_entry *);
5349 +void mb_cache_entry_takeout(struct mb_cache_entry *);
5350 +void mb_cache_entry_free(struct mb_cache_entry *);
5351 +struct mb_cache_entry *mb_cache_entry_dup(struct mb_cache_entry *);
5352 +struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *, kdev_t,
5354 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
5355 +struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache, int,
5356 + kdev_t, unsigned int);
5357 +struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache_entry *, int,
5358 + kdev_t, unsigned int);
5360 Index: linux-2.4.22-vanilla/kernel/ksyms.c
5361 ===================================================================
5362 --- linux-2.4.22-vanilla.orig/kernel/ksyms.c 2003-12-02 23:55:34.000000000 +0300
5363 +++ linux-2.4.22-vanilla/kernel/ksyms.c 2003-12-02 23:55:39.000000000 +0300
5366 #include <linux/config.h>
5367 #include <linux/slab.h>
5368 +#include <linux/cache_def.h>
5369 #include <linux/module.h>
5370 #include <linux/blkdev.h>
5371 #include <linux/cdrom.h>
5373 EXPORT_SYMBOL(exit_files);
5374 EXPORT_SYMBOL(exit_fs);
5375 EXPORT_SYMBOL(exit_sighand);
5376 +EXPORT_SYMBOL(copy_fs_struct);
5378 /* internal kernel memory management */
5379 EXPORT_SYMBOL(_alloc_pages);
5381 EXPORT_SYMBOL(kmem_cache_alloc);
5382 EXPORT_SYMBOL(kmem_cache_free);
5383 EXPORT_SYMBOL(kmem_cache_size);
5384 +EXPORT_SYMBOL(register_cache);
5385 +EXPORT_SYMBOL(unregister_cache);
5386 EXPORT_SYMBOL(kmalloc);
5387 EXPORT_SYMBOL(kfree);
5388 EXPORT_SYMBOL(vfree);
5389 Index: linux-2.4.22-vanilla/mm/vmscan.c
5390 ===================================================================
5391 --- linux-2.4.22-vanilla.orig/mm/vmscan.c 2003-11-03 23:41:27.000000000 +0300
5392 +++ linux-2.4.22-vanilla/mm/vmscan.c 2003-12-02 23:55:39.000000000 +0300
5394 #include <linux/kernel_stat.h>
5395 #include <linux/swap.h>
5396 #include <linux/swapctl.h>
5397 +#include <linux/cache_def.h>
5398 #include <linux/smp_lock.h>
5399 #include <linux/pagemap.h>
5400 #include <linux/init.h>
5403 #define DEF_PRIORITY (6)
5405 +static DECLARE_MUTEX(other_caches_sem);
5406 +static LIST_HEAD(cache_definitions);
5408 +void register_cache(struct cache_definition *cache)
5410 + down(&other_caches_sem);
5411 + list_add(&cache->link, &cache_definitions);
5412 + up(&other_caches_sem);
5415 +void unregister_cache(struct cache_definition *cache)
5417 + down(&other_caches_sem);
5418 + list_del(&cache->link);
5419 + up(&other_caches_sem);
5422 +static void shrink_other_caches(unsigned int priority, int gfp_mask)
5424 + struct list_head *p;
5426 + if (down_trylock(&other_caches_sem))
5429 + list_for_each_prev(p, &cache_definitions) {
5430 + struct cache_definition *cache =
5431 + list_entry(p, struct cache_definition, link);
5433 + cache->shrink(priority, gfp_mask);
5435 + up(&other_caches_sem);
5439 * The swap-out function returns 1 if it successfully
5440 * scanned all the pages it was asked to (`count').
5443 shrink_dcache_memory(priority, gfp_mask);
5444 shrink_icache_memory(priority, gfp_mask);
5445 + shrink_other_caches(priority, gfp_mask);
5447 shrink_dqcache_memory(DEF_PRIORITY, gfp_mask);
5449 Index: linux-2.4.22-vanilla/fs/ext3/ext3-exports.c
5450 ===================================================================
5451 --- linux-2.4.22-vanilla.orig/fs/ext3/ext3-exports.c 2003-12-02 23:55:38.000000000 +0300
5452 +++ linux-2.4.22-vanilla/fs/ext3/ext3-exports.c 2003-12-02 23:55:39.000000000 +0300
5454 +#include <linux/config.h>
5455 +#include <linux/module.h>
5456 +#include <linux/ext3_fs.h>
5457 +#include <linux/ext3_jbd.h>
5458 +#include <linux/ext3_xattr.h>
5460 +EXPORT_SYMBOL(ext3_force_commit);
5461 +EXPORT_SYMBOL(ext3_bread);
5462 +EXPORT_SYMBOL(ext3_xattr_register);
5463 +EXPORT_SYMBOL(ext3_xattr_unregister);
5464 +EXPORT_SYMBOL(ext3_xattr_get);
5465 +EXPORT_SYMBOL(ext3_xattr_list);
5466 +EXPORT_SYMBOL(ext3_xattr_set);