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 --- linux-2.4.20/Documentation/Configure.help~linux-2.4.20-xattr-0.8.54 2003-05-05 17:43:06.000000000 +0800
68 +++ linux-2.4.20-root/Documentation/Configure.help 2003-05-07 18:08:03.000000000 +0800
69 @@ -15242,6 +15242,39 @@ CONFIG_EXT2_FS
70 be compiled as a module, and so this could be dangerous. Most
71 everyone wants to say Y here.
73 +Ext2 extended attributes
75 + Extended attributes are name:value pairs associated with inodes by
76 + the kernel or by users (see the attr(5) manual page, or visit
77 + <http://acl.bestbits.at/> for details).
81 +Ext2 extended attribute block sharing
82 +CONFIG_EXT2_FS_XATTR_SHARING
83 + This options enables code for sharing identical extended attribute
84 + blocks among multiple inodes.
88 +Ext2 extended user attributes
89 +CONFIG_EXT2_FS_XATTR_USER
90 + This option enables extended user attributes on ext2. Processes can
91 + associate extended user attributes with inodes to store additional
92 + information such as the character encoding of files, etc. (see the
93 + attr(5) manual page, or visit <http://acl.bestbits.at/> for details).
97 +Ext2 trusted extended attributes
98 +CONFIG_EXT2_FS_XATTR_TRUSTED
99 + This option enables extended attributes on ext2 that are accessible
100 + (and visible) only to users capable of CAP_SYS_ADMIN. Usually this
101 + is only the super user. Trusted extended attributes are meant for
102 + implementing system/security services.
106 Ext3 journalling file system support (EXPERIMENTAL)
108 This is the journalling version of the Second extended file system
109 @@ -15274,6 +15307,39 @@ CONFIG_EXT3_FS
110 of your root partition (the one containing the directory /) cannot
111 be compiled as a module, and so this may be dangerous.
113 +Ext3 extended attributes
114 +CONFIG_EXT3_FS_XATTR
115 + Extended attributes are name:value pairs associated with inodes by
116 + the kernel or by users (see the attr(5) manual page, or visit
117 + <http://acl.bestbits.at/> for details).
121 +Ext3 extended attribute block sharing
122 +CONFIG_EXT3_FS_XATTR_SHARING
123 + This options enables code for sharing identical extended attribute
124 + blocks among multiple inodes.
128 +Ext3 extended user attributes
129 +CONFIG_EXT3_FS_XATTR_USER
130 + This option enables extended user attributes on ext3. Processes can
131 + associate extended user attributes with inodes to store additional
132 + information such as the character encoding of files, etc. (see the
133 + attr(5) manual page, or visit <http://acl.bestbits.at/> for details).
137 +Ext3 trusted extended attributes
138 +CONFIG_EXT3_FS_XATTR_TRUSTED
139 + This option enables extended attributes on ext3 that are accessible
140 + (and visible) only to users capable of CAP_SYS_ADMIN. Usually this
141 + is only the super user. Trusted extended attributes are meant for
142 + implementing system/security services.
146 Journal Block Device support (JBD for ext3) (EXPERIMENTAL)
148 This is a generic journalling layer for block devices. It is
149 --- linux-2.4.20/arch/alpha/defconfig~linux-2.4.20-xattr-0.8.54 2001-11-20 07:19:42.000000000 +0800
150 +++ linux-2.4.20-root/arch/alpha/defconfig 2003-05-07 18:08:03.000000000 +0800
153 # Automatically generated make config: don't edit
155 +# CONFIG_EXT3_FS_XATTR is not set
156 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
157 +# CONFIG_EXT3_FS_XATTR_USER is not set
158 +# CONFIG_EXT2_FS_XATTR is not set
159 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
160 +# CONFIG_EXT2_FS_XATTR_USER is not set
161 +# CONFIG_FS_MBCACHE is not set
163 # CONFIG_UID16 is not set
164 # CONFIG_RWSEM_GENERIC_SPINLOCK is not set
165 --- linux-2.4.20/arch/alpha/kernel/entry.S~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:42.000000000 +0800
166 +++ linux-2.4.20-root/arch/alpha/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
167 @@ -1154,6 +1154,18 @@ sys_call_table:
169 .quad sys_ni_syscall /* 380, sys_security */
172 + .quad sys_lsetxattr
173 + .quad sys_fsetxattr
174 + .quad sys_getxattr /* 385 */
175 + .quad sys_lgetxattr
176 + .quad sys_fgetxattr
177 + .quad sys_listxattr
178 + .quad sys_llistxattr
179 + .quad sys_flistxattr /* 390 */
180 + .quad sys_removexattr
181 + .quad sys_lremovexattr
182 + .quad sys_fremovexattr
184 /* Remember to update everything, kids. */
185 .ifne (. - sys_call_table) - (NR_SYSCALLS * 8)
186 --- linux-2.4.20/arch/arm/defconfig~linux-2.4.20-xattr-0.8.54 2001-05-20 08:43:05.000000000 +0800
187 +++ linux-2.4.20-root/arch/arm/defconfig 2003-05-07 18:08:03.000000000 +0800
190 # Automatically generated make config: don't edit
192 +# CONFIG_EXT3_FS_XATTR is not set
193 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
194 +# CONFIG_EXT3_FS_XATTR_USER is not set
195 +# CONFIG_EXT2_FS_XATTR is not set
196 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
197 +# CONFIG_EXT2_FS_XATTR_USER is not set
198 +# CONFIG_FS_MBCACHE is not set
200 # CONFIG_EISA is not set
201 # CONFIG_SBUS is not set
202 --- linux-2.4.20/arch/arm/kernel/calls.S~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:42.000000000 +0800
203 +++ linux-2.4.20-root/arch/arm/kernel/calls.S 2003-05-07 18:08:03.000000000 +0800
204 @@ -240,18 +240,18 @@ __syscall_start:
205 .long SYMBOL_NAME(sys_ni_syscall) /* Security */
206 .long SYMBOL_NAME(sys_gettid)
207 /* 225 */ .long SYMBOL_NAME(sys_readahead)
208 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_setxattr */
209 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_lsetxattr */
210 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_fsetxattr */
211 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_getxattr */
212 -/* 230 */ .long SYMBOL_NAME(sys_ni_syscall) /* sys_lgetxattr */
213 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_fgetxattr */
214 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_listxattr */
215 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_llistxattr */
216 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_flistxattr */
217 -/* 235 */ .long SYMBOL_NAME(sys_ni_syscall) /* sys_removexattr */
218 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_lremovexattr */
219 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_fremovexattr */
220 + .long SYMBOL_NAME(sys_setxattr)
221 + .long SYMBOL_NAME(sys_lsetxattr)
222 + .long SYMBOL_NAME(sys_fsetxattr)
223 + .long SYMBOL_NAME(sys_getxattr)
224 +/* 230 */ .long SYMBOL_NAME(sys_lgetxattr)
225 + .long SYMBOL_NAME(sys_fgetxattr)
226 + .long SYMBOL_NAME(sys_listxattr)
227 + .long SYMBOL_NAME(sys_llistxattr)
228 + .long SYMBOL_NAME(sys_flistxattr)
229 +/* 235 */ .long SYMBOL_NAME(sys_removexattr)
230 + .long SYMBOL_NAME(sys_lremovexattr)
231 + .long SYMBOL_NAME(sys_fremovexattr)
232 .long SYMBOL_NAME(sys_tkill)
234 * Please check 2.5 _before_ adding calls here,
235 --- linux-2.4.20/arch/i386/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:09.000000000 +0800
236 +++ linux-2.4.20-root/arch/i386/defconfig 2003-05-07 18:08:03.000000000 +0800
239 # Automatically generated make config: don't edit
241 +# CONFIG_EXT3_FS_XATTR is not set
242 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
243 +# CONFIG_EXT3_FS_XATTR_USER is not set
244 +# CONFIG_EXT2_FS_XATTR is not set
245 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
246 +# CONFIG_EXT2_FS_XATTR_USER is not set
247 +# CONFIG_FS_MBCACHE is not set
250 # CONFIG_SBUS is not set
251 --- linux-2.4.20/arch/ia64/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:09.000000000 +0800
252 +++ linux-2.4.20-root/arch/ia64/defconfig 2003-05-07 18:08:03.000000000 +0800
255 # Automatically generated make config: don't edit
257 +# CONFIG_EXT3_FS_XATTR is not set
258 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
259 +# CONFIG_EXT3_FS_XATTR_USER is not set
260 +# CONFIG_EXT2_FS_XATTR is not set
261 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
262 +# CONFIG_EXT2_FS_XATTR_USER is not set
263 +# CONFIG_FS_MBCACHE is not set
266 # Code maturity level options
267 --- linux-2.4.20/arch/ia64/kernel/entry.S~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:09.000000000 +0800
268 +++ linux-2.4.20-root/arch/ia64/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
269 @@ -1170,18 +1170,18 @@ sys_call_table:
271 data8 sys_getunwind // 1215
273 - data8 ia64_ni_syscall
274 - data8 ia64_ni_syscall
275 - data8 ia64_ni_syscall
276 - data8 ia64_ni_syscall // 1220
277 - data8 ia64_ni_syscall
278 - data8 ia64_ni_syscall
279 - data8 ia64_ni_syscall
280 - data8 ia64_ni_syscall
281 - data8 ia64_ni_syscall // 1225
282 - data8 ia64_ni_syscall
283 - data8 ia64_ni_syscall
284 - data8 ia64_ni_syscall
286 + data8 sys_lsetxattr
287 + data8 sys_fsetxattr
288 + data8 sys_getxattr // 1220
289 + data8 sys_lgetxattr
290 + data8 sys_fgetxattr
291 + data8 sys_listxattr
292 + data8 sys_llistxattr
293 + data8 sys_flistxattr // 1225
294 + data8 sys_removexattr
295 + data8 sys_lremovexattr
296 + data8 sys_fremovexattr
298 data8 ia64_ni_syscall // 1230
299 data8 ia64_ni_syscall
300 --- linux-2.4.20/arch/m68k/defconfig~linux-2.4.20-xattr-0.8.54 2000-06-20 03:56:08.000000000 +0800
301 +++ linux-2.4.20-root/arch/m68k/defconfig 2003-05-07 18:08:03.000000000 +0800
304 # Automatically generated make config: don't edit
306 +# CONFIG_EXT3_FS_XATTR is not set
307 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
308 +# CONFIG_EXT3_FS_XATTR_USER is not set
309 +# CONFIG_EXT2_FS_XATTR is not set
310 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
311 +# CONFIG_EXT2_FS_XATTR_USER is not set
312 +# CONFIG_FS_MBCACHE is not set
316 --- linux-2.4.20/arch/mips/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:10.000000000 +0800
317 +++ linux-2.4.20-root/arch/mips/defconfig 2003-05-07 18:08:03.000000000 +0800
320 # Automatically generated make config: don't edit
322 +# CONFIG_EXT3_FS_XATTR is not set
323 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
324 +# CONFIG_EXT3_FS_XATTR_USER is not set
325 +# CONFIG_EXT2_FS_XATTR is not set
326 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
327 +# CONFIG_EXT2_FS_XATTR_USER is not set
328 +# CONFIG_FS_MBCACHE is not set
331 # CONFIG_MIPS64 is not set
332 --- linux-2.4.20/arch/mips64/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:10.000000000 +0800
333 +++ linux-2.4.20-root/arch/mips64/defconfig 2003-05-07 18:08:03.000000000 +0800
336 # Automatically generated make config: don't edit
338 +# CONFIG_EXT3_FS_XATTR is not set
339 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
340 +# CONFIG_EXT3_FS_XATTR_USER is not set
341 +# CONFIG_EXT2_FS_XATTR is not set
342 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
343 +# CONFIG_EXT2_FS_XATTR_USER is not set
344 +# CONFIG_FS_MBCACHE is not set
346 # CONFIG_MIPS32 is not set
348 --- linux-2.4.20/arch/ppc/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
349 +++ linux-2.4.20-root/arch/ppc/defconfig 2003-05-07 18:08:03.000000000 +0800
352 # Automatically generated make config: don't edit
354 +# CONFIG_EXT3_FS_XATTR is not set
355 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
356 +# CONFIG_EXT3_FS_XATTR_USER is not set
357 +# CONFIG_EXT2_FS_XATTR is not set
358 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
359 +# CONFIG_EXT2_FS_XATTR_USER is not set
360 +# CONFIG_FS_MBCACHE is not set
361 +# CONFIG_EXT3_FS_XATTR is not set
362 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
363 +# CONFIG_EXT3_FS_XATTR_USER is not set
364 +# CONFIG_EXT2_FS_XATTR is not set
365 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
366 +# CONFIG_EXT2_FS_XATTR_USER is not set
367 +# CONFIG_FS_MBCACHE is not set
368 # CONFIG_UID16 is not set
369 # CONFIG_RWSEM_GENERIC_SPINLOCK is not set
370 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
371 --- linux-2.4.20/arch/ppc64/kernel/misc.S~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
372 +++ linux-2.4.20-root/arch/ppc64/kernel/misc.S 2003-05-07 18:08:03.000000000 +0800
373 @@ -731,6 +731,7 @@ _GLOBAL(sys_call_table32)
374 .llong .sys_gettid /* 207 */
375 #if 0 /* Reserved syscalls */
376 .llong .sys_tkill /* 208 */
379 .llong .sys_lsetxattr /* 210 */
380 .llong .sys_fsetxattr
381 @@ -743,6 +744,7 @@ _GLOBAL(sys_call_table32)
382 .llong .sys_removexattr
383 .llong .sys_lremovexattr
384 .llong .sys_fremovexattr /* 220 */
385 +#if 0 /* Reserved syscalls */
388 .llong .sys_perfmonctl /* Put this here for now ... */
389 --- linux-2.4.20/arch/s390/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
390 +++ linux-2.4.20-root/arch/s390/defconfig 2003-05-07 18:08:03.000000000 +0800
393 # Automatically generated make config: don't edit
395 +# CONFIG_EXT3_FS_XATTR is not set
396 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
397 +# CONFIG_EXT3_FS_XATTR_USER is not set
398 +# CONFIG_EXT2_FS_XATTR is not set
399 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
400 +# CONFIG_EXT2_FS_XATTR_USER is not set
401 +# CONFIG_FS_MBCACHE is not set
402 # CONFIG_ISA is not set
403 # CONFIG_EISA is not set
404 # CONFIG_MCA is not set
405 --- linux-2.4.20/arch/s390/kernel/entry.S~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
406 +++ linux-2.4.20-root/arch/s390/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
407 @@ -558,18 +558,18 @@ sys_call_table:
411 - .long sys_ni_syscall /* 224 - reserved for setxattr */
412 - .long sys_ni_syscall /* 225 - reserved for lsetxattr */
413 - .long sys_ni_syscall /* 226 - reserved for fsetxattr */
414 - .long sys_ni_syscall /* 227 - reserved for getxattr */
415 - .long sys_ni_syscall /* 228 - reserved for lgetxattr */
416 - .long sys_ni_syscall /* 229 - reserved for fgetxattr */
417 - .long sys_ni_syscall /* 230 - reserved for listxattr */
418 - .long sys_ni_syscall /* 231 - reserved for llistxattr */
419 - .long sys_ni_syscall /* 232 - reserved for flistxattr */
420 - .long sys_ni_syscall /* 233 - reserved for removexattr */
421 - .long sys_ni_syscall /* 234 - reserved for lremovexattr */
422 - .long sys_ni_syscall /* 235 - reserved for fremovexattr */
424 + .long sys_lsetxattr /* 225 */
425 + .long sys_fsetxattr
427 + .long sys_lgetxattr
428 + .long sys_fgetxattr
429 + .long sys_listxattr /* 230 */
430 + .long sys_llistxattr
431 + .long sys_flistxattr
432 + .long sys_removexattr
433 + .long sys_lremovexattr
434 + .long sys_fremovexattr /* 235 */
438 --- linux-2.4.20/arch/s390x/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
439 +++ linux-2.4.20-root/arch/s390x/defconfig 2003-05-07 18:08:03.000000000 +0800
442 # Automatically generated make config: don't edit
444 +# CONFIG_EXT3_FS_XATTR is not set
445 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
446 +# CONFIG_EXT3_FS_XATTR_USER is not set
447 +# CONFIG_EXT2_FS_XATTR is not set
448 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
449 +# CONFIG_EXT2_FS_XATTR_USER is not set
450 +# CONFIG_FS_MBCACHE is not set
451 # CONFIG_ISA is not set
452 # CONFIG_EISA is not set
453 # CONFIG_MCA is not set
454 --- linux-2.4.20/arch/s390x/kernel/entry.S~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
455 +++ linux-2.4.20-root/arch/s390x/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
456 @@ -591,18 +591,18 @@ sys_call_table:
457 .long SYSCALL(sys_ni_syscall,sys32_fcntl64_wrapper)
458 .long SYSCALL(sys_ni_syscall,sys_ni_syscall)
459 .long SYSCALL(sys_ni_syscall,sys_ni_syscall)
460 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 224 - reserved for setxattr */
461 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 225 - reserved for lsetxattr */
462 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 226 - reserved for fsetxattr */
463 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 227 - reserved for getxattr */
464 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 228 - reserved for lgetxattr */
465 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 229 - reserved for fgetxattr */
466 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 230 - reserved for listxattr */
467 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 231 - reserved for llistxattr */
468 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 232 - reserved for flistxattr */
469 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 233 - reserved for removexattr */
470 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 234 - reserved for lremovexattr */
471 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 235 - reserved for fremovexattr */
472 + .long SYSCALL(sys_setxattr,sys32_setxattr_wrapper)
473 + .long SYSCALL(sys_lsetxattr,sys32_lsetxattr_wrapper) /* 225 */
474 + .long SYSCALL(sys_fsetxattr,sys32_fsetxattr_wrapper)
475 + .long SYSCALL(sys_getxattr,sys32_getxattr_wrapper)
476 + .long SYSCALL(sys_lgetxattr,sys32_lgetxattr_wrapper)
477 + .long SYSCALL(sys_fgetxattr,sys32_fgetxattr_wrapper)
478 + .long SYSCALL(sys_listxattr,sys32_listxattr_wrapper) /* 230 */
479 + .long SYSCALL(sys_llistxattr,sys32_llistxattr_wrapper)
480 + .long SYSCALL(sys_flistxattr,sys32_flistxattr_wrapper)
481 + .long SYSCALL(sys_removexattr,sys32_removexattr_wrapper)
482 + .long SYSCALL(sys_lremovexattr,sys32_lremovexattr_wrapper)
483 + .long SYSCALL(sys_fremovexattr,sys32_fremovexattr_wrapper)/* 235 */
484 .long SYSCALL(sys_gettid,sys_gettid)
485 .long SYSCALL(sys_tkill,sys_tkill)
487 --- linux-2.4.20/arch/s390x/kernel/wrapper32.S~linux-2.4.20-xattr-0.8.54 2002-02-26 03:37:56.000000000 +0800
488 +++ linux-2.4.20-root/arch/s390x/kernel/wrapper32.S 2003-05-07 18:08:03.000000000 +0800
489 @@ -1091,3 +1091,95 @@ sys32_fstat64_wrapper:
490 llgtr %r3,%r3 # struct stat64 *
492 jg sys32_fstat64 # branch to system call
494 + .globl sys32_setxattr_wrapper
495 +sys32_setxattr_wrapper:
496 + llgtr %r2,%r2 # char *
497 + llgtr %r3,%r3 # char *
498 + llgtr %r4,%r4 # void *
499 + llgfr %r5,%r5 # size_t
503 + .globl sys32_lsetxattr_wrapper
504 +sys32_lsetxattr_wrapper:
505 + llgtr %r2,%r2 # char *
506 + llgtr %r3,%r3 # char *
507 + llgtr %r4,%r4 # void *
508 + llgfr %r5,%r5 # size_t
512 + .globl sys32_fsetxattr_wrapper
513 +sys32_fsetxattr_wrapper:
515 + llgtr %r3,%r3 # char *
516 + llgtr %r4,%r4 # void *
517 + llgfr %r5,%r5 # size_t
521 + .globl sys32_getxattr_wrapper
522 +sys32_getxattr_wrapper:
523 + llgtr %r2,%r2 # char *
524 + llgtr %r3,%r3 # char *
525 + llgtr %r4,%r4 # void *
526 + llgfr %r5,%r5 # size_t
529 + .globl sys32_lgetxattr_wrapper
530 +sys32_lgetxattr_wrapper:
531 + llgtr %r2,%r2 # char *
532 + llgtr %r3,%r3 # char *
533 + llgtr %r4,%r4 # void *
534 + llgfr %r5,%r5 # size_t
537 + .globl sys32_fgetxattr_wrapper
538 +sys32_fgetxattr_wrapper:
540 + llgtr %r3,%r3 # char *
541 + llgtr %r4,%r4 # void *
542 + llgfr %r5,%r5 # size_t
545 + .globl sys32_listxattr_wrapper
546 +sys32_listxattr_wrapper:
547 + llgtr %r2,%r2 # char *
548 + llgtr %r3,%r3 # char *
549 + llgfr %r4,%r4 # size_t
552 + .globl sys32_llistxattr_wrapper
553 +sys32_llistxattr_wrapper:
554 + llgtr %r2,%r2 # char *
555 + llgtr %r3,%r3 # char *
556 + llgfr %r4,%r4 # size_t
559 + .globl sys32_flistxattr_wrapper
560 +sys32_flistxattr_wrapper:
562 + llgtr %r3,%r3 # char *
563 + llgfr %r4,%r4 # size_t
566 + .globl sys32_removexattr_wrapper
567 +sys32_removexattr_wrapper:
568 + llgtr %r2,%r2 # char *
569 + llgtr %r3,%r3 # char *
572 + .globl sys32_lremovexattr_wrapper
573 +sys32_lremovexattr_wrapper:
574 + llgtr %r2,%r2 # char *
575 + llgtr %r3,%r3 # char *
576 + jg sys_lremovexattr
578 + .globl sys32_fremovexattr_wrapper
579 +sys32_fremovexattr_wrapper:
581 + llgtr %r3,%r3 # char *
582 + jg sys_fremovexattr
585 --- linux-2.4.20/arch/sparc/defconfig~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:43.000000000 +0800
586 +++ linux-2.4.20-root/arch/sparc/defconfig 2003-05-07 18:08:03.000000000 +0800
589 # Automatically generated make config: don't edit
591 +# CONFIG_EXT3_FS_XATTR is not set
592 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
593 +# CONFIG_EXT3_FS_XATTR_USER is not set
594 +# CONFIG_EXT2_FS_XATTR is not set
595 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
596 +# CONFIG_EXT2_FS_XATTR_USER is not set
597 +# CONFIG_FS_MBCACHE is not set
601 --- linux-2.4.20/arch/sparc/kernel/systbls.S~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:43.000000000 +0800
602 +++ linux-2.4.20-root/arch/sparc/kernel/systbls.S 2003-05-07 18:08:03.000000000 +0800
603 @@ -51,11 +51,11 @@ sys_call_table:
604 /*150*/ .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
605 /*155*/ .long sys_fcntl64, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
606 /*160*/ .long sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
607 -/*165*/ .long sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_nis_syscall
608 -/*170*/ .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getdents
609 -/*175*/ .long sys_setsid, sys_fchdir, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
610 -/*180*/ .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_sigpending, sys_query_module
611 -/*185*/ .long sys_setpgid, sys_nis_syscall, sys_tkill, sys_nis_syscall, sys_newuname
612 +/*165*/ .long sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_setxattr
613 +/*170*/ .long sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys_getdents
614 +/*175*/ .long sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr
615 +/*180*/ .long sys_flistxattr, sys_removexattr, sys_lremovexattr, sys_sigpending, sys_query_module
616 +/*185*/ .long sys_setpgid, sys_fremovexattr, sys_tkill, sys_nis_syscall, sys_newuname
617 /*190*/ .long sys_init_module, sys_personality, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
618 /*195*/ .long sys_nis_syscall, sys_nis_syscall, sys_getppid, sparc_sigaction, sys_sgetmask
619 /*200*/ .long sys_ssetmask, sys_sigsuspend, sys_newlstat, sys_uselib, old_readdir
620 --- linux-2.4.20/arch/sparc64/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:12.000000000 +0800
621 +++ linux-2.4.20-root/arch/sparc64/defconfig 2003-05-07 18:08:03.000000000 +0800
624 # Automatically generated make config: don't edit
626 +# CONFIG_EXT3_FS_XATTR is not set
627 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
628 +# CONFIG_EXT3_FS_XATTR_USER is not set
629 +# CONFIG_EXT2_FS_XATTR is not set
630 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
631 +# CONFIG_EXT2_FS_XATTR_USER is not set
632 +# CONFIG_FS_MBCACHE is not set
635 # Code maturity level options
636 --- linux-2.4.20/arch/sparc64/kernel/systbls.S~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:43.000000000 +0800
637 +++ linux-2.4.20-root/arch/sparc64/kernel/systbls.S 2003-05-07 18:08:03.000000000 +0800
638 @@ -52,11 +52,11 @@ sys_call_table32:
639 /*150*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
640 .word sys32_fcntl64, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
641 /*160*/ .word sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
642 - .word sys32_quotactl, sys_nis_syscall, sys32_mount, sys_ustat, sys_nis_syscall
643 -/*170*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getdents
644 - .word sys_setsid, sys_fchdir, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
645 -/*180*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_sigpending, sys32_query_module
646 - .word sys_setpgid, sys_nis_syscall, sys_tkill, sys_nis_syscall, sparc64_newuname
647 + .word sys32_quotactl, sys_nis_syscall, sys32_mount, sys_ustat, sys_setxattr
648 +/*170*/ .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys32_getdents
649 + .word sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr
650 +/*180*/ .word sys_flistxattr, sys_removexattr, sys_lremovexattr, sys32_sigpending, sys32_query_module
651 + .word sys_setpgid, sys_fremovexattr, sys_tkill, sys_nis_syscall, sparc64_newuname
652 /*190*/ .word sys32_init_module, sparc64_personality, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
653 .word sys_nis_syscall, sys_nis_syscall, sys_getppid, sys32_sigaction, sys_sgetmask
654 /*200*/ .word sys_ssetmask, sys_sigsuspend, sys32_newlstat, sys_uselib, old32_readdir
655 @@ -111,11 +111,11 @@ sys_call_table:
656 /*150*/ .word sys_getsockname, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
657 .word sys_nis_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
658 /*160*/ .word sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_utrap_install
659 - .word sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_nis_syscall
660 -/*170*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getdents
661 - .word sys_setsid, sys_fchdir, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
662 -/*180*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_query_module
663 - .word sys_setpgid, sys_nis_syscall, sys_tkill, sys_nis_syscall, sparc64_newuname
664 + .word sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_setxattr
665 +/*170*/ .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys_getdents
666 + .word sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr
667 +/*180*/ .word sys_flistxattr, sys_removexattr, sys_lremovexattr, sys_nis_syscall, sys_query_module
668 + .word sys_setpgid, sys_fremovexattr, sys_tkill, sys_nis_syscall, sparc64_newuname
669 /*190*/ .word sys_init_module, sparc64_personality, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
670 .word sys_nis_syscall, sys_nis_syscall, sys_getppid, sys_nis_syscall, sys_sgetmask
671 /*200*/ .word sys_ssetmask, sys_nis_syscall, sys_newlstat, sys_uselib, sys_nis_syscall
672 --- linux-2.4.20/fs/Config.in~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
673 +++ linux-2.4.20-root/fs/Config.in 2003-05-07 18:08:03.000000000 +0800
674 @@ -25,6 +25,11 @@ dep_mbool ' Debug Befs' CONFIG_BEFS_DEB
675 dep_tristate 'BFS file system support (EXPERIMENTAL)' CONFIG_BFS_FS $CONFIG_EXPERIMENTAL
677 tristate 'Ext3 journalling file system support' CONFIG_EXT3_FS
678 +dep_mbool ' Ext3 extended attributes' CONFIG_EXT3_FS_XATTR $CONFIG_EXT3_FS
679 +dep_bool ' Ext3 extended attribute block sharing' \
680 + CONFIG_EXT3_FS_XATTR_SHARING $CONFIG_EXT3_FS_XATTR
681 +dep_bool ' Ext3 extended user attributes' \
682 + CONFIG_EXT3_FS_XATTR_USER $CONFIG_EXT3_FS_XATTR
683 # CONFIG_JBD could be its own option (even modular), but until there are
684 # other users than ext3, we will simply make it be the same as CONFIG_EXT3_FS
685 # dep_tristate ' Journal Block Device support (JBD for ext3)' CONFIG_JBD $CONFIG_EXT3_FS
686 @@ -84,6 +89,11 @@ dep_mbool ' QNX4FS write support (DANGE
687 tristate 'ROM file system support' CONFIG_ROMFS_FS
689 tristate 'Second extended fs support' CONFIG_EXT2_FS
690 +dep_mbool ' Ext2 extended attributes' CONFIG_EXT2_FS_XATTR $CONFIG_EXT2_FS
691 +dep_bool ' Ext2 extended attribute block sharing' \
692 + CONFIG_EXT2_FS_XATTR_SHARING $CONFIG_EXT2_FS_XATTR
693 +dep_bool ' Ext2 extended user attributes' \
694 + CONFIG_EXT2_FS_XATTR_USER $CONFIG_EXT2_FS_XATTR
696 tristate 'System V/Xenix/V7/Coherent file system support' CONFIG_SYSV_FS
698 @@ -155,6 +165,10 @@ else
699 define_tristate CONFIG_ZISOFS_FS n
702 +# Meta block cache for Extended Attributes (ext2/ext3)
703 +#tristate 'Meta block cache' CONFIG_FS_MBCACHE
704 +define_tristate CONFIG_FS_MBCACHE y
706 mainmenu_option next_comment
707 comment 'Partition Types'
708 source fs/partitions/Config.in
709 --- linux-2.4.20/fs/Makefile~linux-2.4.20-xattr-0.8.54 2003-05-05 19:00:58.000000000 +0800
710 +++ linux-2.4.20-root/fs/Makefile 2003-05-07 18:08:03.000000000 +0800
711 @@ -79,6 +79,9 @@ obj-y += binfmt_script.o
713 obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
715 +export-objs += mbcache.o
716 +obj-$(CONFIG_FS_MBCACHE) += mbcache.o
718 # persistent filesystems
719 obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
721 --- linux-2.4.20/fs/ext2/Makefile~linux-2.4.20-xattr-0.8.54 2001-10-11 23:05:18.000000000 +0800
722 +++ linux-2.4.20-root/fs/ext2/Makefile 2003-05-07 18:08:03.000000000 +0800
723 @@ -13,4 +13,8 @@ obj-y := balloc.o bitmap.o dir.o file
724 ioctl.o namei.o super.o symlink.o
727 +export-objs += xattr.o
728 +obj-$(CONFIG_EXT2_FS_XATTR) += xattr.o
729 +obj-$(CONFIG_EXT2_FS_XATTR_USER) += xattr_user.o
731 include $(TOPDIR)/Rules.make
732 --- linux-2.4.20/fs/ext2/file.c~linux-2.4.20-xattr-0.8.54 2001-10-11 23:05:18.000000000 +0800
733 +++ linux-2.4.20-root/fs/ext2/file.c 2003-05-07 18:08:03.000000000 +0800
736 #include <linux/fs.h>
737 #include <linux/ext2_fs.h>
738 +#include <linux/ext2_xattr.h>
739 #include <linux/sched.h>
742 @@ -51,4 +52,8 @@ struct file_operations ext2_file_operati
744 struct inode_operations ext2_file_inode_operations = {
745 truncate: ext2_truncate,
746 + setxattr: ext2_setxattr,
747 + getxattr: ext2_getxattr,
748 + listxattr: ext2_listxattr,
749 + removexattr: ext2_removexattr,
751 --- linux-2.4.20/fs/ext2/ialloc.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
752 +++ linux-2.4.20-root/fs/ext2/ialloc.c 2003-05-07 18:08:03.000000000 +0800
754 #include <linux/config.h>
755 #include <linux/fs.h>
756 #include <linux/ext2_fs.h>
757 +#include <linux/ext2_xattr.h>
758 #include <linux/locks.h>
759 #include <linux/quotaops.h>
761 @@ -167,6 +168,7 @@ void ext2_free_inode (struct inode * ino
763 if (!is_bad_inode(inode)) {
764 /* Quota is already initialized in iput() */
765 + ext2_xattr_delete_inode(inode);
766 DQUOT_FREE_INODE(inode);
769 --- linux-2.4.20/fs/ext2/inode.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
770 +++ linux-2.4.20-root/fs/ext2/inode.c 2003-05-07 18:08:03.000000000 +0800
771 @@ -39,6 +39,18 @@ MODULE_LICENSE("GPL");
772 static int ext2_update_inode(struct inode * inode, int do_sync);
775 + * Test whether an inode is a fast symlink.
777 +static inline int ext2_inode_is_fast_symlink(struct inode *inode)
779 + int ea_blocks = inode->u.ext2_i.i_file_acl ?
780 + (inode->i_sb->s_blocksize >> 9) : 0;
782 + return (S_ISLNK(inode->i_mode) &&
783 + inode->i_blocks - ea_blocks == 0);
787 * Called at each iput()
789 void ext2_put_inode (struct inode * inode)
790 @@ -53,9 +65,7 @@ void ext2_delete_inode (struct inode * i
794 - if (is_bad_inode(inode) ||
795 - inode->i_ino == EXT2_ACL_IDX_INO ||
796 - inode->i_ino == EXT2_ACL_DATA_INO)
797 + if (is_bad_inode(inode))
799 inode->u.ext2_i.i_dtime = CURRENT_TIME;
800 mark_inode_dirty(inode);
801 @@ -801,6 +811,8 @@ void ext2_truncate (struct inode * inode
802 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
803 S_ISLNK(inode->i_mode)))
805 + if (ext2_inode_is_fast_symlink(inode))
807 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
810 @@ -888,8 +900,7 @@ void ext2_read_inode (struct inode * ino
811 unsigned long offset;
812 struct ext2_group_desc * gdp;
814 - if ((inode->i_ino != EXT2_ROOT_INO && inode->i_ino != EXT2_ACL_IDX_INO &&
815 - inode->i_ino != EXT2_ACL_DATA_INO &&
816 + if ((inode->i_ino != EXT2_ROOT_INO &&
817 inode->i_ino < EXT2_FIRST_INO(inode->i_sb)) ||
818 inode->i_ino > le32_to_cpu(inode->i_sb->u.ext2_sb.s_es->s_inodes_count)) {
819 ext2_error (inode->i_sb, "ext2_read_inode",
820 @@ -974,10 +985,7 @@ void ext2_read_inode (struct inode * ino
821 for (block = 0; block < EXT2_N_BLOCKS; block++)
822 inode->u.ext2_i.i_data[block] = raw_inode->i_block[block];
824 - if (inode->i_ino == EXT2_ACL_IDX_INO ||
825 - inode->i_ino == EXT2_ACL_DATA_INO)
826 - /* Nothing to do */ ;
827 - else if (S_ISREG(inode->i_mode)) {
828 + if (S_ISREG(inode->i_mode)) {
829 inode->i_op = &ext2_file_inode_operations;
830 inode->i_fop = &ext2_file_operations;
831 inode->i_mapping->a_ops = &ext2_aops;
832 @@ -986,15 +994,17 @@ void ext2_read_inode (struct inode * ino
833 inode->i_fop = &ext2_dir_operations;
834 inode->i_mapping->a_ops = &ext2_aops;
835 } else if (S_ISLNK(inode->i_mode)) {
836 - if (!inode->i_blocks)
837 + if (ext2_inode_is_fast_symlink(inode))
838 inode->i_op = &ext2_fast_symlink_inode_operations;
840 - inode->i_op = &page_symlink_inode_operations;
841 + inode->i_op = &ext2_symlink_inode_operations;
842 inode->i_mapping->a_ops = &ext2_aops;
846 + inode->i_op = &ext2_special_inode_operations;
847 init_special_inode(inode, inode->i_mode,
848 le32_to_cpu(raw_inode->i_block[0]));
851 inode->i_attr_flags = 0;
852 if (inode->u.ext2_i.i_flags & EXT2_SYNC_FL) {
853 --- linux-2.4.20/fs/ext2/namei.c~linux-2.4.20-xattr-0.8.54 2001-10-04 13:57:36.000000000 +0800
854 +++ linux-2.4.20-root/fs/ext2/namei.c 2003-05-07 18:08:03.000000000 +0800
857 #include <linux/fs.h>
858 #include <linux/ext2_fs.h>
859 +#include <linux/ext2_xattr.h>
860 #include <linux/pagemap.h>
863 @@ -136,7 +137,7 @@ static int ext2_symlink (struct inode *
865 if (l > sizeof (inode->u.ext2_i.i_data)) {
867 - inode->i_op = &page_symlink_inode_operations;
868 + inode->i_op = &ext2_symlink_inode_operations;
869 inode->i_mapping->a_ops = &ext2_aops;
870 err = block_symlink(inode, symname, l);
872 @@ -345,4 +346,15 @@ struct inode_operations ext2_dir_inode_o
876 + setxattr: ext2_setxattr,
877 + getxattr: ext2_getxattr,
878 + listxattr: ext2_listxattr,
879 + removexattr: ext2_removexattr,
882 +struct inode_operations ext2_special_inode_operations = {
883 + setxattr: ext2_setxattr,
884 + getxattr: ext2_getxattr,
885 + listxattr: ext2_listxattr,
886 + removexattr: ext2_removexattr,
888 --- linux-2.4.20/fs/ext2/super.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
889 +++ linux-2.4.20-root/fs/ext2/super.c 2003-05-07 18:08:03.000000000 +0800
891 #include <linux/string.h>
892 #include <linux/fs.h>
893 #include <linux/ext2_fs.h>
894 +#include <linux/ext2_xattr.h>
895 #include <linux/slab.h>
896 #include <linux/init.h>
897 #include <linux/locks.h>
898 @@ -125,6 +126,7 @@ void ext2_put_super (struct super_block
902 + ext2_xattr_put_super(sb);
903 if (!(sb->s_flags & MS_RDONLY)) {
904 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
906 @@ -175,6 +177,13 @@ static int parse_options (char * options
907 this_char = strtok (NULL, ",")) {
908 if ((value = strchr (this_char, '=')) != NULL)
910 +#ifdef CONFIG_EXT2_FS_XATTR_USER
911 + if (!strcmp (this_char, "user_xattr"))
912 + set_opt (*mount_options, XATTR_USER);
913 + else if (!strcmp (this_char, "nouser_xattr"))
914 + clear_opt (*mount_options, XATTR_USER);
917 if (!strcmp (this_char, "bsddf"))
918 clear_opt (*mount_options, MINIX_DF);
919 else if (!strcmp (this_char, "nouid32")) {
920 @@ -424,6 +433,9 @@ struct super_block * ext2_read_super (st
921 blocksize = BLOCK_SIZE;
923 sb->u.ext2_sb.s_mount_opt = 0;
924 +#ifdef CONFIG_EXT2_FS_XATTR_USER
925 + /* set_opt (sb->u.ext2_sb.s_mount_opt, XATTR_USER); */
927 if (!parse_options ((char *) data, &sb_block, &resuid, &resgid,
928 &sb->u.ext2_sb.s_mount_opt)) {
930 @@ -813,12 +825,27 @@ static DECLARE_FSTYPE_DEV(ext2_fs_type,
932 static int __init init_ext2_fs(void)
934 - return register_filesystem(&ext2_fs_type);
935 + int error = init_ext2_xattr();
938 + error = init_ext2_xattr_user();
941 + error = register_filesystem(&ext2_fs_type);
945 + exit_ext2_xattr_user();
951 static void __exit exit_ext2_fs(void)
953 unregister_filesystem(&ext2_fs_type);
954 + exit_ext2_xattr_user();
959 --- linux-2.4.20/fs/ext2/symlink.c~linux-2.4.20-xattr-0.8.54 2000-09-28 04:41:33.000000000 +0800
960 +++ linux-2.4.20-root/fs/ext2/symlink.c 2003-05-07 18:08:03.000000000 +0800
963 #include <linux/fs.h>
964 #include <linux/ext2_fs.h>
965 +#include <linux/ext2_xattr.h>
967 static int ext2_readlink(struct dentry *dentry, char *buffer, int buflen)
969 @@ -32,7 +33,20 @@ static int ext2_follow_link(struct dentr
970 return vfs_follow_link(nd, s);
973 +struct inode_operations ext2_symlink_inode_operations = {
974 + readlink: page_readlink,
975 + follow_link: page_follow_link,
976 + setxattr: ext2_setxattr,
977 + getxattr: ext2_getxattr,
978 + listxattr: ext2_listxattr,
979 + removexattr: ext2_removexattr,
982 struct inode_operations ext2_fast_symlink_inode_operations = {
983 readlink: ext2_readlink,
984 follow_link: ext2_follow_link,
985 + setxattr: ext2_setxattr,
986 + getxattr: ext2_getxattr,
987 + listxattr: ext2_listxattr,
988 + removexattr: ext2_removexattr,
990 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
991 +++ linux-2.4.20-root/fs/ext2/xattr.c 2003-05-07 18:08:03.000000000 +0800
994 + * linux/fs/ext2/xattr.c
996 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
998 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
999 + * Extended attributes for symlinks and special files added per
1000 + * suggestion of Luka Renko <luka.renko@hermes.si>.
1004 + * Extended attributes are stored on disk blocks allocated outside of
1005 + * any inode. The i_file_acl field is then made to point to this allocated
1006 + * block. If all extended attributes of an inode are identical, these
1007 + * inodes may share the same extended attribute block. Such situations
1008 + * are automatically detected by keeping a cache of recent attribute block
1009 + * numbers and hashes over the block's contents in memory.
1012 + * Extended attribute block layout:
1014 + * +------------------+
1017 + * | entry 2 | | growing downwards
1019 + * | four null bytes |
1022 + * | value 3 | | growing upwards
1024 + * +------------------+
1026 + * The block header is followed by multiple entry descriptors. These entry
1027 + * descriptors are variable in size, and alligned to EXT2_XATTR_PAD
1028 + * byte boundaries. The entry descriptors are sorted by attribute name,
1029 + * so that two extended attribute blocks can be compared efficiently.
1031 + * Attribute values are aligned to the end of the block, stored in
1032 + * no specific order. They are also padded to EXT2_XATTR_PAD byte
1033 + * boundaries. No additional gaps are left between them.
1035 + * Locking strategy
1036 + * ----------------
1037 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
1038 + * the xattr inode operations are called, so we are guaranteed that only one
1039 + * processes accesses extended attributes of an inode at any time.
1041 + * For writing we also grab the ext2_xattr_sem semaphore. This ensures that
1042 + * only a single process is modifying an extended attribute block, even
1043 + * if the block is shared among inodes.
1045 + * Note for porting to 2.5
1046 + * -----------------------
1047 + * The BKL will no longer be held in the xattr inode operations.
1050 +#include <linux/module.h>
1051 +#include <linux/locks.h>
1052 +#include <linux/slab.h>
1053 +#include <linux/fs.h>
1054 +#include <linux/ext2_fs.h>
1055 +#include <linux/ext2_xattr.h>
1056 +#include <linux/mbcache.h>
1057 +#include <linux/quotaops.h>
1058 +#include <asm/semaphore.h>
1059 +#include <linux/compatmac.h>
1061 +/* These symbols may be needed by a module. */
1062 +EXPORT_SYMBOL(ext2_xattr_register);
1063 +EXPORT_SYMBOL(ext2_xattr_unregister);
1064 +EXPORT_SYMBOL(ext2_xattr_get);
1065 +EXPORT_SYMBOL(ext2_xattr_list);
1066 +EXPORT_SYMBOL(ext2_xattr_set);
1068 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
1069 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
1072 +#define HDR(bh) ((struct ext2_xattr_header *)((bh)->b_data))
1073 +#define ENTRY(ptr) ((struct ext2_xattr_entry *)(ptr))
1074 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
1075 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
1077 +#ifdef EXT2_XATTR_DEBUG
1078 +# define ea_idebug(inode, f...) do { \
1079 + printk(KERN_DEBUG "inode %s:%ld: ", \
1080 + kdevname(inode->i_dev), inode->i_ino); \
1084 +# define ea_bdebug(bh, f...) do { \
1085 + printk(KERN_DEBUG "block %s:%ld: ", \
1086 + kdevname(bh->b_dev), bh->b_blocknr); \
1091 +# define ea_idebug(f...)
1092 +# define ea_bdebug(f...)
1095 +static int ext2_xattr_set2(struct inode *, struct buffer_head *,
1096 + struct ext2_xattr_header *);
1098 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1100 +static int ext2_xattr_cache_insert(struct buffer_head *);
1101 +static struct buffer_head *ext2_xattr_cache_find(struct inode *,
1102 + struct ext2_xattr_header *);
1103 +static void ext2_xattr_cache_remove(struct buffer_head *);
1104 +static void ext2_xattr_rehash(struct ext2_xattr_header *,
1105 + struct ext2_xattr_entry *);
1107 +static struct mb_cache *ext2_xattr_cache;
1110 +# define ext2_xattr_cache_insert(bh) 0
1111 +# define ext2_xattr_cache_find(inode, header) NULL
1112 +# define ext2_xattr_cache_remove(bh) while(0) {}
1113 +# define ext2_xattr_rehash(header, entry) while(0) {}
1117 + * If a file system does not share extended attributes among inodes,
1118 + * we should not need the ext2_xattr_sem semaphore. However, the
1119 + * filesystem may still contain shared blocks, so we always take
1123 +DECLARE_MUTEX(ext2_xattr_sem);
1126 +ext2_xattr_new_block(struct inode *inode, int * errp, int force)
1128 + struct super_block *sb = inode->i_sb;
1129 + int goal = le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block) +
1130 + EXT2_I(inode)->i_block_group * EXT2_BLOCKS_PER_GROUP(sb);
1132 + /* How can we enforce the allocation? */
1133 + int block = ext2_new_block(inode, goal, 0, 0, errp);
1136 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
1142 +ext2_xattr_quota_alloc(struct inode *inode, int force)
1144 + /* How can we enforce the allocation? */
1146 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
1148 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
1150 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
1158 +ext2_xattr_quota_free(struct inode *inode)
1160 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
1161 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1165 +ext2_xattr_free_block(struct inode * inode, unsigned long block)
1167 + ext2_free_blocks(inode, block, 1);
1168 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1172 +# define ext2_xattr_quota_free(inode) \
1173 + DQUOT_FREE_BLOCK(inode, 1)
1174 +# define ext2_xattr_free_block(inode, block) \
1175 + ext2_free_blocks(inode, block, 1)
1178 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
1180 +static inline struct buffer_head *
1181 +sb_bread(struct super_block *sb, int block)
1183 + return bread(sb->s_dev, block, sb->s_blocksize);
1186 +static inline struct buffer_head *
1187 +sb_getblk(struct super_block *sb, int block)
1189 + return getblk(sb->s_dev, block, sb->s_blocksize);
1194 +struct ext2_xattr_handler *ext2_xattr_handlers[EXT2_XATTR_INDEX_MAX];
1195 +rwlock_t ext2_handler_lock = RW_LOCK_UNLOCKED;
1198 +ext2_xattr_register(int name_index, struct ext2_xattr_handler *handler)
1200 + int error = -EINVAL;
1202 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1203 + write_lock(&ext2_handler_lock);
1204 + if (!ext2_xattr_handlers[name_index-1]) {
1205 + ext2_xattr_handlers[name_index-1] = handler;
1208 + write_unlock(&ext2_handler_lock);
1214 +ext2_xattr_unregister(int name_index, struct ext2_xattr_handler *handler)
1216 + if (name_index > 0 || name_index <= EXT2_XATTR_INDEX_MAX) {
1217 + write_lock(&ext2_handler_lock);
1218 + ext2_xattr_handlers[name_index-1] = NULL;
1219 + write_unlock(&ext2_handler_lock);
1223 +static inline const char *
1224 +strcmp_prefix(const char *a, const char *a_prefix)
1226 + while (*a_prefix && *a == *a_prefix) {
1230 + return *a_prefix ? NULL : a;
1234 + * Decode the extended attribute name, and translate it into
1235 + * the name_index and name suffix.
1237 +static struct ext2_xattr_handler *
1238 +ext2_xattr_resolve_name(const char **name)
1240 + struct ext2_xattr_handler *handler = NULL;
1245 + read_lock(&ext2_handler_lock);
1246 + for (i=0; i<EXT2_XATTR_INDEX_MAX; i++) {
1247 + if (ext2_xattr_handlers[i]) {
1248 + const char *n = strcmp_prefix(*name,
1249 + ext2_xattr_handlers[i]->prefix);
1251 + handler = ext2_xattr_handlers[i];
1257 + read_unlock(&ext2_handler_lock);
1261 +static inline struct ext2_xattr_handler *
1262 +ext2_xattr_handler(int name_index)
1264 + struct ext2_xattr_handler *handler = NULL;
1265 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1266 + read_lock(&ext2_handler_lock);
1267 + handler = ext2_xattr_handlers[name_index-1];
1268 + read_unlock(&ext2_handler_lock);
1274 + * Inode operation getxattr()
1276 + * dentry->d_inode->i_sem down
1277 + * BKL held [before 2.5.x]
1280 +ext2_getxattr(struct dentry *dentry, const char *name,
1281 + void *buffer, size_t size)
1283 + struct ext2_xattr_handler *handler;
1284 + struct inode *inode = dentry->d_inode;
1286 + handler = ext2_xattr_resolve_name(&name);
1289 + return handler->get(inode, name, buffer, size);
1293 + * Inode operation listxattr()
1295 + * dentry->d_inode->i_sem down
1296 + * BKL held [before 2.5.x]
1299 +ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
1301 + return ext2_xattr_list(dentry->d_inode, buffer, size);
1305 + * Inode operation setxattr()
1307 + * dentry->d_inode->i_sem down
1308 + * BKL held [before 2.5.x]
1311 +ext2_setxattr(struct dentry *dentry, const char *name,
1312 + const void *value, size_t size, int flags)
1314 + struct ext2_xattr_handler *handler;
1315 + struct inode *inode = dentry->d_inode;
1318 + value = ""; /* empty EA, do not remove */
1319 + handler = ext2_xattr_resolve_name(&name);
1322 + return handler->set(inode, name, value, size, flags);
1326 + * Inode operation removexattr()
1328 + * dentry->d_inode->i_sem down
1329 + * BKL held [before 2.5.x]
1332 +ext2_removexattr(struct dentry *dentry, const char *name)
1334 + struct ext2_xattr_handler *handler;
1335 + struct inode *inode = dentry->d_inode;
1337 + handler = ext2_xattr_resolve_name(&name);
1340 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
1344 + * ext2_xattr_get()
1346 + * Copy an extended attribute into the buffer
1347 + * provided, or compute the buffer size required.
1348 + * Buffer is NULL to compute the size of the buffer required.
1350 + * Returns a negative error number on failure, or the number of bytes
1351 + * used / required on success.
1354 +ext2_xattr_get(struct inode *inode, int name_index, const char *name,
1355 + void *buffer, size_t buffer_size)
1357 + struct buffer_head *bh = NULL;
1358 + struct ext2_xattr_entry *entry;
1359 + unsigned int block, size;
1361 + int name_len, error;
1363 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
1364 + name_index, name, buffer, (long)buffer_size);
1368 + if (!EXT2_I(inode)->i_file_acl)
1370 + block = EXT2_I(inode)->i_file_acl;
1371 + ea_idebug(inode, "reading block %d", block);
1372 + bh = sb_bread(inode->i_sb, block);
1375 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1376 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1377 + end = bh->b_data + bh->b_size;
1378 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1379 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1380 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
1381 + "inode %ld: bad block %d", inode->i_ino, block);
1385 + /* find named attribute */
1386 + name_len = strlen(name);
1389 + if (name_len > 255)
1391 + entry = FIRST_ENTRY(bh);
1392 + while (!IS_LAST_ENTRY(entry)) {
1393 + struct ext2_xattr_entry *next =
1394 + EXT2_XATTR_NEXT(entry);
1395 + if ((char *)next >= end)
1397 + if (name_index == entry->e_name_index &&
1398 + name_len == entry->e_name_len &&
1399 + memcmp(name, entry->e_name, name_len) == 0)
1403 + /* Check the remaining name entries */
1404 + while (!IS_LAST_ENTRY(entry)) {
1405 + struct ext2_xattr_entry *next =
1406 + EXT2_XATTR_NEXT(entry);
1407 + if ((char *)next >= end)
1411 + if (ext2_xattr_cache_insert(bh))
1412 + ea_idebug(inode, "cache insert failed");
1416 + /* check the buffer size */
1417 + if (entry->e_value_block != 0)
1419 + size = le32_to_cpu(entry->e_value_size);
1420 + if (size > inode->i_sb->s_blocksize ||
1421 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
1424 + if (ext2_xattr_cache_insert(bh))
1425 + ea_idebug(inode, "cache insert failed");
1428 + if (size > buffer_size)
1430 + /* return value of attribute */
1431 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
1443 + * ext2_xattr_list()
1445 + * Copy a list of attribute names into the buffer
1446 + * provided, or compute the buffer size required.
1447 + * Buffer is NULL to compute the size of the buffer required.
1449 + * Returns a negative error number on failure, or the number of bytes
1450 + * used / required on success.
1453 +ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
1455 + struct buffer_head *bh = NULL;
1456 + struct ext2_xattr_entry *entry;
1457 + unsigned int block, size = 0;
1461 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
1462 + buffer, (long)buffer_size);
1464 + if (!EXT2_I(inode)->i_file_acl)
1466 + block = EXT2_I(inode)->i_file_acl;
1467 + ea_idebug(inode, "reading block %d", block);
1468 + bh = sb_bread(inode->i_sb, block);
1471 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1472 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1473 + end = bh->b_data + bh->b_size;
1474 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1475 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1476 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
1477 + "inode %ld: bad block %d", inode->i_ino, block);
1481 + /* compute the size required for the list of attribute names */
1482 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1483 + entry = EXT2_XATTR_NEXT(entry)) {
1484 + struct ext2_xattr_handler *handler;
1485 + struct ext2_xattr_entry *next =
1486 + EXT2_XATTR_NEXT(entry);
1487 + if ((char *)next >= end)
1490 + handler = ext2_xattr_handler(entry->e_name_index);
1492 + size += handler->list(NULL, inode, entry->e_name,
1493 + entry->e_name_len);
1496 + if (ext2_xattr_cache_insert(bh))
1497 + ea_idebug(inode, "cache insert failed");
1503 + if (size > buffer_size)
1507 + /* list the attribute names */
1509 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1510 + entry = EXT2_XATTR_NEXT(entry)) {
1511 + struct ext2_xattr_handler *handler;
1513 + handler = ext2_xattr_handler(entry->e_name_index);
1515 + buf += handler->list(buf, inode, entry->e_name,
1516 + entry->e_name_len);
1527 + * If the EXT2_FEATURE_COMPAT_EXT_ATTR feature of this file system is
1528 + * not set, set it.
1530 +static void ext2_xattr_update_super_block(struct super_block *sb)
1532 + if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
1536 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
1537 + EXT2_SB(sb)->s_feature_compat |= EXT2_FEATURE_COMPAT_EXT_ATTR;
1539 + EXT2_SB(sb)->s_es->s_feature_compat |=
1540 + cpu_to_le32(EXT2_FEATURE_COMPAT_EXT_ATTR);
1542 + mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
1547 + * ext2_xattr_set()
1549 + * Create, replace or remove an extended attribute for this inode. Buffer
1550 + * is NULL to remove an existing extended attribute, and non-NULL to
1551 + * either replace an existing extended attribute, or create a new extended
1552 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
1553 + * specify that an extended attribute must exist and must not exist
1554 + * previous to the call, respectively.
1556 + * Returns 0, or a negative error number on failure.
1559 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
1560 + const void *value, size_t value_len, int flags)
1562 + struct super_block *sb = inode->i_sb;
1563 + struct buffer_head *bh = NULL;
1564 + struct ext2_xattr_header *header = NULL;
1565 + struct ext2_xattr_entry *here, *last;
1566 + unsigned int name_len;
1567 + int block = EXT2_I(inode)->i_file_acl;
1568 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
1572 + * header -- Points either into bh, or to a temporarily
1573 + * allocated buffer.
1574 + * here -- The named entry found, or the place for inserting, within
1575 + * the block pointed to by header.
1576 + * last -- Points right after the last named entry within the block
1577 + * pointed to by header.
1578 + * min_offs -- The offset of the first value (values are aligned
1579 + * towards the end of the block).
1580 + * end -- Points right after the block pointed to by header.
1583 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
1584 + name_index, name, value, (long)value_len);
1586 + if (IS_RDONLY(inode))
1588 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1590 + if (value == NULL)
1594 + name_len = strlen(name);
1595 + if (name_len > 255 || value_len > sb->s_blocksize)
1597 + down(&ext2_xattr_sem);
1600 + /* The inode already has an extended attribute block. */
1602 + bh = sb_bread(sb, block);
1606 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1607 + atomic_read(&(bh->b_count)),
1608 + le32_to_cpu(HDR(bh)->h_refcount));
1610 + end = bh->b_data + bh->b_size;
1611 + if (header->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1612 + header->h_blocks != cpu_to_le32(1)) {
1613 +bad_block: ext2_error(sb, "ext2_xattr_set",
1614 + "inode %ld: bad block %d", inode->i_ino, block);
1618 + /* Find the named attribute. */
1619 + here = FIRST_ENTRY(bh);
1620 + while (!IS_LAST_ENTRY(here)) {
1621 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(here);
1622 + if ((char *)next >= end)
1624 + if (!here->e_value_block && here->e_value_size) {
1625 + int offs = le16_to_cpu(here->e_value_offs);
1626 + if (offs < min_offs)
1629 + not_found = name_index - here->e_name_index;
1631 + not_found = name_len - here->e_name_len;
1633 + not_found = memcmp(name, here->e_name,name_len);
1634 + if (not_found <= 0)
1639 + /* We still need to compute min_offs and last. */
1640 + while (!IS_LAST_ENTRY(last)) {
1641 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(last);
1642 + if ((char *)next >= end)
1644 + if (!last->e_value_block && last->e_value_size) {
1645 + int offs = le16_to_cpu(last->e_value_offs);
1646 + if (offs < min_offs)
1652 + /* Check whether we have enough space left. */
1653 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
1655 + /* We will use a new extended attribute block. */
1656 + free = sb->s_blocksize -
1657 + sizeof(struct ext2_xattr_header) - sizeof(__u32);
1658 + here = last = NULL; /* avoid gcc uninitialized warning. */
1662 + /* Request to remove a nonexistent attribute? */
1664 + if (flags & XATTR_REPLACE)
1667 + if (value == NULL)
1670 + free -= EXT2_XATTR_LEN(name_len);
1672 + /* Request to create an existing attribute? */
1674 + if (flags & XATTR_CREATE)
1676 + if (!here->e_value_block && here->e_value_size) {
1677 + unsigned int size = le32_to_cpu(here->e_value_size);
1679 + if (le16_to_cpu(here->e_value_offs) + size >
1680 + sb->s_blocksize || size > sb->s_blocksize)
1682 + free += EXT2_XATTR_SIZE(size);
1685 + free -= EXT2_XATTR_SIZE(value_len);
1690 + /* Here we know that we can set the new attribute. */
1693 + if (header->h_refcount == cpu_to_le32(1)) {
1694 + ea_bdebug(bh, "modifying in-place");
1695 + ext2_xattr_cache_remove(bh);
1699 + ea_bdebug(bh, "cloning");
1700 + header = kmalloc(bh->b_size, GFP_KERNEL);
1702 + if (header == NULL)
1704 + memcpy(header, HDR(bh), bh->b_size);
1705 + header->h_refcount = cpu_to_le32(1);
1706 + offset = (char *)header - bh->b_data;
1707 + here = ENTRY((char *)here + offset);
1708 + last = ENTRY((char *)last + offset);
1711 + /* Allocate a buffer where we construct the new block. */
1712 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
1714 + if (header == NULL)
1716 + memset(header, 0, sb->s_blocksize);
1717 + end = (char *)header + sb->s_blocksize;
1718 + header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC);
1719 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
1720 + last = here = ENTRY(header+1);
1724 + /* Insert the new name. */
1725 + int size = EXT2_XATTR_LEN(name_len);
1726 + int rest = (char *)last - (char *)here;
1727 + memmove((char *)here + size, here, rest);
1728 + memset(here, 0, size);
1729 + here->e_name_index = name_index;
1730 + here->e_name_len = name_len;
1731 + memcpy(here->e_name, name, name_len);
1733 + /* Remove the old value. */
1734 + if (!here->e_value_block && here->e_value_size) {
1735 + char *first_val = (char *)header + min_offs;
1736 + int offs = le16_to_cpu(here->e_value_offs);
1737 + char *val = (char *)header + offs;
1738 + size_t size = EXT2_XATTR_SIZE(
1739 + le32_to_cpu(here->e_value_size));
1740 + memmove(first_val + size, first_val, val - first_val);
1741 + memset(first_val, 0, size);
1742 + here->e_value_offs = 0;
1745 + /* Adjust all value offsets. */
1746 + last = ENTRY(header+1);
1747 + while (!IS_LAST_ENTRY(last)) {
1748 + int o = le16_to_cpu(last->e_value_offs);
1749 + if (!last->e_value_block && o < offs)
1750 + last->e_value_offs =
1751 + cpu_to_le16(o + size);
1752 + last = EXT2_XATTR_NEXT(last);
1755 + if (value == NULL) {
1756 + /* Remove this attribute. */
1757 + if (EXT2_XATTR_NEXT(ENTRY(header+1)) == last) {
1758 + /* This block is now empty. */
1759 + error = ext2_xattr_set2(inode, bh, NULL);
1762 + /* Remove the old name. */
1763 + int size = EXT2_XATTR_LEN(name_len);
1764 + last = ENTRY((char *)last - size);
1765 + memmove(here, (char*)here + size,
1766 + (char*)last - (char*)here);
1767 + memset(last, 0, size);
1772 + if (value != NULL) {
1773 + /* Insert the new value. */
1774 + here->e_value_size = cpu_to_le32(value_len);
1776 + size_t size = EXT2_XATTR_SIZE(value_len);
1777 + char *val = (char *)header + min_offs - size;
1778 + here->e_value_offs =
1779 + cpu_to_le16((char *)val - (char *)header);
1780 + memset(val + size - EXT2_XATTR_PAD, 0,
1781 + EXT2_XATTR_PAD); /* Clear the pad bytes. */
1782 + memcpy(val, value, value_len);
1785 + ext2_xattr_rehash(header, here);
1787 + error = ext2_xattr_set2(inode, bh, header);
1791 + if (!(bh && header == HDR(bh)))
1793 + up(&ext2_xattr_sem);
1799 + * Second half of ext2_xattr_set(): Update the file system.
1802 +ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
1803 + struct ext2_xattr_header *header)
1805 + struct super_block *sb = inode->i_sb;
1806 + struct buffer_head *new_bh = NULL;
1810 + new_bh = ext2_xattr_cache_find(inode, header);
1813 + * We found an identical block in the cache.
1814 + * The old block will be released after updating
1817 + ea_bdebug(old_bh, "reusing block %ld",
1818 + new_bh->b_blocknr);
1821 + if (ext2_xattr_quota_alloc(inode, 1))
1824 + HDR(new_bh)->h_refcount = cpu_to_le32(
1825 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
1826 + ea_bdebug(new_bh, "refcount now=%d",
1827 + le32_to_cpu(HDR(new_bh)->h_refcount));
1828 + } else if (old_bh && header == HDR(old_bh)) {
1829 + /* Keep this block. */
1831 + ext2_xattr_cache_insert(new_bh);
1833 + /* We need to allocate a new block */
1834 + int force = EXT2_I(inode)->i_file_acl != 0;
1835 + int block = ext2_xattr_new_block(inode, &error, force);
1838 + ea_idebug(inode, "creating block %d", block);
1840 + new_bh = sb_getblk(sb, block);
1842 + ext2_xattr_free_block(inode, block);
1846 + lock_buffer(new_bh);
1847 + memcpy(new_bh->b_data, header, new_bh->b_size);
1848 + mark_buffer_uptodate(new_bh, 1);
1849 + unlock_buffer(new_bh);
1850 + ext2_xattr_cache_insert(new_bh);
1852 + ext2_xattr_update_super_block(sb);
1854 + mark_buffer_dirty(new_bh);
1855 + if (IS_SYNC(inode)) {
1856 + ll_rw_block(WRITE, 1, &new_bh);
1857 + wait_on_buffer(new_bh);
1859 + if (buffer_req(new_bh) && !buffer_uptodate(new_bh))
1864 + /* Update the inode. */
1865 + EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
1866 + inode->i_ctime = CURRENT_TIME;
1867 + if (IS_SYNC(inode)) {
1868 + error = ext2_sync_inode (inode);
1872 + mark_inode_dirty(inode);
1875 + if (old_bh && old_bh != new_bh) {
1877 + * If there was an old block, and we are not still using it,
1878 + * we now release the old block.
1880 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
1882 + if (refcount == 1) {
1883 + /* Free the old block. */
1884 + ea_bdebug(old_bh, "freeing");
1885 + ext2_xattr_free_block(inode, old_bh->b_blocknr);
1886 + mark_buffer_clean(old_bh);
1888 + /* Decrement the refcount only. */
1890 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
1891 + ext2_xattr_quota_free(inode);
1892 + mark_buffer_dirty(old_bh);
1893 + ea_bdebug(old_bh, "refcount now=%d", refcount);
1898 + if (old_bh != new_bh)
1905 + * ext2_xattr_delete_inode()
1907 + * Free extended attribute resources associated with this inode. This
1908 + * is called immediately before an inode is freed.
1911 +ext2_xattr_delete_inode(struct inode *inode)
1913 + struct buffer_head *bh;
1914 + unsigned int block = EXT2_I(inode)->i_file_acl;
1918 + down(&ext2_xattr_sem);
1920 + bh = sb_bread(inode->i_sb, block);
1922 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1923 + "inode %ld: block %d read error", inode->i_ino, block);
1926 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
1927 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1928 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1929 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1930 + "inode %ld: bad block %d", inode->i_ino, block);
1933 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
1934 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
1935 + ext2_xattr_cache_remove(bh);
1936 + ext2_xattr_free_block(inode, block);
1940 + HDR(bh)->h_refcount = cpu_to_le32(
1941 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
1942 + mark_buffer_dirty(bh);
1943 + if (IS_SYNC(inode)) {
1944 + ll_rw_block(WRITE, 1, &bh);
1945 + wait_on_buffer(bh);
1947 + ext2_xattr_quota_free(inode);
1949 + EXT2_I(inode)->i_file_acl = 0;
1953 + up(&ext2_xattr_sem);
1957 + * ext2_xattr_put_super()
1959 + * This is called when a file system is unmounted.
1962 +ext2_xattr_put_super(struct super_block *sb)
1964 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1965 + mb_cache_shrink(ext2_xattr_cache, sb->s_dev);
1969 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1972 + * ext2_xattr_cache_insert()
1974 + * Create a new entry in the extended attribute cache, and insert
1975 + * it unless such an entry is already in the cache.
1977 + * Returns 0, or a negative error number on failure.
1980 +ext2_xattr_cache_insert(struct buffer_head *bh)
1982 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
1983 + struct mb_cache_entry *ce;
1986 + ce = mb_cache_entry_alloc(ext2_xattr_cache);
1989 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
1991 + mb_cache_entry_free(ce);
1992 + if (error == -EBUSY) {
1993 + ea_bdebug(bh, "already in cache (%d cache entries)",
1994 + atomic_read(&ext2_xattr_cache->c_entry_count));
1998 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
1999 + atomic_read(&ext2_xattr_cache->c_entry_count));
2000 + mb_cache_entry_release(ce);
2006 + * ext2_xattr_cmp()
2008 + * Compare two extended attribute blocks for equality.
2010 + * Returns 0 if the blocks are equal, 1 if they differ, and
2011 + * a negative error number on errors.
2014 +ext2_xattr_cmp(struct ext2_xattr_header *header1,
2015 + struct ext2_xattr_header *header2)
2017 + struct ext2_xattr_entry *entry1, *entry2;
2019 + entry1 = ENTRY(header1+1);
2020 + entry2 = ENTRY(header2+1);
2021 + while (!IS_LAST_ENTRY(entry1)) {
2022 + if (IS_LAST_ENTRY(entry2))
2024 + if (entry1->e_hash != entry2->e_hash ||
2025 + entry1->e_name_len != entry2->e_name_len ||
2026 + entry1->e_value_size != entry2->e_value_size ||
2027 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
2029 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
2031 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
2032 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
2033 + le32_to_cpu(entry1->e_value_size)))
2036 + entry1 = EXT2_XATTR_NEXT(entry1);
2037 + entry2 = EXT2_XATTR_NEXT(entry2);
2039 + if (!IS_LAST_ENTRY(entry2))
2045 + * ext2_xattr_cache_find()
2047 + * Find an identical extended attribute block.
2049 + * Returns a pointer to the block found, or NULL if such a block was
2050 + * not found or an error occurred.
2052 +static struct buffer_head *
2053 +ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
2055 + __u32 hash = le32_to_cpu(header->h_hash);
2056 + struct mb_cache_entry *ce;
2058 + if (!header->h_hash)
2059 + return NULL; /* never share */
2060 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
2061 + ce = mb_cache_entry_find_first(ext2_xattr_cache, 0, inode->i_dev, hash);
2063 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
2066 + ext2_error(inode->i_sb, "ext2_xattr_cache_find",
2067 + "inode %ld: block %ld read error",
2068 + inode->i_ino, ce->e_block);
2069 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
2070 + EXT2_XATTR_REFCOUNT_MAX) {
2071 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
2072 + le32_to_cpu(HDR(bh)->h_refcount),
2073 + EXT2_XATTR_REFCOUNT_MAX);
2074 + } else if (!ext2_xattr_cmp(header, HDR(bh))) {
2075 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
2076 + mb_cache_entry_release(ce);
2080 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
2086 + * ext2_xattr_cache_remove()
2088 + * Remove the cache entry of a block from the cache. Called when a
2089 + * block becomes invalid.
2092 +ext2_xattr_cache_remove(struct buffer_head *bh)
2094 + struct mb_cache_entry *ce;
2096 + ce = mb_cache_entry_get(ext2_xattr_cache, bh->b_dev, bh->b_blocknr);
2098 + ea_bdebug(bh, "removing (%d cache entries remaining)",
2099 + atomic_read(&ext2_xattr_cache->c_entry_count)-1);
2100 + mb_cache_entry_free(ce);
2102 + ea_bdebug(bh, "no cache entry");
2105 +#define NAME_HASH_SHIFT 5
2106 +#define VALUE_HASH_SHIFT 16
2109 + * ext2_xattr_hash_entry()
2111 + * Compute the hash of an extended attribute.
2113 +static inline void ext2_xattr_hash_entry(struct ext2_xattr_header *header,
2114 + struct ext2_xattr_entry *entry)
2117 + char *name = entry->e_name;
2120 + for (n=0; n < entry->e_name_len; n++) {
2121 + hash = (hash << NAME_HASH_SHIFT) ^
2122 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
2126 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
2127 + __u32 *value = (__u32 *)((char *)header +
2128 + le16_to_cpu(entry->e_value_offs));
2129 + for (n = (le32_to_cpu(entry->e_value_size) +
2130 + EXT2_XATTR_ROUND) >> EXT2_XATTR_PAD_BITS; n; n--) {
2131 + hash = (hash << VALUE_HASH_SHIFT) ^
2132 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
2133 + le32_to_cpu(*value++);
2136 + entry->e_hash = cpu_to_le32(hash);
2139 +#undef NAME_HASH_SHIFT
2140 +#undef VALUE_HASH_SHIFT
2142 +#define BLOCK_HASH_SHIFT 16
2145 + * ext2_xattr_rehash()
2147 + * Re-compute the extended attribute hash value after an entry has changed.
2149 +static void ext2_xattr_rehash(struct ext2_xattr_header *header,
2150 + struct ext2_xattr_entry *entry)
2152 + struct ext2_xattr_entry *here;
2155 + ext2_xattr_hash_entry(header, entry);
2156 + here = ENTRY(header+1);
2157 + while (!IS_LAST_ENTRY(here)) {
2158 + if (!here->e_hash) {
2159 + /* Block is not shared if an entry's hash value == 0 */
2163 + hash = (hash << BLOCK_HASH_SHIFT) ^
2164 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
2165 + le32_to_cpu(here->e_hash);
2166 + here = EXT2_XATTR_NEXT(here);
2168 + header->h_hash = cpu_to_le32(hash);
2171 +#undef BLOCK_HASH_SHIFT
2174 +init_ext2_xattr(void)
2176 + ext2_xattr_cache = mb_cache_create("ext2_xattr", NULL,
2177 + sizeof(struct mb_cache_entry) +
2178 + sizeof(struct mb_cache_entry_index), 1, 61);
2179 + if (!ext2_xattr_cache)
2186 +exit_ext2_xattr(void)
2188 + mb_cache_destroy(ext2_xattr_cache);
2191 +#else /* CONFIG_EXT2_FS_XATTR_SHARING */
2194 +init_ext2_xattr(void)
2200 +exit_ext2_xattr(void)
2204 +#endif /* CONFIG_EXT2_FS_XATTR_SHARING */
2205 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
2206 +++ linux-2.4.20-root/fs/ext2/xattr_user.c 2003-05-07 18:08:03.000000000 +0800
2209 + * linux/fs/ext2/xattr_user.c
2210 + * Handler for extended user attributes.
2212 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2215 +#include <linux/module.h>
2216 +#include <linux/string.h>
2217 +#include <linux/fs.h>
2218 +#include <linux/ext2_fs.h>
2219 +#include <linux/ext2_xattr.h>
2221 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2222 +# include <linux/ext2_acl.h>
2225 +#define XATTR_USER_PREFIX "user."
2228 +ext2_xattr_user_list(char *list, struct inode *inode,
2229 + const char *name, int name_len)
2231 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
2233 + if (!test_opt(inode->i_sb, XATTR_USER))
2237 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
2238 + memcpy(list+prefix_len, name, name_len);
2239 + list[prefix_len + name_len] = '\0';
2241 + return prefix_len + name_len + 1;
2245 +ext2_xattr_user_get(struct inode *inode, const char *name,
2246 + void *buffer, size_t size)
2250 + if (strcmp(name, "") == 0)
2252 + if (!test_opt(inode->i_sb, XATTR_USER))
2254 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2255 + error = ext2_permission_locked(inode, MAY_READ);
2257 + error = permission(inode, MAY_READ);
2262 + return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name,
2267 +ext2_xattr_user_set(struct inode *inode, const char *name,
2268 + const void *value, size_t size, int flags)
2272 + if (strcmp(name, "") == 0)
2274 + if (!test_opt(inode->i_sb, XATTR_USER))
2276 + if ( !S_ISREG(inode->i_mode) &&
2277 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
2279 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2280 + error = ext2_permission_locked(inode, MAY_WRITE);
2282 + error = permission(inode, MAY_WRITE);
2287 + return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name,
2288 + value, size, flags);
2291 +struct ext2_xattr_handler ext2_xattr_user_handler = {
2292 + prefix: XATTR_USER_PREFIX,
2293 + list: ext2_xattr_user_list,
2294 + get: ext2_xattr_user_get,
2295 + set: ext2_xattr_user_set,
2299 +init_ext2_xattr_user(void)
2301 + return ext2_xattr_register(EXT2_XATTR_INDEX_USER,
2302 + &ext2_xattr_user_handler);
2306 +exit_ext2_xattr_user(void)
2308 + ext2_xattr_unregister(EXT2_XATTR_INDEX_USER,
2309 + &ext2_xattr_user_handler);
2311 --- linux-2.4.20/fs/ext3/Makefile~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2312 +++ linux-2.4.20-root/fs/ext3/Makefile 2003-05-07 18:10:33.000000000 +0800
2315 -# Makefile for the linux ext2-filesystem routines.
2316 +# Makefile for the linux ext3-filesystem routines.
2318 # Note! Dependencies are done automagically by 'make dep', which also
2319 # removes any old dependencies. DON'T put your own dependencies here
2324 -export-objs := super.o inode.o
2325 +export-objs := ext3-exports.o
2327 obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
2328 - ioctl.o namei.o super.o symlink.o hash.o
2329 + ioctl.o namei.o super.o symlink.o hash.o ext3-exports.o
2330 obj-m := $(O_TARGET)
2332 +export-objs += xattr.o
2333 +obj-$(CONFIG_EXT3_FS_XATTR) += xattr.o
2334 +obj-$(CONFIG_EXT3_FS_XATTR_USER) += xattr_user.o
2336 include $(TOPDIR)/Rules.make
2337 --- linux-2.4.20/fs/ext3/file.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2338 +++ linux-2.4.20-root/fs/ext3/file.c 2003-05-07 18:08:03.000000000 +0800
2340 #include <linux/locks.h>
2341 #include <linux/jbd.h>
2342 #include <linux/ext3_fs.h>
2343 +#include <linux/ext3_xattr.h>
2344 #include <linux/ext3_jbd.h>
2345 #include <linux/smp_lock.h>
2347 @@ -126,5 +127,9 @@ struct file_operations ext3_file_operati
2348 struct inode_operations ext3_file_inode_operations = {
2349 truncate: ext3_truncate, /* BKL held */
2350 setattr: ext3_setattr, /* BKL held */
2351 + setxattr: ext3_setxattr, /* BKL held */
2352 + getxattr: ext3_getxattr, /* BKL held */
2353 + listxattr: ext3_listxattr, /* BKL held */
2354 + removexattr: ext3_removexattr, /* BKL held */
2357 --- linux-2.4.20/fs/ext3/ialloc.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
2358 +++ linux-2.4.20-root/fs/ext3/ialloc.c 2003-05-07 18:08:03.000000000 +0800
2360 #include <linux/jbd.h>
2361 #include <linux/ext3_fs.h>
2362 #include <linux/ext3_jbd.h>
2363 +#include <linux/ext3_xattr.h>
2364 #include <linux/stat.h>
2365 #include <linux/string.h>
2366 #include <linux/locks.h>
2367 @@ -216,6 +217,7 @@ void ext3_free_inode (handle_t *handle,
2368 * as writing the quota to disk may need the lock as well.
2371 + ext3_xattr_delete_inode(handle, inode);
2372 DQUOT_FREE_INODE(inode);
2375 --- linux-2.4.20/fs/ext3/inode.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
2376 +++ linux-2.4.20-root/fs/ext3/inode.c 2003-05-07 18:08:03.000000000 +0800
2379 #undef SEARCH_FROM_ZERO
2382 + * Test whether an inode is a fast symlink.
2384 +static inline int ext3_inode_is_fast_symlink(struct inode *inode)
2386 + int ea_blocks = inode->u.ext3_i.i_file_acl ?
2387 + (inode->i_sb->s_blocksize >> 9) : 0;
2389 + return (S_ISLNK(inode->i_mode) &&
2390 + inode->i_blocks - ea_blocks == 0);
2393 /* The ext3 forget function must perform a revoke if we are freeing data
2394 * which has been journaled. Metadata (eg. indirect blocks) must be
2395 * revoked in all cases.
2397 * still needs to be revoked.
2400 -static int ext3_forget(handle_t *handle, int is_metadata,
2401 +int ext3_forget(handle_t *handle, int is_metadata,
2402 struct inode *inode, struct buffer_head *bh,
2405 @@ -164,9 +176,7 @@ void ext3_delete_inode (struct inode * i
2409 - if (is_bad_inode(inode) ||
2410 - inode->i_ino == EXT3_ACL_IDX_INO ||
2411 - inode->i_ino == EXT3_ACL_DATA_INO)
2412 + if (is_bad_inode(inode))
2416 @@ -1855,6 +1865,8 @@ void ext3_truncate(struct inode * inode)
2417 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
2418 S_ISLNK(inode->i_mode)))
2420 + if (ext3_inode_is_fast_symlink(inode))
2422 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2425 @@ -2002,8 +2014,6 @@ int ext3_get_inode_loc (struct inode *in
2426 struct ext3_group_desc * gdp;
2428 if ((inode->i_ino != EXT3_ROOT_INO &&
2429 - inode->i_ino != EXT3_ACL_IDX_INO &&
2430 - inode->i_ino != EXT3_ACL_DATA_INO &&
2431 inode->i_ino != EXT3_JOURNAL_INO &&
2432 inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
2433 inode->i_ino > le32_to_cpu(
2434 @@ -2130,10 +2140,7 @@ void ext3_read_inode(struct inode * inod
2438 - if (inode->i_ino == EXT3_ACL_IDX_INO ||
2439 - inode->i_ino == EXT3_ACL_DATA_INO)
2440 - /* Nothing to do */ ;
2441 - else if (S_ISREG(inode->i_mode)) {
2442 + if (S_ISREG(inode->i_mode)) {
2443 inode->i_op = &ext3_file_inode_operations;
2444 inode->i_fop = &ext3_file_operations;
2445 inode->i_mapping->a_ops = &ext3_aops;
2446 @@ -2141,15 +2148,17 @@ void ext3_read_inode(struct inode * inod
2447 inode->i_op = &ext3_dir_inode_operations;
2448 inode->i_fop = &ext3_dir_operations;
2449 } else if (S_ISLNK(inode->i_mode)) {
2450 - if (!inode->i_blocks)
2451 + if (ext3_inode_is_fast_symlink(inode))
2452 inode->i_op = &ext3_fast_symlink_inode_operations;
2454 - inode->i_op = &page_symlink_inode_operations;
2455 + inode->i_op = &ext3_symlink_inode_operations;
2456 inode->i_mapping->a_ops = &ext3_aops;
2460 + inode->i_op = &ext3_special_inode_operations;
2461 init_special_inode(inode, inode->i_mode,
2462 le32_to_cpu(iloc.raw_inode->i_block[0]));
2464 /* inode->i_attr_flags = 0; unused */
2465 if (inode->u.ext3_i.i_flags & EXT3_SYNC_FL) {
2466 /* inode->i_attr_flags |= ATTR_FLAG_SYNCRONOUS; unused */
2467 --- linux-2.4.20/fs/ext3/namei.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:05.000000000 +0800
2468 +++ linux-2.4.20-root/fs/ext3/namei.c 2003-05-07 18:08:03.000000000 +0800
2470 #include <linux/sched.h>
2471 #include <linux/ext3_fs.h>
2472 #include <linux/ext3_jbd.h>
2473 +#include <linux/ext3_xattr.h>
2474 #include <linux/fcntl.h>
2475 #include <linux/stat.h>
2476 #include <linux/string.h>
2477 @@ -1611,7 +1612,7 @@ static int ext3_mkdir(struct inode * dir
2481 - inode = ext3_new_inode (handle, dir, S_IFDIR);
2482 + inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
2483 err = PTR_ERR(inode);
2486 @@ -1619,7 +1620,6 @@ static int ext3_mkdir(struct inode * dir
2487 inode->i_op = &ext3_dir_inode_operations;
2488 inode->i_fop = &ext3_dir_operations;
2489 inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
2490 - inode->i_blocks = 0;
2491 dir_block = ext3_bread (handle, inode, 0, 1, &err);
2493 inode->i_nlink--; /* is this nlink == 0? */
2494 @@ -1646,9 +1646,6 @@ static int ext3_mkdir(struct inode * dir
2495 BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
2496 ext3_journal_dirty_metadata(handle, dir_block);
2498 - inode->i_mode = S_IFDIR | mode;
2499 - if (dir->i_mode & S_ISGID)
2500 - inode->i_mode |= S_ISGID;
2501 ext3_mark_inode_dirty(handle, inode);
2502 err = ext3_add_entry (handle, dentry, inode);
2504 @@ -2017,7 +2014,7 @@ static int ext3_symlink (struct inode *
2507 if (l > sizeof (EXT3_I(inode)->i_data)) {
2508 - inode->i_op = &page_symlink_inode_operations;
2509 + inode->i_op = &ext3_symlink_inode_operations;
2510 inode->i_mapping->a_ops = &ext3_aops;
2512 * block_symlink() calls back into ext3_prepare/commit_write.
2513 @@ -2244,4 +2241,16 @@ struct inode_operations ext3_dir_inode_o
2514 rmdir: ext3_rmdir, /* BKL held */
2515 mknod: ext3_mknod, /* BKL held */
2516 rename: ext3_rename, /* BKL held */
2517 + setxattr: ext3_setxattr, /* BKL held */
2518 + getxattr: ext3_getxattr, /* BKL held */
2519 + listxattr: ext3_listxattr, /* BKL held */
2520 + removexattr: ext3_removexattr, /* BKL held */
2523 +struct inode_operations ext3_special_inode_operations = {
2524 + setxattr: ext3_setxattr, /* BKL held */
2525 + getxattr: ext3_getxattr, /* BKL held */
2526 + listxattr: ext3_listxattr, /* BKL held */
2527 + removexattr: ext3_removexattr, /* BKL held */
2530 --- linux-2.4.20/fs/ext3/super.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2531 +++ linux-2.4.20-root/fs/ext3/super.c 2003-05-07 18:08:39.000000000 +0800
2533 #include <linux/jbd.h>
2534 #include <linux/ext3_fs.h>
2535 #include <linux/ext3_jbd.h>
2536 +#include <linux/ext3_xattr.h>
2537 #include <linux/slab.h>
2538 #include <linux/init.h>
2539 #include <linux/locks.h>
2540 @@ -404,6 +405,7 @@ void ext3_put_super (struct super_block
2541 kdev_t j_dev = sbi->s_journal->j_dev;
2544 + ext3_xattr_put_super(sb);
2545 journal_destroy(sbi->s_journal);
2546 if (!(sb->s_flags & MS_RDONLY)) {
2547 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
2548 @@ -499,6 +501,7 @@ static int parse_options (char * options
2551 unsigned long *mount_options = &sbi->s_mount_opt;
2553 uid_t *resuid = &sbi->s_resuid;
2554 gid_t *resgid = &sbi->s_resgid;
2556 @@ -511,6 +514,13 @@ static int parse_options (char * options
2557 this_char = strtok (NULL, ",")) {
2558 if ((value = strchr (this_char, '=')) != NULL)
2560 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2561 + if (!strcmp (this_char, "user_xattr"))
2562 + set_opt (*mount_options, XATTR_USER);
2563 + else if (!strcmp (this_char, "nouser_xattr"))
2564 + clear_opt (*mount_options, XATTR_USER);
2567 if (!strcmp (this_char, "bsddf"))
2568 clear_opt (*mount_options, MINIX_DF);
2569 else if (!strcmp (this_char, "nouid32")) {
2570 @@ -928,6 +938,12 @@ struct super_block * ext3_read_super (st
2571 sbi->s_mount_opt = 0;
2572 sbi->s_resuid = EXT3_DEF_RESUID;
2573 sbi->s_resgid = EXT3_DEF_RESGID;
2575 + /* Default extended attribute flags */
2576 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2577 + /* set_opt(sbi->s_mount_opt, XATTR_USER); */
2580 if (!parse_options ((char *) data, &sb_block, sbi, &journal_inum, 0)) {
2583 @@ -1767,17 +1783,29 @@ static DECLARE_FSTYPE_DEV(ext3_fs_type,
2585 static int __init init_ext3_fs(void)
2587 - return register_filesystem(&ext3_fs_type);
2588 + int error = init_ext3_xattr();
2591 + error = init_ext3_xattr_user();
2594 + error = register_filesystem(&ext3_fs_type);
2598 + exit_ext3_xattr_user();
2600 + exit_ext3_xattr();
2604 static void __exit exit_ext3_fs(void)
2606 unregister_filesystem(&ext3_fs_type);
2607 + exit_ext3_xattr_user();
2608 + exit_ext3_xattr();
2611 -EXPORT_SYMBOL(ext3_force_commit);
2612 -EXPORT_SYMBOL(ext3_bread);
2614 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
2615 MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
2616 MODULE_LICENSE("GPL");
2617 --- linux-2.4.20/fs/ext3/symlink.c~linux-2.4.20-xattr-0.8.54 2001-11-10 06:25:04.000000000 +0800
2618 +++ linux-2.4.20-root/fs/ext3/symlink.c 2003-05-07 18:08:03.000000000 +0800
2620 #include <linux/fs.h>
2621 #include <linux/jbd.h>
2622 #include <linux/ext3_fs.h>
2623 +#include <linux/ext3_xattr.h>
2625 static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen)
2627 @@ -33,7 +34,20 @@ static int ext3_follow_link(struct dentr
2628 return vfs_follow_link(nd, s);
2631 +struct inode_operations ext3_symlink_inode_operations = {
2632 + readlink: page_readlink, /* BKL not held. Don't need */
2633 + follow_link: page_follow_link, /* BKL not held. Don't need */
2634 + setxattr: ext3_setxattr, /* BKL held */
2635 + getxattr: ext3_getxattr, /* BKL held */
2636 + listxattr: ext3_listxattr, /* BKL held */
2637 + removexattr: ext3_removexattr, /* BKL held */
2640 struct inode_operations ext3_fast_symlink_inode_operations = {
2641 readlink: ext3_readlink, /* BKL not held. Don't need */
2642 follow_link: ext3_follow_link, /* BKL not held. Don't need */
2643 + setxattr: ext3_setxattr, /* BKL held */
2644 + getxattr: ext3_getxattr, /* BKL held */
2645 + listxattr: ext3_listxattr, /* BKL held */
2646 + removexattr: ext3_removexattr, /* BKL held */
2648 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
2649 +++ linux-2.4.20-root/fs/ext3/xattr.c 2003-05-07 18:09:23.000000000 +0800
2652 + * linux/fs/ext3/xattr.c
2654 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2656 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
2657 + * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
2658 + * Extended attributes for symlinks and special files added per
2659 + * suggestion of Luka Renko <luka.renko@hermes.si>.
2663 + * Extended attributes are stored on disk blocks allocated outside of
2664 + * any inode. The i_file_acl field is then made to point to this allocated
2665 + * block. If all extended attributes of an inode are identical, these
2666 + * inodes may share the same extended attribute block. Such situations
2667 + * are automatically detected by keeping a cache of recent attribute block
2668 + * numbers and hashes over the block's contents in memory.
2671 + * Extended attribute block layout:
2673 + * +------------------+
2676 + * | entry 2 | | growing downwards
2678 + * | four null bytes |
2681 + * | value 3 | | growing upwards
2683 + * +------------------+
2685 + * The block header is followed by multiple entry descriptors. These entry
2686 + * descriptors are variable in size, and alligned to EXT3_XATTR_PAD
2687 + * byte boundaries. The entry descriptors are sorted by attribute name,
2688 + * so that two extended attribute blocks can be compared efficiently.
2690 + * Attribute values are aligned to the end of the block, stored in
2691 + * no specific order. They are also padded to EXT3_XATTR_PAD byte
2692 + * boundaries. No additional gaps are left between them.
2694 + * Locking strategy
2695 + * ----------------
2696 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
2697 + * the xattr inode operations are called, so we are guaranteed that only one
2698 + * processes accesses extended attributes of an inode at any time.
2700 + * For writing we also grab the ext3_xattr_sem semaphore. This ensures that
2701 + * only a single process is modifying an extended attribute block, even
2702 + * if the block is shared among inodes.
2704 + * Note for porting to 2.5
2705 + * -----------------------
2706 + * The BKL will no longer be held in the xattr inode operations.
2709 +#include <linux/module.h>
2710 +#include <linux/fs.h>
2711 +#include <linux/locks.h>
2712 +#include <linux/slab.h>
2713 +#include <linux/ext3_jbd.h>
2714 +#include <linux/ext3_fs.h>
2715 +#include <linux/ext3_xattr.h>
2716 +#include <linux/mbcache.h>
2717 +#include <linux/quotaops.h>
2718 +#include <asm/semaphore.h>
2719 +#include <linux/compatmac.h>
2721 +#define EXT3_EA_USER "user."
2723 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
2724 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
2727 +#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data))
2728 +#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr))
2729 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
2730 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
2732 +#ifdef EXT3_XATTR_DEBUG
2733 +# define ea_idebug(inode, f...) do { \
2734 + printk(KERN_DEBUG "inode %s:%ld: ", \
2735 + kdevname(inode->i_dev), inode->i_ino); \
2739 +# define ea_bdebug(bh, f...) do { \
2740 + printk(KERN_DEBUG "block %s:%ld: ", \
2741 + kdevname(bh->b_dev), bh->b_blocknr); \
2746 +# define ea_idebug(f...)
2747 +# define ea_bdebug(f...)
2750 +static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *,
2751 + struct ext3_xattr_header *);
2753 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
2755 +static int ext3_xattr_cache_insert(struct buffer_head *);
2756 +static struct buffer_head *ext3_xattr_cache_find(struct inode *,
2757 + struct ext3_xattr_header *);
2758 +static void ext3_xattr_cache_remove(struct buffer_head *);
2759 +static void ext3_xattr_rehash(struct ext3_xattr_header *,
2760 + struct ext3_xattr_entry *);
2762 +static struct mb_cache *ext3_xattr_cache;
2765 +# define ext3_xattr_cache_insert(bh) 0
2766 +# define ext3_xattr_cache_find(inode, header) NULL
2767 +# define ext3_xattr_cache_remove(bh) while(0) {}
2768 +# define ext3_xattr_rehash(header, entry) while(0) {}
2772 + * If a file system does not share extended attributes among inodes,
2773 + * we should not need the ext3_xattr_sem semaphore. However, the
2774 + * filesystem may still contain shared blocks, so we always take
2778 +DECLARE_MUTEX(ext3_xattr_sem);
2781 +ext3_xattr_new_block(handle_t *handle, struct inode *inode,
2782 + int * errp, int force)
2784 + struct super_block *sb = inode->i_sb;
2785 + int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
2786 + EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb);
2788 + /* How can we enforce the allocation? */
2789 + int block = ext3_new_block(handle, inode, goal, 0, 0, errp);
2792 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2798 +ext3_xattr_quota_alloc(struct inode *inode, int force)
2800 + /* How can we enforce the allocation? */
2802 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
2804 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2806 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
2814 +ext3_xattr_quota_free(struct inode *inode)
2816 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
2817 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2821 +ext3_xattr_free_block(handle_t *handle, struct inode * inode,
2822 + unsigned long block)
2824 + ext3_free_blocks(handle, inode, block, 1);
2825 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2829 +# define ext3_xattr_quota_free(inode) \
2830 + DQUOT_FREE_BLOCK(inode, 1)
2831 +# define ext3_xattr_free_block(handle, inode, block) \
2832 + ext3_free_blocks(handle, inode, block, 1)
2835 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
2837 +static inline struct buffer_head *
2838 +sb_bread(struct super_block *sb, int block)
2840 + return bread(sb->s_dev, block, sb->s_blocksize);
2843 +static inline struct buffer_head *
2844 +sb_getblk(struct super_block *sb, int block)
2846 + return getblk(sb->s_dev, block, sb->s_blocksize);
2851 +struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
2852 +rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
2855 +ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
2857 + int error = -EINVAL;
2859 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2860 + write_lock(&ext3_handler_lock);
2861 + if (!ext3_xattr_handlers[name_index-1]) {
2862 + ext3_xattr_handlers[name_index-1] = handler;
2865 + write_unlock(&ext3_handler_lock);
2871 +ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
2873 + if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
2874 + write_lock(&ext3_handler_lock);
2875 + ext3_xattr_handlers[name_index-1] = NULL;
2876 + write_unlock(&ext3_handler_lock);
2880 +static inline const char *
2881 +strcmp_prefix(const char *a, const char *a_prefix)
2883 + while (*a_prefix && *a == *a_prefix) {
2887 + return *a_prefix ? NULL : a;
2891 + * Decode the extended attribute name, and translate it into
2892 + * the name_index and name suffix.
2894 +static inline struct ext3_xattr_handler *
2895 +ext3_xattr_resolve_name(const char **name)
2897 + struct ext3_xattr_handler *handler = NULL;
2902 + read_lock(&ext3_handler_lock);
2903 + for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
2904 + if (ext3_xattr_handlers[i]) {
2905 + const char *n = strcmp_prefix(*name,
2906 + ext3_xattr_handlers[i]->prefix);
2908 + handler = ext3_xattr_handlers[i];
2914 + read_unlock(&ext3_handler_lock);
2918 +static inline struct ext3_xattr_handler *
2919 +ext3_xattr_handler(int name_index)
2921 + struct ext3_xattr_handler *handler = NULL;
2922 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2923 + read_lock(&ext3_handler_lock);
2924 + handler = ext3_xattr_handlers[name_index-1];
2925 + read_unlock(&ext3_handler_lock);
2931 + * Inode operation getxattr()
2933 + * dentry->d_inode->i_sem down
2934 + * BKL held [before 2.5.x]
2937 +ext3_getxattr(struct dentry *dentry, const char *name,
2938 + void *buffer, size_t size)
2940 + struct ext3_xattr_handler *handler;
2941 + struct inode *inode = dentry->d_inode;
2943 + handler = ext3_xattr_resolve_name(&name);
2946 + return handler->get(inode, name, buffer, size);
2950 + * Inode operation listxattr()
2952 + * dentry->d_inode->i_sem down
2953 + * BKL held [before 2.5.x]
2956 +ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
2958 + return ext3_xattr_list(dentry->d_inode, buffer, size);
2962 + * Inode operation setxattr()
2964 + * dentry->d_inode->i_sem down
2965 + * BKL held [before 2.5.x]
2968 +ext3_setxattr(struct dentry *dentry, const char *name,
2969 + const void *value, size_t size, int flags)
2971 + struct ext3_xattr_handler *handler;
2972 + struct inode *inode = dentry->d_inode;
2975 + value = ""; /* empty EA, do not remove */
2976 + handler = ext3_xattr_resolve_name(&name);
2979 + return handler->set(inode, name, value, size, flags);
2983 + * Inode operation removexattr()
2985 + * dentry->d_inode->i_sem down
2986 + * BKL held [before 2.5.x]
2989 +ext3_removexattr(struct dentry *dentry, const char *name)
2991 + struct ext3_xattr_handler *handler;
2992 + struct inode *inode = dentry->d_inode;
2994 + handler = ext3_xattr_resolve_name(&name);
2997 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
3001 + * ext3_xattr_get()
3003 + * Copy an extended attribute into the buffer
3004 + * provided, or compute the buffer size required.
3005 + * Buffer is NULL to compute the size of the buffer required.
3007 + * Returns a negative error number on failure, or the number of bytes
3008 + * used / required on success.
3011 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
3012 + void *buffer, size_t buffer_size)
3014 + struct buffer_head *bh = NULL;
3015 + struct ext3_xattr_entry *entry;
3016 + unsigned int block, size;
3018 + int name_len, error;
3020 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
3021 + name_index, name, buffer, (long)buffer_size);
3025 + if (!EXT3_I(inode)->i_file_acl)
3027 + block = EXT3_I(inode)->i_file_acl;
3028 + ea_idebug(inode, "reading block %d", block);
3029 + bh = sb_bread(inode->i_sb, block);
3032 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3033 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
3034 + end = bh->b_data + bh->b_size;
3035 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3036 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3037 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_get",
3038 + "inode %ld: bad block %d", inode->i_ino, block);
3042 + /* find named attribute */
3043 + name_len = strlen(name);
3046 + if (name_len > 255)
3048 + entry = FIRST_ENTRY(bh);
3049 + while (!IS_LAST_ENTRY(entry)) {
3050 + struct ext3_xattr_entry *next =
3051 + EXT3_XATTR_NEXT(entry);
3052 + if ((char *)next >= end)
3054 + if (name_index == entry->e_name_index &&
3055 + name_len == entry->e_name_len &&
3056 + memcmp(name, entry->e_name, name_len) == 0)
3060 + /* Check the remaining name entries */
3061 + while (!IS_LAST_ENTRY(entry)) {
3062 + struct ext3_xattr_entry *next =
3063 + EXT3_XATTR_NEXT(entry);
3064 + if ((char *)next >= end)
3068 + if (ext3_xattr_cache_insert(bh))
3069 + ea_idebug(inode, "cache insert failed");
3073 + /* check the buffer size */
3074 + if (entry->e_value_block != 0)
3076 + size = le32_to_cpu(entry->e_value_size);
3077 + if (size > inode->i_sb->s_blocksize ||
3078 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
3081 + if (ext3_xattr_cache_insert(bh))
3082 + ea_idebug(inode, "cache insert failed");
3085 + if (size > buffer_size)
3087 + /* return value of attribute */
3088 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
3100 + * ext3_xattr_list()
3102 + * Copy a list of attribute names into the buffer
3103 + * provided, or compute the buffer size required.
3104 + * Buffer is NULL to compute the size of the buffer required.
3106 + * Returns a negative error number on failure, or the number of bytes
3107 + * used / required on success.
3110 +ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
3112 + struct buffer_head *bh = NULL;
3113 + struct ext3_xattr_entry *entry;
3114 + unsigned int block, size = 0;
3118 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
3119 + buffer, (long)buffer_size);
3121 + if (!EXT3_I(inode)->i_file_acl)
3123 + block = EXT3_I(inode)->i_file_acl;
3124 + ea_idebug(inode, "reading block %d", block);
3125 + bh = sb_bread(inode->i_sb, block);
3128 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3129 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
3130 + end = bh->b_data + bh->b_size;
3131 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3132 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3133 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_list",
3134 + "inode %ld: bad block %d", inode->i_ino, block);
3138 + /* compute the size required for the list of attribute names */
3139 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
3140 + entry = EXT3_XATTR_NEXT(entry)) {
3141 + struct ext3_xattr_handler *handler;
3142 + struct ext3_xattr_entry *next =
3143 + EXT3_XATTR_NEXT(entry);
3144 + if ((char *)next >= end)
3147 + handler = ext3_xattr_handler(entry->e_name_index);
3149 + size += handler->list(NULL, inode, entry->e_name,
3150 + entry->e_name_len);
3153 + if (ext3_xattr_cache_insert(bh))
3154 + ea_idebug(inode, "cache insert failed");
3160 + if (size > buffer_size)
3164 + /* list the attribute names */
3166 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
3167 + entry = EXT3_XATTR_NEXT(entry)) {
3168 + struct ext3_xattr_handler *handler;
3170 + handler = ext3_xattr_handler(entry->e_name_index);
3172 + buf += handler->list(buf, inode, entry->e_name,
3173 + entry->e_name_len);
3184 + * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is
3185 + * not set, set it.
3187 +static void ext3_xattr_update_super_block(handle_t *handle,
3188 + struct super_block *sb)
3190 + if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
3194 + ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
3195 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
3196 + EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR;
3198 + EXT3_SB(sb)->s_es->s_feature_compat |=
3199 + cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
3201 + ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
3206 + * ext3_xattr_set()
3208 + * Create, replace or remove an extended attribute for this inode. Buffer
3209 + * is NULL to remove an existing extended attribute, and non-NULL to
3210 + * either replace an existing extended attribute, or create a new extended
3211 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
3212 + * specify that an extended attribute must exist and must not exist
3213 + * previous to the call, respectively.
3215 + * Returns 0, or a negative error number on failure.
3218 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
3219 + const char *name, const void *value, size_t value_len, int flags)
3221 + struct super_block *sb = inode->i_sb;
3222 + struct buffer_head *bh = NULL;
3223 + struct ext3_xattr_header *header = NULL;
3224 + struct ext3_xattr_entry *here, *last;
3225 + unsigned int name_len;
3226 + int block = EXT3_I(inode)->i_file_acl;
3227 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
3231 + * header -- Points either into bh, or to a temporarily
3232 + * allocated buffer.
3233 + * here -- The named entry found, or the place for inserting, within
3234 + * the block pointed to by header.
3235 + * last -- Points right after the last named entry within the block
3236 + * pointed to by header.
3237 + * min_offs -- The offset of the first value (values are aligned
3238 + * towards the end of the block).
3239 + * end -- Points right after the block pointed to by header.
3242 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
3243 + name_index, name, value, (long)value_len);
3245 + if (IS_RDONLY(inode))
3247 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3249 + if (value == NULL)
3253 + name_len = strlen(name);
3254 + if (name_len > 255 || value_len > sb->s_blocksize)
3256 + down(&ext3_xattr_sem);
3259 + /* The inode already has an extended attribute block. */
3260 + bh = sb_bread(sb, block);
3264 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3265 + atomic_read(&(bh->b_count)),
3266 + le32_to_cpu(HDR(bh)->h_refcount));
3268 + end = bh->b_data + bh->b_size;
3269 + if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3270 + header->h_blocks != cpu_to_le32(1)) {
3271 +bad_block: ext3_error(sb, "ext3_xattr_set",
3272 + "inode %ld: bad block %d", inode->i_ino, block);
3276 + /* Find the named attribute. */
3277 + here = FIRST_ENTRY(bh);
3278 + while (!IS_LAST_ENTRY(here)) {
3279 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here);
3280 + if ((char *)next >= end)
3282 + if (!here->e_value_block && here->e_value_size) {
3283 + int offs = le16_to_cpu(here->e_value_offs);
3284 + if (offs < min_offs)
3287 + not_found = name_index - here->e_name_index;
3289 + not_found = name_len - here->e_name_len;
3291 + not_found = memcmp(name, here->e_name,name_len);
3292 + if (not_found <= 0)
3297 + /* We still need to compute min_offs and last. */
3298 + while (!IS_LAST_ENTRY(last)) {
3299 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last);
3300 + if ((char *)next >= end)
3302 + if (!last->e_value_block && last->e_value_size) {
3303 + int offs = le16_to_cpu(last->e_value_offs);
3304 + if (offs < min_offs)
3310 + /* Check whether we have enough space left. */
3311 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
3313 + /* We will use a new extended attribute block. */
3314 + free = sb->s_blocksize -
3315 + sizeof(struct ext3_xattr_header) - sizeof(__u32);
3316 + here = last = NULL; /* avoid gcc uninitialized warning. */
3320 + /* Request to remove a nonexistent attribute? */
3322 + if (flags & XATTR_REPLACE)
3325 + if (value == NULL)
3328 + free -= EXT3_XATTR_LEN(name_len);
3330 + /* Request to create an existing attribute? */
3332 + if (flags & XATTR_CREATE)
3334 + if (!here->e_value_block && here->e_value_size) {
3335 + unsigned int size = le32_to_cpu(here->e_value_size);
3337 + if (le16_to_cpu(here->e_value_offs) + size >
3338 + sb->s_blocksize || size > sb->s_blocksize)
3340 + free += EXT3_XATTR_SIZE(size);
3343 + free -= EXT3_XATTR_SIZE(value_len);
3348 + /* Here we know that we can set the new attribute. */
3351 + if (header->h_refcount == cpu_to_le32(1)) {
3352 + ea_bdebug(bh, "modifying in-place");
3353 + ext3_xattr_cache_remove(bh);
3354 + error = ext3_journal_get_write_access(handle, bh);
3360 + ea_bdebug(bh, "cloning");
3361 + header = kmalloc(bh->b_size, GFP_KERNEL);
3363 + if (header == NULL)
3365 + memcpy(header, HDR(bh), bh->b_size);
3366 + header->h_refcount = cpu_to_le32(1);
3367 + offset = (char *)header - bh->b_data;
3368 + here = ENTRY((char *)here + offset);
3369 + last = ENTRY((char *)last + offset);
3372 + /* Allocate a buffer where we construct the new block. */
3373 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
3375 + if (header == NULL)
3377 + memset(header, 0, sb->s_blocksize);
3378 + end = (char *)header + sb->s_blocksize;
3379 + header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
3380 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
3381 + last = here = ENTRY(header+1);
3385 + /* Insert the new name. */
3386 + int size = EXT3_XATTR_LEN(name_len);
3387 + int rest = (char *)last - (char *)here;
3388 + memmove((char *)here + size, here, rest);
3389 + memset(here, 0, size);
3390 + here->e_name_index = name_index;
3391 + here->e_name_len = name_len;
3392 + memcpy(here->e_name, name, name_len);
3394 + /* Remove the old value. */
3395 + if (!here->e_value_block && here->e_value_size) {
3396 + char *first_val = (char *)header + min_offs;
3397 + int offs = le16_to_cpu(here->e_value_offs);
3398 + char *val = (char *)header + offs;
3399 + size_t size = EXT3_XATTR_SIZE(
3400 + le32_to_cpu(here->e_value_size));
3401 + memmove(first_val + size, first_val, val - first_val);
3402 + memset(first_val, 0, size);
3403 + here->e_value_offs = 0;
3406 + /* Adjust all value offsets. */
3407 + last = ENTRY(header+1);
3408 + while (!IS_LAST_ENTRY(last)) {
3409 + int o = le16_to_cpu(last->e_value_offs);
3410 + if (!last->e_value_block && o < offs)
3411 + last->e_value_offs =
3412 + cpu_to_le16(o + size);
3413 + last = EXT3_XATTR_NEXT(last);
3416 + if (value == NULL) {
3417 + /* Remove this attribute. */
3418 + if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) {
3419 + /* This block is now empty. */
3420 + error = ext3_xattr_set2(handle, inode, bh,NULL);
3423 + /* Remove the old name. */
3424 + int size = EXT3_XATTR_LEN(name_len);
3425 + last = ENTRY((char *)last - size);
3426 + memmove(here, (char*)here + size,
3427 + (char*)last - (char*)here);
3428 + memset(last, 0, size);
3433 + if (value != NULL) {
3434 + /* Insert the new value. */
3435 + here->e_value_size = cpu_to_le32(value_len);
3437 + size_t size = EXT3_XATTR_SIZE(value_len);
3438 + char *val = (char *)header + min_offs - size;
3439 + here->e_value_offs =
3440 + cpu_to_le16((char *)val - (char *)header);
3441 + memset(val + size - EXT3_XATTR_PAD, 0,
3442 + EXT3_XATTR_PAD); /* Clear the pad bytes. */
3443 + memcpy(val, value, value_len);
3446 + ext3_xattr_rehash(header, here);
3448 + error = ext3_xattr_set2(handle, inode, bh, header);
3452 + if (!(bh && header == HDR(bh)))
3454 + up(&ext3_xattr_sem);
3460 + * Second half of ext3_xattr_set(): Update the file system.
3463 +ext3_xattr_set2(handle_t *handle, struct inode *inode,
3464 + struct buffer_head *old_bh, struct ext3_xattr_header *header)
3466 + struct super_block *sb = inode->i_sb;
3467 + struct buffer_head *new_bh = NULL;
3471 + new_bh = ext3_xattr_cache_find(inode, header);
3474 + * We found an identical block in the cache.
3475 + * The old block will be released after updating
3478 + ea_bdebug(old_bh, "reusing block %ld",
3479 + new_bh->b_blocknr);
3482 + if (ext3_xattr_quota_alloc(inode, 1))
3485 + error = ext3_journal_get_write_access(handle, new_bh);
3488 + HDR(new_bh)->h_refcount = cpu_to_le32(
3489 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
3490 + ea_bdebug(new_bh, "refcount now=%d",
3491 + le32_to_cpu(HDR(new_bh)->h_refcount));
3492 + } else if (old_bh && header == HDR(old_bh)) {
3493 + /* Keep this block. */
3495 + ext3_xattr_cache_insert(new_bh);
3497 + /* We need to allocate a new block */
3498 + int force = EXT3_I(inode)->i_file_acl != 0;
3499 + int block = ext3_xattr_new_block(handle, inode,
3503 + ea_idebug(inode, "creating block %d", block);
3505 + new_bh = sb_getblk(sb, block);
3507 +getblk_failed: ext3_xattr_free_block(handle, inode, block);
3511 + lock_buffer(new_bh);
3512 + error = ext3_journal_get_create_access(handle, new_bh);
3514 + unlock_buffer(new_bh);
3515 + goto getblk_failed;
3517 + memcpy(new_bh->b_data, header, new_bh->b_size);
3518 + mark_buffer_uptodate(new_bh, 1);
3519 + unlock_buffer(new_bh);
3520 + ext3_xattr_cache_insert(new_bh);
3522 + ext3_xattr_update_super_block(handle, sb);
3524 + error = ext3_journal_dirty_metadata(handle, new_bh);
3529 + /* Update the inode. */
3530 + EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
3531 + inode->i_ctime = CURRENT_TIME;
3532 + ext3_mark_inode_dirty(handle, inode);
3533 + if (IS_SYNC(inode))
3534 + handle->h_sync = 1;
3537 + if (old_bh && old_bh != new_bh) {
3539 + * If there was an old block, and we are not still using it,
3540 + * we now release the old block.
3542 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
3544 + error = ext3_journal_get_write_access(handle, old_bh);
3547 + if (refcount == 1) {
3548 + /* Free the old block. */
3549 + ea_bdebug(old_bh, "freeing");
3550 + ext3_xattr_free_block(handle, inode, old_bh->b_blocknr);
3552 + /* ext3_forget() calls bforget() for us, but we
3553 + let our caller release old_bh, so we need to
3554 + duplicate the handle before. */
3556 + ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr);
3558 + /* Decrement the refcount only. */
3560 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
3561 + ext3_xattr_quota_free(inode);
3562 + ext3_journal_dirty_metadata(handle, old_bh);
3563 + ea_bdebug(old_bh, "refcount now=%d", refcount);
3568 + if (old_bh != new_bh)
3575 + * ext3_xattr_delete_inode()
3577 + * Free extended attribute resources associated with this inode. This
3578 + * is called immediately before an inode is freed.
3581 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
3583 + struct buffer_head *bh;
3584 + unsigned int block = EXT3_I(inode)->i_file_acl;
3588 + down(&ext3_xattr_sem);
3590 + bh = sb_bread(inode->i_sb, block);
3592 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3593 + "inode %ld: block %d read error", inode->i_ino, block);
3596 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
3597 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3598 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3599 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3600 + "inode %ld: bad block %d", inode->i_ino, block);
3603 + ext3_journal_get_write_access(handle, bh);
3604 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
3605 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
3606 + ext3_xattr_cache_remove(bh);
3607 + ext3_xattr_free_block(handle, inode, block);
3608 + ext3_forget(handle, 1, inode, bh, block);
3611 + HDR(bh)->h_refcount = cpu_to_le32(
3612 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
3613 + ext3_journal_dirty_metadata(handle, bh);
3614 + if (IS_SYNC(inode))
3615 + handle->h_sync = 1;
3616 + ext3_xattr_quota_free(inode);
3618 + EXT3_I(inode)->i_file_acl = 0;
3622 + up(&ext3_xattr_sem);
3626 + * ext3_xattr_put_super()
3628 + * This is called when a file system is unmounted.
3631 +ext3_xattr_put_super(struct super_block *sb)
3633 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3634 + mb_cache_shrink(ext3_xattr_cache, sb->s_dev);
3638 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3641 + * ext3_xattr_cache_insert()
3643 + * Create a new entry in the extended attribute cache, and insert
3644 + * it unless such an entry is already in the cache.
3646 + * Returns 0, or a negative error number on failure.
3649 +ext3_xattr_cache_insert(struct buffer_head *bh)
3651 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
3652 + struct mb_cache_entry *ce;
3655 + ce = mb_cache_entry_alloc(ext3_xattr_cache);
3658 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
3660 + mb_cache_entry_free(ce);
3661 + if (error == -EBUSY) {
3662 + ea_bdebug(bh, "already in cache (%d cache entries)",
3663 + atomic_read(&ext3_xattr_cache->c_entry_count));
3667 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
3668 + atomic_read(&ext3_xattr_cache->c_entry_count));
3669 + mb_cache_entry_release(ce);
3675 + * ext3_xattr_cmp()
3677 + * Compare two extended attribute blocks for equality.
3679 + * Returns 0 if the blocks are equal, 1 if they differ, and
3680 + * a negative error number on errors.
3683 +ext3_xattr_cmp(struct ext3_xattr_header *header1,
3684 + struct ext3_xattr_header *header2)
3686 + struct ext3_xattr_entry *entry1, *entry2;
3688 + entry1 = ENTRY(header1+1);
3689 + entry2 = ENTRY(header2+1);
3690 + while (!IS_LAST_ENTRY(entry1)) {
3691 + if (IS_LAST_ENTRY(entry2))
3693 + if (entry1->e_hash != entry2->e_hash ||
3694 + entry1->e_name_len != entry2->e_name_len ||
3695 + entry1->e_value_size != entry2->e_value_size ||
3696 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
3698 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
3700 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
3701 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
3702 + le32_to_cpu(entry1->e_value_size)))
3705 + entry1 = EXT3_XATTR_NEXT(entry1);
3706 + entry2 = EXT3_XATTR_NEXT(entry2);
3708 + if (!IS_LAST_ENTRY(entry2))
3714 + * ext3_xattr_cache_find()
3716 + * Find an identical extended attribute block.
3718 + * Returns a pointer to the block found, or NULL if such a block was
3719 + * not found or an error occurred.
3721 +static struct buffer_head *
3722 +ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header)
3724 + __u32 hash = le32_to_cpu(header->h_hash);
3725 + struct mb_cache_entry *ce;
3727 + if (!header->h_hash)
3728 + return NULL; /* never share */
3729 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
3730 + ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash);
3732 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
3735 + ext3_error(inode->i_sb, "ext3_xattr_cache_find",
3736 + "inode %ld: block %ld read error",
3737 + inode->i_ino, ce->e_block);
3738 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
3739 + EXT3_XATTR_REFCOUNT_MAX) {
3740 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
3741 + le32_to_cpu(HDR(bh)->h_refcount),
3742 + EXT3_XATTR_REFCOUNT_MAX);
3743 + } else if (!ext3_xattr_cmp(header, HDR(bh))) {
3744 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
3745 + mb_cache_entry_release(ce);
3749 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
3755 + * ext3_xattr_cache_remove()
3757 + * Remove the cache entry of a block from the cache. Called when a
3758 + * block becomes invalid.
3761 +ext3_xattr_cache_remove(struct buffer_head *bh)
3763 + struct mb_cache_entry *ce;
3765 + ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr);
3767 + ea_bdebug(bh, "removing (%d cache entries remaining)",
3768 + atomic_read(&ext3_xattr_cache->c_entry_count)-1);
3769 + mb_cache_entry_free(ce);
3771 + ea_bdebug(bh, "no cache entry");
3774 +#define NAME_HASH_SHIFT 5
3775 +#define VALUE_HASH_SHIFT 16
3778 + * ext3_xattr_hash_entry()
3780 + * Compute the hash of an extended attribute.
3782 +static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
3783 + struct ext3_xattr_entry *entry)
3786 + char *name = entry->e_name;
3789 + for (n=0; n < entry->e_name_len; n++) {
3790 + hash = (hash << NAME_HASH_SHIFT) ^
3791 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
3795 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
3796 + __u32 *value = (__u32 *)((char *)header +
3797 + le16_to_cpu(entry->e_value_offs));
3798 + for (n = (le32_to_cpu(entry->e_value_size) +
3799 + EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
3800 + hash = (hash << VALUE_HASH_SHIFT) ^
3801 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
3802 + le32_to_cpu(*value++);
3805 + entry->e_hash = cpu_to_le32(hash);
3808 +#undef NAME_HASH_SHIFT
3809 +#undef VALUE_HASH_SHIFT
3811 +#define BLOCK_HASH_SHIFT 16
3814 + * ext3_xattr_rehash()
3816 + * Re-compute the extended attribute hash value after an entry has changed.
3818 +static void ext3_xattr_rehash(struct ext3_xattr_header *header,
3819 + struct ext3_xattr_entry *entry)
3821 + struct ext3_xattr_entry *here;
3824 + ext3_xattr_hash_entry(header, entry);
3825 + here = ENTRY(header+1);
3826 + while (!IS_LAST_ENTRY(here)) {
3827 + if (!here->e_hash) {
3828 + /* Block is not shared if an entry's hash value == 0 */
3832 + hash = (hash << BLOCK_HASH_SHIFT) ^
3833 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
3834 + le32_to_cpu(here->e_hash);
3835 + here = EXT3_XATTR_NEXT(here);
3837 + header->h_hash = cpu_to_le32(hash);
3840 +#undef BLOCK_HASH_SHIFT
3843 +init_ext3_xattr(void)
3845 + ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
3846 + sizeof(struct mb_cache_entry) +
3847 + sizeof(struct mb_cache_entry_index), 1, 61);
3848 + if (!ext3_xattr_cache)
3855 +exit_ext3_xattr(void)
3857 + if (ext3_xattr_cache)
3858 + mb_cache_destroy(ext3_xattr_cache);
3859 + ext3_xattr_cache = NULL;
3862 +#else /* CONFIG_EXT3_FS_XATTR_SHARING */
3865 +init_ext3_xattr(void)
3871 +exit_ext3_xattr(void)
3875 +#endif /* CONFIG_EXT3_FS_XATTR_SHARING */
3876 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
3877 +++ linux-2.4.20-root/fs/ext3/xattr_user.c 2003-05-07 18:08:03.000000000 +0800
3880 + * linux/fs/ext3/xattr_user.c
3881 + * Handler for extended user attributes.
3883 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
3886 +#include <linux/module.h>
3887 +#include <linux/string.h>
3888 +#include <linux/fs.h>
3889 +#include <linux/ext3_jbd.h>
3890 +#include <linux/ext3_fs.h>
3891 +#include <linux/ext3_xattr.h>
3893 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3894 +# include <linux/ext3_acl.h>
3897 +#define XATTR_USER_PREFIX "user."
3900 +ext3_xattr_user_list(char *list, struct inode *inode,
3901 + const char *name, int name_len)
3903 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
3905 + if (!test_opt(inode->i_sb, XATTR_USER))
3909 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
3910 + memcpy(list+prefix_len, name, name_len);
3911 + list[prefix_len + name_len] = '\0';
3913 + return prefix_len + name_len + 1;
3917 +ext3_xattr_user_get(struct inode *inode, const char *name,
3918 + void *buffer, size_t size)
3922 + if (strcmp(name, "") == 0)
3924 + if (!test_opt(inode->i_sb, XATTR_USER))
3926 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3927 + error = ext3_permission_locked(inode, MAY_READ);
3929 + error = permission(inode, MAY_READ);
3934 + return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name,
3939 +ext3_xattr_user_set(struct inode *inode, const char *name,
3940 + const void *value, size_t size, int flags)
3945 + if (strcmp(name, "") == 0)
3947 + if (!test_opt(inode->i_sb, XATTR_USER))
3949 + if ( !S_ISREG(inode->i_mode) &&
3950 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
3952 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3953 + error = ext3_permission_locked(inode, MAY_WRITE);
3955 + error = permission(inode, MAY_WRITE);
3960 + handle = ext3_journal_start(inode, EXT3_XATTR_TRANS_BLOCKS);
3961 + if (IS_ERR(handle))
3962 + return PTR_ERR(handle);
3963 + error = ext3_xattr_set(handle, inode, EXT3_XATTR_INDEX_USER, name,
3964 + value, size, flags);
3965 + ext3_journal_stop(handle, inode);
3970 +struct ext3_xattr_handler ext3_xattr_user_handler = {
3971 + prefix: XATTR_USER_PREFIX,
3972 + list: ext3_xattr_user_list,
3973 + get: ext3_xattr_user_get,
3974 + set: ext3_xattr_user_set,
3978 +init_ext3_xattr_user(void)
3980 + return ext3_xattr_register(EXT3_XATTR_INDEX_USER,
3981 + &ext3_xattr_user_handler);
3985 +exit_ext3_xattr_user(void)
3987 + ext3_xattr_unregister(EXT3_XATTR_INDEX_USER,
3988 + &ext3_xattr_user_handler);
3990 --- linux-2.4.20/fs/jfs/jfs_xattr.h~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
3991 +++ linux-2.4.20-root/fs/jfs/jfs_xattr.h 2003-05-07 18:08:03.000000000 +0800
3992 @@ -52,8 +52,10 @@ struct jfs_ea_list {
3993 #define END_EALIST(ealist) \
3994 ((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist)))
3996 -extern int __jfs_setxattr(struct inode *, const char *, void *, size_t, int);
3997 -extern int jfs_setxattr(struct dentry *, const char *, void *, size_t, int);
3998 +extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t,
4000 +extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
4002 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
4003 extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
4004 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
4005 --- linux-2.4.20/fs/jfs/xattr.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
4006 +++ linux-2.4.20-root/fs/jfs/xattr.c 2003-05-07 18:08:03.000000000 +0800
4007 @@ -641,7 +641,7 @@ static int ea_put(struct inode *inode, s
4010 static int can_set_xattr(struct inode *inode, const char *name,
4011 - void *value, size_t value_len)
4012 + const void *value, size_t value_len)
4014 if (IS_RDONLY(inode))
4016 @@ -660,7 +660,7 @@ static int can_set_xattr(struct inode *i
4017 return permission(inode, MAY_WRITE);
4020 -int __jfs_setxattr(struct inode *inode, const char *name, void *value,
4021 +int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
4022 size_t value_len, int flags)
4024 struct jfs_ea_list *ealist;
4025 @@ -799,7 +799,7 @@ int __jfs_setxattr(struct inode *inode,
4029 -int jfs_setxattr(struct dentry *dentry, const char *name, void *value,
4030 +int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
4031 size_t value_len, int flags)
4033 if (value == NULL) { /* empty EA, do not remove */
4034 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4035 +++ linux-2.4.20-root/fs/mbcache.c 2003-05-07 18:08:03.000000000 +0800
4038 + * linux/fs/mbcache.c
4039 + * (C) 2001-2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
4043 + * Filesystem Meta Information Block Cache (mbcache)
4045 + * The mbcache caches blocks of block devices that need to be located
4046 + * by their device/block number, as well as by other criteria (such
4047 + * as the block's contents).
4049 + * There can only be one cache entry in a cache per device and block number.
4050 + * Additional indexes need not be unique in this sense. The number of
4051 + * additional indexes (=other criteria) can be hardwired at compile time
4052 + * or specified at cache create time.
4054 + * Each cache entry is of fixed size. An entry may be `valid' or `invalid'
4055 + * in the cache. A valid entry is in the main hash tables of the cache,
4056 + * and may also be in the lru list. An invalid entry is not in any hashes
4059 + * A valid cache entry is only in the lru list if no handles refer to it.
4060 + * Invalid cache entries will be freed when the last handle to the cache
4061 + * entry is released. Entries that cannot be freed immediately are put
4062 + * back on the lru list.
4065 +#include <linux/kernel.h>
4066 +#include <linux/module.h>
4068 +#include <linux/fs.h>
4069 +#include <linux/slab.h>
4070 +#include <linux/sched.h>
4071 +#include <linux/cache_def.h>
4072 +#include <linux/version.h>
4073 +#include <linux/init.h>
4074 +#include <linux/mbcache.h>
4077 +#ifdef MB_CACHE_DEBUG
4078 +# define mb_debug(f...) do { \
4079 + printk(KERN_DEBUG f); \
4082 +#define mb_assert(c) do { if (!(c)) \
4083 + printk(KERN_ERR "assertion " #c " failed\n"); \
4086 +# define mb_debug(f...) do { } while(0)
4087 +# define mb_assert(c) do { } while(0)
4089 +#define mb_error(f...) do { \
4090 + printk(KERN_ERR f); \
4094 +MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>");
4095 +MODULE_DESCRIPTION("Meta block cache (for extended attributes)");
4096 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
4097 +MODULE_LICENSE("GPL");
4100 +EXPORT_SYMBOL(mb_cache_create);
4101 +EXPORT_SYMBOL(mb_cache_shrink);
4102 +EXPORT_SYMBOL(mb_cache_destroy);
4103 +EXPORT_SYMBOL(mb_cache_entry_alloc);
4104 +EXPORT_SYMBOL(mb_cache_entry_insert);
4105 +EXPORT_SYMBOL(mb_cache_entry_release);
4106 +EXPORT_SYMBOL(mb_cache_entry_takeout);
4107 +EXPORT_SYMBOL(mb_cache_entry_free);
4108 +EXPORT_SYMBOL(mb_cache_entry_dup);
4109 +EXPORT_SYMBOL(mb_cache_entry_get);
4110 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
4111 +EXPORT_SYMBOL(mb_cache_entry_find_first);
4112 +EXPORT_SYMBOL(mb_cache_entry_find_next);
4117 + * Global data: list of all mbcache's, lru list, and a spinlock for
4118 + * accessing cache data structures on SMP machines. The lru list is
4119 + * global across all mbcaches.
4122 +static LIST_HEAD(mb_cache_list);
4123 +static LIST_HEAD(mb_cache_lru_list);
4124 +static spinlock_t mb_cache_spinlock = SPIN_LOCK_UNLOCKED;
4127 +mb_cache_indexes(struct mb_cache *cache)
4129 +#ifdef MB_CACHE_INDEXES_COUNT
4130 + return MB_CACHE_INDEXES_COUNT;
4132 + return cache->c_indexes_count;
4137 + * What the mbcache registers as to get shrunk dynamically.
4141 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask);
4143 +static struct cache_definition mb_cache_definition = {
4145 + mb_cache_memory_pressure
4150 +__mb_cache_entry_is_hashed(struct mb_cache_entry *ce)
4152 + return !list_empty(&ce->e_block_list);
4157 +__mb_cache_entry_unhash(struct mb_cache_entry *ce)
4161 + if (__mb_cache_entry_is_hashed(ce)) {
4162 + list_del_init(&ce->e_block_list);
4163 + for (n=0; n<mb_cache_indexes(ce->e_cache); n++)
4164 + list_del(&ce->e_indexes[n].o_list);
4170 +__mb_cache_entry_forget(struct mb_cache_entry *ce, int gfp_mask)
4172 + struct mb_cache *cache = ce->e_cache;
4174 + mb_assert(atomic_read(&ce->e_used) == 0);
4175 + if (cache->c_op.free && cache->c_op.free(ce, gfp_mask)) {
4176 + /* free failed -- put back on the lru list
4177 + for freeing later. */
4178 + spin_lock(&mb_cache_spinlock);
4179 + list_add(&ce->e_lru_list, &mb_cache_lru_list);
4180 + spin_unlock(&mb_cache_spinlock);
4182 + kmem_cache_free(cache->c_entry_cache, ce);
4183 + atomic_dec(&cache->c_entry_count);
4189 +__mb_cache_entry_release_unlock(struct mb_cache_entry *ce)
4191 + if (atomic_dec_and_test(&ce->e_used)) {
4192 + if (__mb_cache_entry_is_hashed(ce))
4193 + list_add_tail(&ce->e_lru_list, &mb_cache_lru_list);
4195 + spin_unlock(&mb_cache_spinlock);
4196 + __mb_cache_entry_forget(ce, GFP_KERNEL);
4200 + spin_unlock(&mb_cache_spinlock);
4205 + * mb_cache_memory_pressure() memory pressure callback
4207 + * This function is called by the kernel memory management when memory
4210 + * @priority: Amount by which to shrink the cache (0 = highes priority)
4211 + * @gfp_mask: (ignored)
4214 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask)
4216 + LIST_HEAD(free_list);
4217 + struct list_head *l, *ltmp;
4220 + spin_lock(&mb_cache_spinlock);
4221 + list_for_each(l, &mb_cache_list) {
4222 + struct mb_cache *cache =
4223 + list_entry(l, struct mb_cache, c_cache_list);
4224 + mb_debug("cache %s (%d)", cache->c_name,
4225 + atomic_read(&cache->c_entry_count));
4226 + count += atomic_read(&cache->c_entry_count);
4228 + mb_debug("trying to free %d of %d entries",
4229 + count / (priority ? priority : 1), count);
4231 + count /= priority;
4232 + while (count-- && !list_empty(&mb_cache_lru_list)) {
4233 + struct mb_cache_entry *ce =
4234 + list_entry(mb_cache_lru_list.next,
4235 + struct mb_cache_entry, e_lru_list);
4236 + list_del(&ce->e_lru_list);
4237 + __mb_cache_entry_unhash(ce);
4238 + list_add_tail(&ce->e_lru_list, &free_list);
4240 + spin_unlock(&mb_cache_spinlock);
4241 + list_for_each_safe(l, ltmp, &free_list) {
4242 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4243 + e_lru_list), gfp_mask);
4249 + * mb_cache_create() create a new cache
4251 + * All entries in one cache are equal size. Cache entries may be from
4252 + * multiple devices. If this is the first mbcache created, registers
4253 + * the cache with kernel memory management. Returns NULL if no more
4254 + * memory was available.
4256 + * @name: name of the cache (informal)
4257 + * @cache_op: contains the callback called when freeing a cache entry
4258 + * @entry_size: The size of a cache entry, including
4259 + * struct mb_cache_entry
4260 + * @indexes_count: number of additional indexes in the cache. Must equal
4261 + * MB_CACHE_INDEXES_COUNT if the number of indexes is
4263 + * @bucket_count: number of hash buckets
4266 +mb_cache_create(const char *name, struct mb_cache_op *cache_op,
4267 + size_t entry_size, int indexes_count, int bucket_count)
4270 + struct mb_cache *cache = NULL;
4272 + if(entry_size < sizeof(struct mb_cache_entry) +
4273 + indexes_count * sizeof(struct mb_cache_entry_index))
4276 + MOD_INC_USE_COUNT;
4277 + cache = kmalloc(sizeof(struct mb_cache) +
4278 + indexes_count * sizeof(struct list_head), GFP_KERNEL);
4281 + cache->c_name = name;
4282 + cache->c_op.free = NULL;
4284 + cache->c_op.free = cache_op->free;
4285 + atomic_set(&cache->c_entry_count, 0);
4286 + cache->c_bucket_count = bucket_count;
4287 +#ifdef MB_CACHE_INDEXES_COUNT
4288 + mb_assert(indexes_count == MB_CACHE_INDEXES_COUNT);
4290 + cache->c_indexes_count = indexes_count;
4292 + cache->c_block_hash = kmalloc(bucket_count * sizeof(struct list_head),
4294 + if (!cache->c_block_hash)
4296 + for (n=0; n<bucket_count; n++)
4297 + INIT_LIST_HEAD(&cache->c_block_hash[n]);
4298 + for (m=0; m<indexes_count; m++) {
4299 + cache->c_indexes_hash[m] = kmalloc(bucket_count *
4300 + sizeof(struct list_head),
4302 + if (!cache->c_indexes_hash[m])
4304 + for (n=0; n<bucket_count; n++)
4305 + INIT_LIST_HEAD(&cache->c_indexes_hash[m][n]);
4307 + cache->c_entry_cache = kmem_cache_create(name, entry_size, 0,
4308 + 0 /*SLAB_POISON | SLAB_RED_ZONE*/, NULL, NULL);
4309 + if (!cache->c_entry_cache)
4312 + spin_lock(&mb_cache_spinlock);
4313 + list_add(&cache->c_cache_list, &mb_cache_list);
4314 + spin_unlock(&mb_cache_spinlock);
4320 + kfree(cache->c_indexes_hash[m]);
4321 + if (cache->c_block_hash)
4322 + kfree(cache->c_block_hash);
4325 + MOD_DEC_USE_COUNT;
4331 + * mb_cache_shrink()
4333 + * Removes all cache entires of a device from the cache. All cache entries
4334 + * currently in use cannot be freed, and thus remain in the cache.
4336 + * @cache: which cache to shrink
4337 + * @dev: which device's cache entries to shrink
4340 +mb_cache_shrink(struct mb_cache *cache, kdev_t dev)
4342 + LIST_HEAD(free_list);
4343 + struct list_head *l, *ltmp;
4345 + spin_lock(&mb_cache_spinlock);
4346 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4347 + struct mb_cache_entry *ce =
4348 + list_entry(l, struct mb_cache_entry, e_lru_list);
4349 + if (ce->e_dev == dev) {
4350 + list_del(&ce->e_lru_list);
4351 + list_add_tail(&ce->e_lru_list, &free_list);
4352 + __mb_cache_entry_unhash(ce);
4355 + spin_unlock(&mb_cache_spinlock);
4356 + list_for_each_safe(l, ltmp, &free_list) {
4357 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4358 + e_lru_list), GFP_KERNEL);
4364 + * mb_cache_destroy()
4366 + * Shrinks the cache to its minimum possible size (hopefully 0 entries),
4367 + * and then destroys it. If this was the last mbcache, un-registers the
4368 + * mbcache from kernel memory management.
4371 +mb_cache_destroy(struct mb_cache *cache)
4373 + LIST_HEAD(free_list);
4374 + struct list_head *l, *ltmp;
4377 + spin_lock(&mb_cache_spinlock);
4378 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4379 + struct mb_cache_entry *ce =
4380 + list_entry(l, struct mb_cache_entry, e_lru_list);
4381 + if (ce->e_cache == cache) {
4382 + list_del(&ce->e_lru_list);
4383 + list_add_tail(&ce->e_lru_list, &free_list);
4384 + __mb_cache_entry_unhash(ce);
4387 + list_del(&cache->c_cache_list);
4388 + spin_unlock(&mb_cache_spinlock);
4389 + list_for_each_safe(l, ltmp, &free_list) {
4390 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4391 + e_lru_list), GFP_KERNEL);
4394 + if (atomic_read(&cache->c_entry_count) > 0) {
4395 + mb_error("cache %s: %d orphaned entries",
4397 + atomic_read(&cache->c_entry_count));
4400 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
4401 + /* We don't have kmem_cache_destroy() in 2.2.x */
4402 + kmem_cache_shrink(cache->c_entry_cache);
4404 + kmem_cache_destroy(cache->c_entry_cache);
4406 + for (n=0; n < mb_cache_indexes(cache); n++)
4407 + kfree(cache->c_indexes_hash[n]);
4408 + kfree(cache->c_block_hash);
4411 + MOD_DEC_USE_COUNT;
4416 + * mb_cache_entry_alloc()
4418 + * Allocates a new cache entry. The new entry will not be valid initially,
4419 + * and thus cannot be looked up yet. It should be filled with data, and
4420 + * then inserted into the cache using mb_cache_entry_insert(). Returns NULL
4421 + * if no more memory was available.
4423 +struct mb_cache_entry *
4424 +mb_cache_entry_alloc(struct mb_cache *cache)
4426 + struct mb_cache_entry *ce;
4428 + atomic_inc(&cache->c_entry_count);
4429 + ce = kmem_cache_alloc(cache->c_entry_cache, GFP_KERNEL);
4431 + INIT_LIST_HEAD(&ce->e_lru_list);
4432 + INIT_LIST_HEAD(&ce->e_block_list);
4433 + ce->e_cache = cache;
4434 + atomic_set(&ce->e_used, 1);
4441 + * mb_cache_entry_insert()
4443 + * Inserts an entry that was allocated using mb_cache_entry_alloc() into
4444 + * the cache. After this, the cache entry can be looked up, but is not yet
4445 + * in the lru list as the caller still holds a handle to it. Returns 0 on
4446 + * success, or -EBUSY if a cache entry for that device + inode exists
4447 + * already (this may happen after a failed lookup, if another process has
4448 + * inserted the same cache entry in the meantime).
4450 + * @dev: device the cache entry belongs to
4451 + * @block: block number
4452 + * @keys: array of additional keys. There must be indexes_count entries
4453 + * in the array (as specified when creating the cache).
4456 +mb_cache_entry_insert(struct mb_cache_entry *ce, kdev_t dev,
4457 + unsigned long block, unsigned int keys[])
4459 + struct mb_cache *cache = ce->e_cache;
4460 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4461 + struct list_head *l;
4462 + int error = -EBUSY, n;
4464 + spin_lock(&mb_cache_spinlock);
4465 + list_for_each(l, &cache->c_block_hash[bucket]) {
4466 + struct mb_cache_entry *ce =
4467 + list_entry(l, struct mb_cache_entry, e_block_list);
4468 + if (ce->e_dev == dev && ce->e_block == block)
4471 + __mb_cache_entry_unhash(ce);
4473 + ce->e_block = block;
4474 + list_add(&ce->e_block_list, &cache->c_block_hash[bucket]);
4475 + for (n=0; n<mb_cache_indexes(cache); n++) {
4476 + ce->e_indexes[n].o_key = keys[n];
4477 + bucket = keys[n] % cache->c_bucket_count;
4478 + list_add(&ce->e_indexes[n].o_list,
4479 + &cache->c_indexes_hash[n][bucket]);
4482 + spin_unlock(&mb_cache_spinlock);
4488 + * mb_cache_entry_release()
4490 + * Release a handle to a cache entry. When the last handle to a cache entry
4491 + * is released it is either freed (if it is invalid) or otherwise inserted
4492 + * in to the lru list.
4495 +mb_cache_entry_release(struct mb_cache_entry *ce)
4497 + spin_lock(&mb_cache_spinlock);
4498 + __mb_cache_entry_release_unlock(ce);
4503 + * mb_cache_entry_takeout()
4505 + * Take a cache entry out of the cache, making it invalid. The entry can later
4506 + * be re-inserted using mb_cache_entry_insert(), or released using
4507 + * mb_cache_entry_release().
4510 +mb_cache_entry_takeout(struct mb_cache_entry *ce)
4512 + spin_lock(&mb_cache_spinlock);
4513 + mb_assert(list_empty(&ce->e_lru_list));
4514 + __mb_cache_entry_unhash(ce);
4515 + spin_unlock(&mb_cache_spinlock);
4520 + * mb_cache_entry_free()
4522 + * This is equivalent to the sequence mb_cache_entry_takeout() --
4523 + * mb_cache_entry_release().
4526 +mb_cache_entry_free(struct mb_cache_entry *ce)
4528 + spin_lock(&mb_cache_spinlock);
4529 + mb_assert(list_empty(&ce->e_lru_list));
4530 + __mb_cache_entry_unhash(ce);
4531 + __mb_cache_entry_release_unlock(ce);
4536 + * mb_cache_entry_dup()
4538 + * Duplicate a handle to a cache entry (does not duplicate the cache entry
4539 + * itself). After the call, both the old and the new handle must be released.
4541 +struct mb_cache_entry *
4542 +mb_cache_entry_dup(struct mb_cache_entry *ce)
4544 + atomic_inc(&ce->e_used);
4550 + * mb_cache_entry_get()
4552 + * Get a cache entry by device / block number. (There can only be one entry
4553 + * in the cache per device and block.) Returns NULL if no such cache entry
4556 +struct mb_cache_entry *
4557 +mb_cache_entry_get(struct mb_cache *cache, kdev_t dev, unsigned long block)
4559 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4560 + struct list_head *l;
4561 + struct mb_cache_entry *ce;
4563 + spin_lock(&mb_cache_spinlock);
4564 + list_for_each(l, &cache->c_block_hash[bucket]) {
4565 + ce = list_entry(l, struct mb_cache_entry, e_block_list);
4566 + if (ce->e_dev == dev && ce->e_block == block) {
4567 + if (!list_empty(&ce->e_lru_list))
4568 + list_del_init(&ce->e_lru_list);
4569 + atomic_inc(&ce->e_used);
4576 + spin_unlock(&mb_cache_spinlock);
4580 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
4582 +static struct mb_cache_entry *
4583 +__mb_cache_entry_find(struct list_head *l, struct list_head *head,
4584 + int index, kdev_t dev, unsigned int key)
4586 + while (l != head) {
4587 + struct mb_cache_entry *ce =
4588 + list_entry(l, struct mb_cache_entry,
4589 + e_indexes[index].o_list);
4590 + if (ce->e_dev == dev && ce->e_indexes[index].o_key == key) {
4591 + if (!list_empty(&ce->e_lru_list))
4592 + list_del_init(&ce->e_lru_list);
4593 + atomic_inc(&ce->e_used);
4603 + * mb_cache_entry_find_first()
4605 + * Find the first cache entry on a given device with a certain key in
4606 + * an additional index. Additonal matches can be found with
4607 + * mb_cache_entry_find_next(). Returns NULL if no match was found.
4609 + * @cache: the cache to search
4610 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4611 + * @dev: the device the cache entry should belong to
4612 + * @key: the key in the index
4614 +struct mb_cache_entry *
4615 +mb_cache_entry_find_first(struct mb_cache *cache, int index, kdev_t dev,
4618 + unsigned int bucket = key % cache->c_bucket_count;
4619 + struct list_head *l;
4620 + struct mb_cache_entry *ce;
4622 + mb_assert(index < mb_cache_indexes(cache));
4623 + spin_lock(&mb_cache_spinlock);
4624 + l = cache->c_indexes_hash[index][bucket].next;
4625 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4627 + spin_unlock(&mb_cache_spinlock);
4633 + * mb_cache_entry_find_next()
4635 + * Find the next cache entry on a given device with a certain key in an
4636 + * additional index. Returns NULL if no match could be found. The previous
4637 + * entry is atomatically released, so that mb_cache_entry_find_next() can
4638 + * be called like this:
4640 + * entry = mb_cache_entry_find_first();
4643 + * entry = mb_cache_entry_find_next(entry, ...);
4646 + * @prev: The previous match
4647 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4648 + * @dev: the device the cache entry should belong to
4649 + * @key: the key in the index
4651 +struct mb_cache_entry *
4652 +mb_cache_entry_find_next(struct mb_cache_entry *prev, int index, kdev_t dev,
4655 + struct mb_cache *cache = prev->e_cache;
4656 + unsigned int bucket = key % cache->c_bucket_count;
4657 + struct list_head *l;
4658 + struct mb_cache_entry *ce;
4660 + mb_assert(index < mb_cache_indexes(cache));
4661 + spin_lock(&mb_cache_spinlock);
4662 + l = prev->e_indexes[index].o_list.next;
4663 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4665 + __mb_cache_entry_release_unlock(prev);
4669 +#endif /* !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0) */
4671 +static int __init init_mbcache(void)
4673 + register_cache(&mb_cache_definition);
4677 +static void __exit exit_mbcache(void)
4679 + unregister_cache(&mb_cache_definition);
4682 +module_init(init_mbcache)
4683 +module_exit(exit_mbcache)
4685 --- linux-2.4.20/include/asm-arm/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4686 +++ linux-2.4.20-root/include/asm-arm/unistd.h 2003-05-07 18:08:03.000000000 +0800
4688 #define __NR_security (__NR_SYSCALL_BASE+223)
4689 #define __NR_gettid (__NR_SYSCALL_BASE+224)
4690 #define __NR_readahead (__NR_SYSCALL_BASE+225)
4691 -#if 0 /* allocated in 2.5 */
4692 #define __NR_setxattr (__NR_SYSCALL_BASE+226)
4693 #define __NR_lsetxattr (__NR_SYSCALL_BASE+227)
4694 #define __NR_fsetxattr (__NR_SYSCALL_BASE+228)
4696 #define __NR_removexattr (__NR_SYSCALL_BASE+235)
4697 #define __NR_lremovexattr (__NR_SYSCALL_BASE+236)
4698 #define __NR_fremovexattr (__NR_SYSCALL_BASE+237)
4700 #define __NR_tkill (__NR_SYSCALL_BASE+238)
4702 * Please check 2.5 _before_ adding calls here,
4703 --- linux-2.4.20/include/asm-ia64/unistd.h~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
4704 +++ linux-2.4.20-root/include/asm-ia64/unistd.h 2003-05-07 18:08:03.000000000 +0800
4705 @@ -206,8 +206,19 @@
4706 #define __NR_getdents64 1214
4707 #define __NR_getunwind 1215
4708 #define __NR_readahead 1216
4709 +#define __NR_setxattr 1217
4710 +#define __NR_lsetxattr 1218
4711 +#define __NR_fsetxattr 1219
4712 +#define __NR_getxattr 1220
4713 +#define __NR_lgetxattr 1221
4714 +#define __NR_fgetxattr 1222
4715 +#define __NR_listxattr 1223
4716 +#define __NR_llistxattr 1224
4717 +#define __NR_flistxattr 1225
4718 +#define __NR_removexattr 1226
4719 +#define __NR_lremovexattr 1227
4720 +#define __NR_fremovexattr 1228
4722 - * 1217-1228: reserved for xattr
4723 * 1230-1232: reserved for futex and sched_[sg]etaffinity.
4725 #define __NR_tkill 1229
4726 --- linux-2.4.20/include/asm-ppc64/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4727 +++ linux-2.4.20-root/include/asm-ppc64/unistd.h 2003-05-07 18:08:03.000000000 +0800
4729 #define __NR_gettid 207
4730 #if 0 /* Reserved syscalls */
4731 #define __NR_tkill 208
4733 #define __NR_setxattr 209
4734 #define __NR_lsetxattr 210
4735 #define __NR_fsetxattr 211
4737 #define __NR_removexattr 218
4738 #define __NR_lremovexattr 219
4739 #define __NR_fremovexattr 220
4740 +#if 0 /* Reserved syscalls */
4741 #define __NR_futex 221
4744 --- linux-2.4.20/include/asm-s390/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4745 +++ linux-2.4.20-root/include/asm-s390/unistd.h 2003-05-07 18:08:03.000000000 +0800
4746 @@ -212,9 +212,18 @@
4747 #define __NR_madvise 219
4748 #define __NR_getdents64 220
4749 #define __NR_fcntl64 221
4751 - * Numbers 224-235 are reserved for posix acl
4753 +#define __NR_setxattr 224
4754 +#define __NR_lsetxattr 225
4755 +#define __NR_fsetxattr 226
4756 +#define __NR_getxattr 227
4757 +#define __NR_lgetxattr 228
4758 +#define __NR_fgetxattr 229
4759 +#define __NR_listxattr 230
4760 +#define __NR_llistxattr 231
4761 +#define __NR_flistxattr 232
4762 +#define __NR_removexattr 233
4763 +#define __NR_lremovexattr 234
4764 +#define __NR_fremovexattr 235
4765 #define __NR_gettid 236
4766 #define __NR_tkill 237
4768 --- linux-2.4.20/include/asm-s390x/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4769 +++ linux-2.4.20-root/include/asm-s390x/unistd.h 2003-05-07 18:08:03.000000000 +0800
4770 @@ -180,9 +180,18 @@
4771 #define __NR_pivot_root 217
4772 #define __NR_mincore 218
4773 #define __NR_madvise 219
4775 - * Numbers 224-235 are reserved for posix acl
4777 +#define __NR_setxattr 224
4778 +#define __NR_lsetxattr 225
4779 +#define __NR_fsetxattr 226
4780 +#define __NR_getxattr 227
4781 +#define __NR_lgetxattr 228
4782 +#define __NR_fgetxattr 229
4783 +#define __NR_listxattr 230
4784 +#define __NR_llistxattr 231
4785 +#define __NR_flistxattr 232
4786 +#define __NR_removexattr 233
4787 +#define __NR_lremovexattr 234
4788 +#define __NR_fremovexattr 235
4789 #define __NR_gettid 236
4790 #define __NR_tkill 237
4792 --- linux-2.4.20/include/asm-sparc/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4793 +++ linux-2.4.20-root/include/asm-sparc/unistd.h 2003-05-07 18:08:03.000000000 +0800
4794 @@ -184,24 +184,24 @@
4795 /* #define __NR_exportfs 166 SunOS Specific */
4796 #define __NR_mount 167 /* Common */
4797 #define __NR_ustat 168 /* Common */
4798 -/* #define __NR_semsys 169 SunOS Specific */
4799 -/* #define __NR_msgsys 170 SunOS Specific */
4800 -/* #define __NR_shmsys 171 SunOS Specific */
4801 -/* #define __NR_auditsys 172 SunOS Specific */
4802 -/* #define __NR_rfssys 173 SunOS Specific */
4803 +#define __NR_setxattr 169 /* SunOS: semsys */
4804 +#define __NR_lsetxattr 170 /* SunOS: msgsys */
4805 +#define __NR_fsetxattr 171 /* SunOS: shmsys */
4806 +#define __NR_getxattr 172 /* SunOS: auditsys */
4807 +#define __NR_lgetxattr 173 /* SunOS: rfssys */
4808 #define __NR_getdents 174 /* Common */
4809 #define __NR_setsid 175 /* Common */
4810 #define __NR_fchdir 176 /* Common */
4811 -/* #define __NR_fchroot 177 SunOS Specific */
4812 -/* #define __NR_vpixsys 178 SunOS Specific */
4813 -/* #define __NR_aioread 179 SunOS Specific */
4814 -/* #define __NR_aiowrite 180 SunOS Specific */
4815 -/* #define __NR_aiowait 181 SunOS Specific */
4816 -/* #define __NR_aiocancel 182 SunOS Specific */
4817 +#define __NR_fgetxattr 177 /* SunOS: fchroot */
4818 +#define __NR_listxattr 178 /* SunOS: vpixsys */
4819 +#define __NR_llistxattr 179 /* SunOS: aioread */
4820 +#define __NR_flistxattr 180 /* SunOS: aiowrite */
4821 +#define __NR_removexattr 181 /* SunOS: aiowait */
4822 +#define __NR_lremovexattr 182 /* SunOS: aiocancel */
4823 #define __NR_sigpending 183 /* Common */
4824 #define __NR_query_module 184 /* Linux Specific */
4825 #define __NR_setpgid 185 /* Common */
4826 -/* #define __NR_pathconf 186 SunOS Specific */
4827 +#define __NR_fremovexattr 186 /* SunOS: pathconf */
4828 #define __NR_tkill 187 /* SunOS: fpathconf */
4829 /* #define __NR_sysconf 188 SunOS Specific */
4830 #define __NR_uname 189 /* Linux Specific */
4831 --- linux-2.4.20/include/asm-sparc64/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4832 +++ linux-2.4.20-root/include/asm-sparc64/unistd.h 2003-05-07 18:08:03.000000000 +0800
4833 @@ -184,24 +184,24 @@
4834 /* #define __NR_exportfs 166 SunOS Specific */
4835 #define __NR_mount 167 /* Common */
4836 #define __NR_ustat 168 /* Common */
4837 -/* #define __NR_semsys 169 SunOS Specific */
4838 -/* #define __NR_msgsys 170 SunOS Specific */
4839 -/* #define __NR_shmsys 171 SunOS Specific */
4840 -/* #define __NR_auditsys 172 SunOS Specific */
4841 -/* #define __NR_rfssys 173 SunOS Specific */
4842 +#define __NR_setxattr 169 /* SunOS: semsys */
4843 +#define __NR_lsetxattr 170 /* SunOS: msgsys */
4844 +#define __NR_fsetxattr 171 /* SunOS: shmsys */
4845 +#define __NR_getxattr 172 /* SunOS: auditsys */
4846 +#define __NR_lgetxattr 173 /* SunOS: rfssys */
4847 #define __NR_getdents 174 /* Common */
4848 #define __NR_setsid 175 /* Common */
4849 #define __NR_fchdir 176 /* Common */
4850 -/* #define __NR_fchroot 177 SunOS Specific */
4851 -/* #define __NR_vpixsys 178 SunOS Specific */
4852 -/* #define __NR_aioread 179 SunOS Specific */
4853 -/* #define __NR_aiowrite 180 SunOS Specific */
4854 -/* #define __NR_aiowait 181 SunOS Specific */
4855 -/* #define __NR_aiocancel 182 SunOS Specific */
4856 +#define __NR_fgetxattr 177 /* SunOS: fchroot */
4857 +#define __NR_listxattr 178 /* SunOS: vpixsys */
4858 +#define __NR_llistxattr 179 /* SunOS: aioread */
4859 +#define __NR_flistxattr 180 /* SunOS: aiowrite */
4860 +#define __NR_removexattr 181 /* SunOS: aiowait */
4861 +#define __NR_lremovexattr 182 /* SunOS: aiocancel */
4862 #define __NR_sigpending 183 /* Common */
4863 #define __NR_query_module 184 /* Linux Specific */
4864 #define __NR_setpgid 185 /* Common */
4865 -/* #define __NR_pathconf 186 SunOS Specific */
4866 +#define __NR_fremovexattr 186 /* SunOS: pathconf */
4867 #define __NR_tkill 187 /* SunOS: fpathconf */
4868 /* #define __NR_sysconf 188 SunOS Specific */
4869 #define __NR_uname 189 /* Linux Specific */
4870 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4871 +++ linux-2.4.20-root/include/linux/cache_def.h 2003-05-07 18:08:03.000000000 +0800
4874 + * linux/cache_def.h
4875 + * Handling of caches defined in drivers, filesystems, ...
4877 + * Copyright (C) 2002 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
4880 +struct cache_definition {
4882 + void (*shrink)(int, unsigned int);
4883 + struct list_head link;
4886 +extern void register_cache(struct cache_definition *);
4887 +extern void unregister_cache(struct cache_definition *);
4888 --- linux-2.4.20/include/linux/errno.h~linux-2.4.20-xattr-0.8.54 2003-04-14 16:39:03.000000000 +0800
4889 +++ linux-2.4.20-root/include/linux/errno.h 2003-05-07 18:08:03.000000000 +0800
4894 +/* Defined for extended attributes */
4895 +#define ENOATTR ENODATA /* No such attribute */
4896 +#define ENOTSUP EOPNOTSUPP /* Operation not supported */
4899 --- linux-2.4.20/include/linux/ext2_fs.h~linux-2.4.20-xattr-0.8.54 2003-04-14 16:39:08.000000000 +0800
4900 +++ linux-2.4.20-root/include/linux/ext2_fs.h 2003-05-07 18:08:03.000000000 +0800
4903 #define EXT2_BAD_INO 1 /* Bad blocks inode */
4904 #define EXT2_ROOT_INO 2 /* Root inode */
4905 -#define EXT2_ACL_IDX_INO 3 /* ACL inode */
4906 -#define EXT2_ACL_DATA_INO 4 /* ACL inode */
4907 #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
4908 #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
4912 # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
4914 -#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
4915 #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
4917 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
4918 @@ -121,28 +118,6 @@
4924 -struct ext2_acl_header /* Header of Access Control Lists */
4927 - __u32 aclh_file_count;
4928 - __u32 aclh_acle_count;
4929 - __u32 aclh_first_acle;
4932 -struct ext2_acl_entry /* Access Control List Entry */
4935 - __u16 acle_perms; /* Access permissions */
4936 - __u16 acle_type; /* Type of entry */
4937 - __u16 acle_tag; /* User or group identity */
4939 - __u32 acle_next; /* Pointer on next entry for the */
4940 - /* same inode or on next free entry */
4944 * Structure of a blocks group descriptor
4946 struct ext2_group_desc
4947 @@ -314,6 +289,7 @@ struct ext2_inode {
4948 #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
4949 #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
4950 #define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
4951 +#define EXT2_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
4953 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
4954 #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
4955 @@ -397,6 +373,7 @@ struct ext2_super_block {
4958 #define EXT2_SB(sb) (&((sb)->u.ext2_sb))
4959 +#define EXT2_I(inode) (&((inode)->u.ext2_i))
4961 /* Assume that user mode programs are passing in an ext2fs superblock, not
4962 * a kernel struct super_block. This will allow us to call the feature-test
4963 @@ -466,7 +443,7 @@ struct ext2_super_block {
4964 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
4965 #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
4967 -#define EXT2_FEATURE_COMPAT_SUPP 0
4968 +#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
4969 #define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE
4970 #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
4971 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
4972 @@ -623,8 +600,10 @@ extern struct address_space_operations e
4975 extern struct inode_operations ext2_dir_inode_operations;
4976 +extern struct inode_operations ext2_special_inode_operations;
4979 +extern struct inode_operations ext2_symlink_inode_operations;
4980 extern struct inode_operations ext2_fast_symlink_inode_operations;
4982 #endif /* __KERNEL__ */
4983 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4984 +++ linux-2.4.20-root/include/linux/ext2_xattr.h 2003-05-07 18:08:03.000000000 +0800
4987 + File: linux/ext2_xattr.h
4989 + On-disk format of extended attributes for the ext2 filesystem.
4991 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
4994 +#include <linux/config.h>
4995 +#include <linux/init.h>
4996 +#include <linux/xattr.h>
4998 +/* Magic value in attribute blocks */
4999 +#define EXT2_XATTR_MAGIC 0xEA020000
5001 +/* Maximum number of references to one attribute block */
5002 +#define EXT2_XATTR_REFCOUNT_MAX 1024
5005 +#define EXT2_XATTR_INDEX_MAX 10
5006 +#define EXT2_XATTR_INDEX_USER 1
5007 +#define EXT2_XATTR_INDEX_POSIX_ACL_ACCESS 2
5008 +#define EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT 3
5010 +struct ext2_xattr_header {
5011 + __u32 h_magic; /* magic number for identification */
5012 + __u32 h_refcount; /* reference count */
5013 + __u32 h_blocks; /* number of disk blocks used */
5014 + __u32 h_hash; /* hash value of all attributes */
5015 + __u32 h_reserved[4]; /* zero right now */
5018 +struct ext2_xattr_entry {
5019 + __u8 e_name_len; /* length of name */
5020 + __u8 e_name_index; /* attribute name index */
5021 + __u16 e_value_offs; /* offset in disk block of value */
5022 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
5023 + __u32 e_value_size; /* size of attribute value */
5024 + __u32 e_hash; /* hash value of name and value */
5025 + char e_name[0]; /* attribute name */
5028 +#define EXT2_XATTR_PAD_BITS 2
5029 +#define EXT2_XATTR_PAD (1<<EXT2_XATTR_PAD_BITS)
5030 +#define EXT2_XATTR_ROUND (EXT2_XATTR_PAD-1)
5031 +#define EXT2_XATTR_LEN(name_len) \
5032 + (((name_len) + EXT2_XATTR_ROUND + \
5033 + sizeof(struct ext2_xattr_entry)) & ~EXT2_XATTR_ROUND)
5034 +#define EXT2_XATTR_NEXT(entry) \
5035 + ( (struct ext2_xattr_entry *)( \
5036 + (char *)(entry) + EXT2_XATTR_LEN((entry)->e_name_len)) )
5037 +#define EXT2_XATTR_SIZE(size) \
5038 + (((size) + EXT2_XATTR_ROUND) & ~EXT2_XATTR_ROUND)
5042 +# ifdef CONFIG_EXT2_FS_XATTR
5044 +struct ext2_xattr_handler {
5046 + size_t (*list)(char *list, struct inode *inode, const char *name,
5048 + int (*get)(struct inode *inode, const char *name, void *buffer,
5050 + int (*set)(struct inode *inode, const char *name, const void *buffer,
5051 + size_t size, int flags);
5054 +extern int ext2_xattr_register(int, struct ext2_xattr_handler *);
5055 +extern void ext2_xattr_unregister(int, struct ext2_xattr_handler *);
5057 +extern int ext2_setxattr(struct dentry *, const char *, const void *, size_t, int);
5058 +extern ssize_t ext2_getxattr(struct dentry *, const char *, void *, size_t);
5059 +extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
5060 +extern int ext2_removexattr(struct dentry *, const char *);
5062 +extern int ext2_xattr_get(struct inode *, int, const char *, void *, size_t);
5063 +extern int ext2_xattr_list(struct inode *, char *, size_t);
5064 +extern int ext2_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
5066 +extern void ext2_xattr_delete_inode(struct inode *);
5067 +extern void ext2_xattr_put_super(struct super_block *);
5069 +extern int init_ext2_xattr(void) __init;
5070 +extern void exit_ext2_xattr(void);
5072 +# else /* CONFIG_EXT2_FS_XATTR */
5073 +# define ext2_setxattr NULL
5074 +# define ext2_getxattr NULL
5075 +# define ext2_listxattr NULL
5076 +# define ext2_removexattr NULL
5079 +ext2_xattr_get(struct inode *inode, int name_index,
5080 + const char *name, void *buffer, size_t size)
5086 +ext2_xattr_list(struct inode *inode, char *buffer, size_t size)
5092 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
5093 + const void *value, size_t size, int flags)
5099 +ext2_xattr_delete_inode(struct inode *inode)
5104 +ext2_xattr_put_super(struct super_block *sb)
5109 +init_ext2_xattr(void)
5115 +exit_ext2_xattr(void)
5119 +# endif /* CONFIG_EXT2_FS_XATTR */
5121 +# ifdef CONFIG_EXT2_FS_XATTR_USER
5123 +extern int init_ext2_xattr_user(void) __init;
5124 +extern void exit_ext2_xattr_user(void);
5126 +# else /* CONFIG_EXT2_FS_XATTR_USER */
5129 +init_ext2_xattr_user(void)
5135 +exit_ext2_xattr_user(void)
5139 +# endif /* CONFIG_EXT2_FS_XATTR_USER */
5141 +#endif /* __KERNEL__ */
5143 --- linux-2.4.20/include/linux/ext3_fs.h~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:04.000000000 +0800
5144 +++ linux-2.4.20-root/include/linux/ext3_fs.h 2003-05-07 18:08:03.000000000 +0800
5147 #define EXT3_BAD_INO 1 /* Bad blocks inode */
5148 #define EXT3_ROOT_INO 2 /* Root inode */
5149 -#define EXT3_ACL_IDX_INO 3 /* ACL inode */
5150 -#define EXT3_ACL_DATA_INO 4 /* ACL inode */
5151 #define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
5152 #define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
5153 #define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
5156 # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
5158 -#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
5159 #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
5161 # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
5162 @@ -129,28 +126,6 @@
5168 -struct ext3_acl_header /* Header of Access Control Lists */
5171 - __u32 aclh_file_count;
5172 - __u32 aclh_acle_count;
5173 - __u32 aclh_first_acle;
5176 -struct ext3_acl_entry /* Access Control List Entry */
5179 - __u16 acle_perms; /* Access permissions */
5180 - __u16 acle_type; /* Type of entry */
5181 - __u16 acle_tag; /* User or group identity */
5183 - __u32 acle_next; /* Pointer on next entry for the */
5184 - /* same inode or on next free entry */
5188 * Structure of a blocks group descriptor
5190 struct ext3_group_desc
5191 @@ -344,6 +319,7 @@ struct ext3_inode {
5192 #define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */
5193 #define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */
5194 #define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
5195 +#define EXT3_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
5197 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
5198 #ifndef _LINUX_EXT2_FS_H
5199 @@ -520,7 +496,7 @@ struct ext3_super_block {
5200 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
5201 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
5203 -#define EXT3_FEATURE_COMPAT_SUPP 0
5204 +#define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
5205 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
5206 EXT3_FEATURE_INCOMPAT_RECOVER)
5207 #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
5208 @@ -703,6 +679,7 @@ extern void ext3_check_inodes_bitmap (st
5209 extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
5212 +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
5213 extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
5214 extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
5216 @@ -771,8 +748,10 @@ extern struct address_space_operations e
5219 extern struct inode_operations ext3_dir_inode_operations;
5220 +extern struct inode_operations ext3_special_inode_operations;
5223 +extern struct inode_operations ext3_symlink_inode_operations;
5224 extern struct inode_operations ext3_fast_symlink_inode_operations;
5227 --- linux-2.4.20/include/linux/ext3_jbd.h~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
5228 +++ linux-2.4.20-root/include/linux/ext3_jbd.h 2003-05-07 18:08:03.000000000 +0800
5231 #define EXT3_SINGLEDATA_TRANS_BLOCKS 8
5233 +/* Extended attributes may touch two data buffers, two bitmap buffers,
5234 + * and two group and summaries. */
5236 +#define EXT3_XATTR_TRANS_BLOCKS 8
5238 /* Define the minimum size for a transaction which modifies data. This
5239 * needs to take into account the fact that we may end up modifying two
5240 * quota files too (one for the group, one for the user quota). The
5241 * superblock only gets updated once, of course, so don't bother
5242 * counting that again for the quota updates. */
5244 -#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2)
5245 +#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \
5246 + EXT3_XATTR_TRANS_BLOCKS - 2)
5248 extern int ext3_writepage_trans_blocks(struct inode *inode);
5250 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5251 +++ linux-2.4.20-root/include/linux/ext3_xattr.h 2003-05-07 18:08:03.000000000 +0800
5254 + File: linux/ext3_xattr.h
5256 + On-disk format of extended attributes for the ext3 filesystem.
5258 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5261 +#include <linux/config.h>
5262 +#include <linux/init.h>
5263 +#include <linux/xattr.h>
5265 +/* Magic value in attribute blocks */
5266 +#define EXT3_XATTR_MAGIC 0xEA020000
5268 +/* Maximum number of references to one attribute block */
5269 +#define EXT3_XATTR_REFCOUNT_MAX 1024
5272 +#define EXT3_XATTR_INDEX_MAX 10
5273 +#define EXT3_XATTR_INDEX_USER 1
5274 +#define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS 2
5275 +#define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT 3
5277 +struct ext3_xattr_header {
5278 + __u32 h_magic; /* magic number for identification */
5279 + __u32 h_refcount; /* reference count */
5280 + __u32 h_blocks; /* number of disk blocks used */
5281 + __u32 h_hash; /* hash value of all attributes */
5282 + __u32 h_reserved[4]; /* zero right now */
5285 +struct ext3_xattr_entry {
5286 + __u8 e_name_len; /* length of name */
5287 + __u8 e_name_index; /* attribute name index */
5288 + __u16 e_value_offs; /* offset in disk block of value */
5289 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
5290 + __u32 e_value_size; /* size of attribute value */
5291 + __u32 e_hash; /* hash value of name and value */
5292 + char e_name[0]; /* attribute name */
5295 +#define EXT3_XATTR_PAD_BITS 2
5296 +#define EXT3_XATTR_PAD (1<<EXT3_XATTR_PAD_BITS)
5297 +#define EXT3_XATTR_ROUND (EXT3_XATTR_PAD-1)
5298 +#define EXT3_XATTR_LEN(name_len) \
5299 + (((name_len) + EXT3_XATTR_ROUND + \
5300 + sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
5301 +#define EXT3_XATTR_NEXT(entry) \
5302 + ( (struct ext3_xattr_entry *)( \
5303 + (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
5304 +#define EXT3_XATTR_SIZE(size) \
5305 + (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
5309 +# ifdef CONFIG_EXT3_FS_XATTR
5311 +struct ext3_xattr_handler {
5313 + size_t (*list)(char *list, struct inode *inode, const char *name,
5315 + int (*get)(struct inode *inode, const char *name, void *buffer,
5317 + int (*set)(struct inode *inode, const char *name, const void *buffer,
5318 + size_t size, int flags);
5321 +extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
5322 +extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
5324 +extern int ext3_setxattr(struct dentry *, const char *, const void *, size_t, int);
5325 +extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
5326 +extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
5327 +extern int ext3_removexattr(struct dentry *, const char *);
5329 +extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
5330 +extern int ext3_xattr_list(struct inode *, char *, size_t);
5331 +extern int ext3_xattr_set(handle_t *handle, struct inode *, int, const char *, const void *, size_t, int);
5333 +extern void ext3_xattr_delete_inode(handle_t *, struct inode *);
5334 +extern void ext3_xattr_put_super(struct super_block *);
5336 +extern int init_ext3_xattr(void) __init;
5337 +extern void exit_ext3_xattr(void);
5339 +# else /* CONFIG_EXT3_FS_XATTR */
5340 +# define ext3_setxattr NULL
5341 +# define ext3_getxattr NULL
5342 +# define ext3_listxattr NULL
5343 +# define ext3_removexattr NULL
5346 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
5347 + void *buffer, size_t size)
5353 +ext3_xattr_list(struct inode *inode, void *buffer, size_t size)
5359 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
5360 + const char *name, const void *value, size_t size, int flags)
5366 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
5371 +ext3_xattr_put_super(struct super_block *sb)
5376 +init_ext3_xattr(void)
5382 +exit_ext3_xattr(void)
5386 +# endif /* CONFIG_EXT3_FS_XATTR */
5388 +# ifdef CONFIG_EXT3_FS_XATTR_USER
5390 +extern int init_ext3_xattr_user(void) __init;
5391 +extern void exit_ext3_xattr_user(void);
5393 +# else /* CONFIG_EXT3_FS_XATTR_USER */
5396 +init_ext3_xattr_user(void)
5402 +exit_ext3_xattr_user(void)
5406 +#endif /* CONFIG_EXT3_FS_XATTR_USER */
5408 +#endif /* __KERNEL__ */
5410 --- linux-2.4.20/include/linux/fs.h~linux-2.4.20-xattr-0.8.54 2003-05-05 19:00:55.000000000 +0800
5411 +++ linux-2.4.20-root/include/linux/fs.h 2003-05-07 18:08:03.000000000 +0800
5412 @@ -888,7 +888,7 @@ struct inode_operations {
5413 int (*setattr) (struct dentry *, struct iattr *);
5414 int (*setattr_raw) (struct inode *, struct iattr *);
5415 int (*getattr) (struct dentry *, struct iattr *);
5416 - int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
5417 + int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
5418 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
5419 ssize_t (*listxattr) (struct dentry *, char *, size_t);
5420 int (*removexattr) (struct dentry *, const char *);
5421 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5422 +++ linux-2.4.20-root/include/linux/mbcache.h 2003-05-07 18:08:03.000000000 +0800
5425 + File: linux/mbcache.h
5427 + (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
5430 +/* Hardwire the number of additional indexes */
5431 +#define MB_CACHE_INDEXES_COUNT 1
5433 +struct mb_cache_entry;
5435 +struct mb_cache_op {
5436 + int (*free)(struct mb_cache_entry *, int);
5440 + struct list_head c_cache_list;
5441 + const char *c_name;
5442 + struct mb_cache_op c_op;
5443 + atomic_t c_entry_count;
5444 + int c_bucket_count;
5445 +#ifndef MB_CACHE_INDEXES_COUNT
5446 + int c_indexes_count;
5448 + kmem_cache_t *c_entry_cache;
5449 + struct list_head *c_block_hash;
5450 + struct list_head *c_indexes_hash[0];
5453 +struct mb_cache_entry_index {
5454 + struct list_head o_list;
5455 + unsigned int o_key;
5458 +struct mb_cache_entry {
5459 + struct list_head e_lru_list;
5460 + struct mb_cache *e_cache;
5463 + unsigned long e_block;
5464 + struct list_head e_block_list;
5465 + struct mb_cache_entry_index e_indexes[0];
5468 +/* Functions on caches */
5470 +struct mb_cache * mb_cache_create(const char *, struct mb_cache_op *, size_t,
5472 +void mb_cache_shrink(struct mb_cache *, kdev_t);
5473 +void mb_cache_destroy(struct mb_cache *);
5475 +/* Functions on cache entries */
5477 +struct mb_cache_entry *mb_cache_entry_alloc(struct mb_cache *);
5478 +int mb_cache_entry_insert(struct mb_cache_entry *, kdev_t, unsigned long,
5480 +void mb_cache_entry_rehash(struct mb_cache_entry *, unsigned int[]);
5481 +void mb_cache_entry_release(struct mb_cache_entry *);
5482 +void mb_cache_entry_takeout(struct mb_cache_entry *);
5483 +void mb_cache_entry_free(struct mb_cache_entry *);
5484 +struct mb_cache_entry *mb_cache_entry_dup(struct mb_cache_entry *);
5485 +struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *, kdev_t,
5487 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
5488 +struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache, int,
5489 + kdev_t, unsigned int);
5490 +struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache_entry *, int,
5491 + kdev_t, unsigned int);
5493 --- linux-2.4.20/kernel/ksyms.c~linux-2.4.20-xattr-0.8.54 2003-05-05 17:43:15.000000000 +0800
5494 +++ linux-2.4.20-root/kernel/ksyms.c 2003-05-07 18:08:03.000000000 +0800
5497 #include <linux/config.h>
5498 #include <linux/slab.h>
5499 +#include <linux/cache_def.h>
5500 #include <linux/module.h>
5501 #include <linux/blkdev.h>
5502 #include <linux/cdrom.h>
5503 @@ -89,6 +90,7 @@ EXPORT_SYMBOL(exit_mm);
5504 EXPORT_SYMBOL(exit_files);
5505 EXPORT_SYMBOL(exit_fs);
5506 EXPORT_SYMBOL(exit_sighand);
5507 +EXPORT_SYMBOL(copy_fs_struct);
5509 /* internal kernel memory management */
5510 EXPORT_SYMBOL(_alloc_pages);
5511 @@ -107,6 +109,8 @@ EXPORT_SYMBOL(kmem_cache_validate);
5512 EXPORT_SYMBOL(kmem_cache_alloc);
5513 EXPORT_SYMBOL(kmem_cache_free);
5514 EXPORT_SYMBOL(kmem_cache_size);
5515 +EXPORT_SYMBOL(register_cache);
5516 +EXPORT_SYMBOL(unregister_cache);
5517 EXPORT_SYMBOL(kmalloc);
5518 EXPORT_SYMBOL(kfree);
5519 EXPORT_SYMBOL(vfree);
5520 --- linux-2.4.20/mm/vmscan.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
5521 +++ linux-2.4.20-root/mm/vmscan.c 2003-05-07 18:08:03.000000000 +0800
5523 #include <linux/kernel_stat.h>
5524 #include <linux/swap.h>
5525 #include <linux/swapctl.h>
5526 +#include <linux/cache_def.h>
5527 #include <linux/smp_lock.h>
5528 #include <linux/pagemap.h>
5529 #include <linux/init.h>
5532 #define DEF_PRIORITY (6)
5534 +static DECLARE_MUTEX(other_caches_sem);
5535 +static LIST_HEAD(cache_definitions);
5537 +void register_cache(struct cache_definition *cache)
5539 + down(&other_caches_sem);
5540 + list_add(&cache->link, &cache_definitions);
5541 + up(&other_caches_sem);
5544 +void unregister_cache(struct cache_definition *cache)
5546 + down(&other_caches_sem);
5547 + list_del(&cache->link);
5548 + up(&other_caches_sem);
5551 +static void shrink_other_caches(unsigned int priority, int gfp_mask)
5553 + struct list_head *p;
5555 + if (down_trylock(&other_caches_sem))
5558 + list_for_each_prev(p, &cache_definitions) {
5559 + struct cache_definition *cache =
5560 + list_entry(p, struct cache_definition, link);
5562 + cache->shrink(priority, gfp_mask);
5564 + up(&other_caches_sem);
5568 * The swap-out function returns 1 if it successfully
5569 * scanned all the pages it was asked to (`count').
5570 @@ -577,6 +611,7 @@ static int shrink_caches(zone_t * classz
5572 shrink_dcache_memory(priority, gfp_mask);
5573 shrink_icache_memory(priority, gfp_mask);
5574 + shrink_other_caches(priority, gfp_mask);
5576 shrink_dqcache_memory(DEF_PRIORITY, gfp_mask);
5578 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5579 +++ linux-root/fs/ext3/ext3-exports.c 2003-05-05 18:19:11.000000000 +0800
5581 +#include <linux/config.h>
5582 +#include <linux/module.h>
5583 +#include <linux/ext3_fs.h>
5584 +#include <linux/ext3_jbd.h>
5585 +#include <linux/ext3_xattr.h>
5587 +EXPORT_SYMBOL(ext3_force_commit);
5588 +EXPORT_SYMBOL(ext3_bread);
5589 +EXPORT_SYMBOL(ext3_xattr_register);
5590 +EXPORT_SYMBOL(ext3_xattr_unregister);
5591 +EXPORT_SYMBOL(ext3_xattr_get);
5592 +EXPORT_SYMBOL(ext3_xattr_list);
5593 +EXPORT_SYMBOL(ext3_xattr_set);