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=y
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=y
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=y
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=y
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=y
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=y
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=y
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=y
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_UID16 is not set
362 # CONFIG_RWSEM_GENERIC_SPINLOCK is not set
363 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
364 --- 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
365 +++ linux-2.4.20-root/arch/ppc64/kernel/misc.S 2003-05-07 18:08:03.000000000 +0800
366 @@ -731,6 +731,7 @@ _GLOBAL(sys_call_table32)
367 .llong .sys_gettid /* 207 */
368 #if 0 /* Reserved syscalls */
369 .llong .sys_tkill /* 208 */
372 .llong .sys_lsetxattr /* 210 */
373 .llong .sys_fsetxattr
374 @@ -743,6 +744,7 @@ _GLOBAL(sys_call_table32)
375 .llong .sys_removexattr
376 .llong .sys_lremovexattr
377 .llong .sys_fremovexattr /* 220 */
378 +#if 0 /* Reserved syscalls */
381 .llong .sys_perfmonctl /* Put this here for now ... */
382 --- linux-2.4.20/arch/s390/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
383 +++ linux-2.4.20-root/arch/s390/defconfig 2003-05-07 18:08:03.000000000 +0800
386 # Automatically generated make config: don't edit
388 +CONFIG_EXT3_FS_XATTR=y
389 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
390 +# CONFIG_EXT3_FS_XATTR_USER is not set
391 +# CONFIG_EXT2_FS_XATTR is not set
392 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
393 +# CONFIG_EXT2_FS_XATTR_USER is not set
394 +# CONFIG_FS_MBCACHE is not set
395 # CONFIG_ISA is not set
396 # CONFIG_EISA is not set
397 # CONFIG_MCA is not set
398 --- 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
399 +++ linux-2.4.20-root/arch/s390/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
400 @@ -558,18 +558,18 @@ sys_call_table:
404 - .long sys_ni_syscall /* 224 - reserved for setxattr */
405 - .long sys_ni_syscall /* 225 - reserved for lsetxattr */
406 - .long sys_ni_syscall /* 226 - reserved for fsetxattr */
407 - .long sys_ni_syscall /* 227 - reserved for getxattr */
408 - .long sys_ni_syscall /* 228 - reserved for lgetxattr */
409 - .long sys_ni_syscall /* 229 - reserved for fgetxattr */
410 - .long sys_ni_syscall /* 230 - reserved for listxattr */
411 - .long sys_ni_syscall /* 231 - reserved for llistxattr */
412 - .long sys_ni_syscall /* 232 - reserved for flistxattr */
413 - .long sys_ni_syscall /* 233 - reserved for removexattr */
414 - .long sys_ni_syscall /* 234 - reserved for lremovexattr */
415 - .long sys_ni_syscall /* 235 - reserved for fremovexattr */
417 + .long sys_lsetxattr /* 225 */
418 + .long sys_fsetxattr
420 + .long sys_lgetxattr
421 + .long sys_fgetxattr
422 + .long sys_listxattr /* 230 */
423 + .long sys_llistxattr
424 + .long sys_flistxattr
425 + .long sys_removexattr
426 + .long sys_lremovexattr
427 + .long sys_fremovexattr /* 235 */
431 --- linux-2.4.20/arch/s390x/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
432 +++ linux-2.4.20-root/arch/s390x/defconfig 2003-05-07 18:08:03.000000000 +0800
435 # Automatically generated make config: don't edit
437 +CONFIG_EXT3_FS_XATTR=y
438 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
439 +# CONFIG_EXT3_FS_XATTR_USER is not set
440 +# CONFIG_EXT2_FS_XATTR is not set
441 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
442 +# CONFIG_EXT2_FS_XATTR_USER is not set
443 +# CONFIG_FS_MBCACHE is not set
444 # CONFIG_ISA is not set
445 # CONFIG_EISA is not set
446 # CONFIG_MCA is not set
447 --- 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
448 +++ linux-2.4.20-root/arch/s390x/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
449 @@ -591,18 +591,18 @@ sys_call_table:
450 .long SYSCALL(sys_ni_syscall,sys32_fcntl64_wrapper)
451 .long SYSCALL(sys_ni_syscall,sys_ni_syscall)
452 .long SYSCALL(sys_ni_syscall,sys_ni_syscall)
453 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 224 - reserved for setxattr */
454 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 225 - reserved for lsetxattr */
455 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 226 - reserved for fsetxattr */
456 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 227 - reserved for getxattr */
457 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 228 - reserved for lgetxattr */
458 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 229 - reserved for fgetxattr */
459 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 230 - reserved for listxattr */
460 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 231 - reserved for llistxattr */
461 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 232 - reserved for flistxattr */
462 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 233 - reserved for removexattr */
463 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 234 - reserved for lremovexattr */
464 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 235 - reserved for fremovexattr */
465 + .long SYSCALL(sys_setxattr,sys32_setxattr_wrapper)
466 + .long SYSCALL(sys_lsetxattr,sys32_lsetxattr_wrapper) /* 225 */
467 + .long SYSCALL(sys_fsetxattr,sys32_fsetxattr_wrapper)
468 + .long SYSCALL(sys_getxattr,sys32_getxattr_wrapper)
469 + .long SYSCALL(sys_lgetxattr,sys32_lgetxattr_wrapper)
470 + .long SYSCALL(sys_fgetxattr,sys32_fgetxattr_wrapper)
471 + .long SYSCALL(sys_listxattr,sys32_listxattr_wrapper) /* 230 */
472 + .long SYSCALL(sys_llistxattr,sys32_llistxattr_wrapper)
473 + .long SYSCALL(sys_flistxattr,sys32_flistxattr_wrapper)
474 + .long SYSCALL(sys_removexattr,sys32_removexattr_wrapper)
475 + .long SYSCALL(sys_lremovexattr,sys32_lremovexattr_wrapper)
476 + .long SYSCALL(sys_fremovexattr,sys32_fremovexattr_wrapper)/* 235 */
477 .long SYSCALL(sys_gettid,sys_gettid)
478 .long SYSCALL(sys_tkill,sys_tkill)
480 --- 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
481 +++ linux-2.4.20-root/arch/s390x/kernel/wrapper32.S 2003-05-07 18:08:03.000000000 +0800
482 @@ -1091,3 +1091,95 @@ sys32_fstat64_wrapper:
483 llgtr %r3,%r3 # struct stat64 *
485 jg sys32_fstat64 # branch to system call
487 + .globl sys32_setxattr_wrapper
488 +sys32_setxattr_wrapper:
489 + llgtr %r2,%r2 # char *
490 + llgtr %r3,%r3 # char *
491 + llgtr %r4,%r4 # void *
492 + llgfr %r5,%r5 # size_t
496 + .globl sys32_lsetxattr_wrapper
497 +sys32_lsetxattr_wrapper:
498 + llgtr %r2,%r2 # char *
499 + llgtr %r3,%r3 # char *
500 + llgtr %r4,%r4 # void *
501 + llgfr %r5,%r5 # size_t
505 + .globl sys32_fsetxattr_wrapper
506 +sys32_fsetxattr_wrapper:
508 + llgtr %r3,%r3 # char *
509 + llgtr %r4,%r4 # void *
510 + llgfr %r5,%r5 # size_t
514 + .globl sys32_getxattr_wrapper
515 +sys32_getxattr_wrapper:
516 + llgtr %r2,%r2 # char *
517 + llgtr %r3,%r3 # char *
518 + llgtr %r4,%r4 # void *
519 + llgfr %r5,%r5 # size_t
522 + .globl sys32_lgetxattr_wrapper
523 +sys32_lgetxattr_wrapper:
524 + llgtr %r2,%r2 # char *
525 + llgtr %r3,%r3 # char *
526 + llgtr %r4,%r4 # void *
527 + llgfr %r5,%r5 # size_t
530 + .globl sys32_fgetxattr_wrapper
531 +sys32_fgetxattr_wrapper:
533 + llgtr %r3,%r3 # char *
534 + llgtr %r4,%r4 # void *
535 + llgfr %r5,%r5 # size_t
538 + .globl sys32_listxattr_wrapper
539 +sys32_listxattr_wrapper:
540 + llgtr %r2,%r2 # char *
541 + llgtr %r3,%r3 # char *
542 + llgfr %r4,%r4 # size_t
545 + .globl sys32_llistxattr_wrapper
546 +sys32_llistxattr_wrapper:
547 + llgtr %r2,%r2 # char *
548 + llgtr %r3,%r3 # char *
549 + llgfr %r4,%r4 # size_t
552 + .globl sys32_flistxattr_wrapper
553 +sys32_flistxattr_wrapper:
555 + llgtr %r3,%r3 # char *
556 + llgfr %r4,%r4 # size_t
559 + .globl sys32_removexattr_wrapper
560 +sys32_removexattr_wrapper:
561 + llgtr %r2,%r2 # char *
562 + llgtr %r3,%r3 # char *
565 + .globl sys32_lremovexattr_wrapper
566 +sys32_lremovexattr_wrapper:
567 + llgtr %r2,%r2 # char *
568 + llgtr %r3,%r3 # char *
569 + jg sys_lremovexattr
571 + .globl sys32_fremovexattr_wrapper
572 +sys32_fremovexattr_wrapper:
574 + llgtr %r3,%r3 # char *
575 + jg sys_fremovexattr
578 --- linux-2.4.20/arch/sparc/defconfig~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:43.000000000 +0800
579 +++ linux-2.4.20-root/arch/sparc/defconfig 2003-05-07 18:08:03.000000000 +0800
582 # Automatically generated make config: don't edit
584 +CONFIG_EXT3_FS_XATTR=y
585 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
586 +# CONFIG_EXT3_FS_XATTR_USER is not set
587 +# CONFIG_EXT2_FS_XATTR is not set
588 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
589 +# CONFIG_EXT2_FS_XATTR_USER is not set
590 +# CONFIG_FS_MBCACHE is not set
594 --- 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
595 +++ linux-2.4.20-root/arch/sparc/kernel/systbls.S 2003-05-07 18:08:03.000000000 +0800
596 @@ -51,11 +51,11 @@ sys_call_table:
597 /*150*/ .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
598 /*155*/ .long sys_fcntl64, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
599 /*160*/ .long sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
600 -/*165*/ .long sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_nis_syscall
601 -/*170*/ .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getdents
602 -/*175*/ .long sys_setsid, sys_fchdir, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
603 -/*180*/ .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_sigpending, sys_query_module
604 -/*185*/ .long sys_setpgid, sys_nis_syscall, sys_tkill, sys_nis_syscall, sys_newuname
605 +/*165*/ .long sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_setxattr
606 +/*170*/ .long sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys_getdents
607 +/*175*/ .long sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr
608 +/*180*/ .long sys_flistxattr, sys_removexattr, sys_lremovexattr, sys_sigpending, sys_query_module
609 +/*185*/ .long sys_setpgid, sys_fremovexattr, sys_tkill, sys_nis_syscall, sys_newuname
610 /*190*/ .long sys_init_module, sys_personality, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
611 /*195*/ .long sys_nis_syscall, sys_nis_syscall, sys_getppid, sparc_sigaction, sys_sgetmask
612 /*200*/ .long sys_ssetmask, sys_sigsuspend, sys_newlstat, sys_uselib, old_readdir
613 --- linux-2.4.20/arch/sparc64/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:12.000000000 +0800
614 +++ linux-2.4.20-root/arch/sparc64/defconfig 2003-05-07 18:08:03.000000000 +0800
617 # Automatically generated make config: don't edit
619 +CONFIG_EXT3_FS_XATTR=y
620 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
621 +# CONFIG_EXT3_FS_XATTR_USER is not set
622 +# CONFIG_EXT2_FS_XATTR is not set
623 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
624 +# CONFIG_EXT2_FS_XATTR_USER is not set
625 +# CONFIG_FS_MBCACHE is not set
628 # Code maturity level options
629 --- 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
630 +++ linux-2.4.20-root/arch/sparc64/kernel/systbls.S 2003-05-07 18:08:03.000000000 +0800
631 @@ -52,11 +52,11 @@ sys_call_table32:
632 /*150*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
633 .word sys32_fcntl64, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
634 /*160*/ .word sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
635 - .word sys32_quotactl, sys_nis_syscall, sys32_mount, sys_ustat, sys_nis_syscall
636 -/*170*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getdents
637 - .word sys_setsid, sys_fchdir, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
638 -/*180*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_sigpending, sys32_query_module
639 - .word sys_setpgid, sys_nis_syscall, sys_tkill, sys_nis_syscall, sparc64_newuname
640 + .word sys32_quotactl, sys_nis_syscall, sys32_mount, sys_ustat, sys_setxattr
641 +/*170*/ .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys32_getdents
642 + .word sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr
643 +/*180*/ .word sys_flistxattr, sys_removexattr, sys_lremovexattr, sys32_sigpending, sys32_query_module
644 + .word sys_setpgid, sys_fremovexattr, sys_tkill, sys_nis_syscall, sparc64_newuname
645 /*190*/ .word sys32_init_module, sparc64_personality, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
646 .word sys_nis_syscall, sys_nis_syscall, sys_getppid, sys32_sigaction, sys_sgetmask
647 /*200*/ .word sys_ssetmask, sys_sigsuspend, sys32_newlstat, sys_uselib, old32_readdir
648 @@ -111,11 +111,11 @@ sys_call_table:
649 /*150*/ .word sys_getsockname, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
650 .word sys_nis_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
651 /*160*/ .word sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_utrap_install
652 - .word sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_nis_syscall
653 -/*170*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getdents
654 - .word sys_setsid, sys_fchdir, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
655 -/*180*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_query_module
656 - .word sys_setpgid, sys_nis_syscall, sys_tkill, sys_nis_syscall, sparc64_newuname
657 + .word sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_setxattr
658 +/*170*/ .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys_getdents
659 + .word sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr
660 +/*180*/ .word sys_flistxattr, sys_removexattr, sys_lremovexattr, sys_nis_syscall, sys_query_module
661 + .word sys_setpgid, sys_fremovexattr, sys_tkill, sys_nis_syscall, sparc64_newuname
662 /*190*/ .word sys_init_module, sparc64_personality, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
663 .word sys_nis_syscall, sys_nis_syscall, sys_getppid, sys_nis_syscall, sys_sgetmask
664 /*200*/ .word sys_ssetmask, sys_nis_syscall, sys_newlstat, sys_uselib, sys_nis_syscall
665 --- linux-2.4.20/fs/Config.in~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
666 +++ linux-2.4.20-root/fs/Config.in 2003-05-07 18:08:03.000000000 +0800
667 @@ -25,6 +25,11 @@ dep_mbool ' Debug Befs' CONFIG_BEFS_DEB
668 dep_tristate 'BFS file system support (EXPERIMENTAL)' CONFIG_BFS_FS $CONFIG_EXPERIMENTAL
670 tristate 'Ext3 journalling file system support' CONFIG_EXT3_FS
671 +dep_mbool ' Ext3 extended attributes' CONFIG_EXT3_FS_XATTR $CONFIG_EXT3_FS
672 +dep_bool ' Ext3 extended attribute block sharing' \
673 + CONFIG_EXT3_FS_XATTR_SHARING $CONFIG_EXT3_FS_XATTR
674 +dep_bool ' Ext3 extended user attributes' \
675 + CONFIG_EXT3_FS_XATTR_USER $CONFIG_EXT3_FS_XATTR
676 # CONFIG_JBD could be its own option (even modular), but until there are
677 # other users than ext3, we will simply make it be the same as CONFIG_EXT3_FS
678 # dep_tristate ' Journal Block Device support (JBD for ext3)' CONFIG_JBD $CONFIG_EXT3_FS
679 @@ -84,6 +89,11 @@ dep_mbool ' QNX4FS write support (DANGE
680 tristate 'ROM file system support' CONFIG_ROMFS_FS
682 tristate 'Second extended fs support' CONFIG_EXT2_FS
683 +dep_mbool ' Ext2 extended attributes' CONFIG_EXT2_FS_XATTR $CONFIG_EXT2_FS
684 +dep_bool ' Ext2 extended attribute block sharing' \
685 + CONFIG_EXT2_FS_XATTR_SHARING $CONFIG_EXT2_FS_XATTR
686 +dep_bool ' Ext2 extended user attributes' \
687 + CONFIG_EXT2_FS_XATTR_USER $CONFIG_EXT2_FS_XATTR
689 tristate 'System V/Xenix/V7/Coherent file system support' CONFIG_SYSV_FS
691 @@ -155,6 +165,10 @@ else
692 define_tristate CONFIG_ZISOFS_FS n
695 +# Meta block cache for Extended Attributes (ext2/ext3)
696 +#tristate 'Meta block cache' CONFIG_FS_MBCACHE
697 +define_tristate CONFIG_FS_MBCACHE y
699 mainmenu_option next_comment
700 comment 'Partition Types'
701 source fs/partitions/Config.in
702 --- linux-2.4.20/fs/Makefile~linux-2.4.20-xattr-0.8.54 2003-05-05 19:00:58.000000000 +0800
703 +++ linux-2.4.20-root/fs/Makefile 2003-05-07 18:08:03.000000000 +0800
704 @@ -79,6 +79,9 @@ obj-y += binfmt_script.o
706 obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
708 +export-objs += mbcache.o
709 +obj-$(CONFIG_FS_MBCACHE) += mbcache.o
711 # persistent filesystems
712 obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
714 --- linux-2.4.20/fs/ext2/Makefile~linux-2.4.20-xattr-0.8.54 2001-10-11 23:05:18.000000000 +0800
715 +++ linux-2.4.20-root/fs/ext2/Makefile 2003-05-07 18:08:03.000000000 +0800
716 @@ -13,4 +13,8 @@ obj-y := balloc.o bitmap.o dir.o file
717 ioctl.o namei.o super.o symlink.o
720 +export-objs += xattr.o
721 +obj-$(CONFIG_EXT2_FS_XATTR) += xattr.o
722 +obj-$(CONFIG_EXT2_FS_XATTR_USER) += xattr_user.o
724 include $(TOPDIR)/Rules.make
725 --- linux-2.4.20/fs/ext2/file.c~linux-2.4.20-xattr-0.8.54 2001-10-11 23:05:18.000000000 +0800
726 +++ linux-2.4.20-root/fs/ext2/file.c 2003-05-07 18:08:03.000000000 +0800
729 #include <linux/fs.h>
730 #include <linux/ext2_fs.h>
731 +#include <linux/ext2_xattr.h>
732 #include <linux/sched.h>
735 @@ -51,4 +52,8 @@ struct file_operations ext2_file_operati
737 struct inode_operations ext2_file_inode_operations = {
738 truncate: ext2_truncate,
739 + setxattr: ext2_setxattr,
740 + getxattr: ext2_getxattr,
741 + listxattr: ext2_listxattr,
742 + removexattr: ext2_removexattr,
744 --- linux-2.4.20/fs/ext2/ialloc.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
745 +++ linux-2.4.20-root/fs/ext2/ialloc.c 2003-05-07 18:08:03.000000000 +0800
747 #include <linux/config.h>
748 #include <linux/fs.h>
749 #include <linux/ext2_fs.h>
750 +#include <linux/ext2_xattr.h>
751 #include <linux/locks.h>
752 #include <linux/quotaops.h>
754 @@ -167,6 +168,7 @@ void ext2_free_inode (struct inode * ino
756 if (!is_bad_inode(inode)) {
757 /* Quota is already initialized in iput() */
758 + ext2_xattr_delete_inode(inode);
759 DQUOT_FREE_INODE(inode);
762 --- linux-2.4.20/fs/ext2/inode.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
763 +++ linux-2.4.20-root/fs/ext2/inode.c 2003-05-07 18:08:03.000000000 +0800
764 @@ -39,6 +39,18 @@ MODULE_LICENSE("GPL");
765 static int ext2_update_inode(struct inode * inode, int do_sync);
768 + * Test whether an inode is a fast symlink.
770 +static inline int ext2_inode_is_fast_symlink(struct inode *inode)
772 + int ea_blocks = inode->u.ext2_i.i_file_acl ?
773 + (inode->i_sb->s_blocksize >> 9) : 0;
775 + return (S_ISLNK(inode->i_mode) &&
776 + inode->i_blocks - ea_blocks == 0);
780 * Called at each iput()
782 void ext2_put_inode (struct inode * inode)
783 @@ -53,9 +65,7 @@ void ext2_delete_inode (struct inode * i
787 - if (is_bad_inode(inode) ||
788 - inode->i_ino == EXT2_ACL_IDX_INO ||
789 - inode->i_ino == EXT2_ACL_DATA_INO)
790 + if (is_bad_inode(inode))
792 inode->u.ext2_i.i_dtime = CURRENT_TIME;
793 mark_inode_dirty(inode);
794 @@ -801,6 +811,8 @@ void ext2_truncate (struct inode * inode
795 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
796 S_ISLNK(inode->i_mode)))
798 + if (ext2_inode_is_fast_symlink(inode))
800 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
803 @@ -888,8 +900,7 @@ void ext2_read_inode (struct inode * ino
804 unsigned long offset;
805 struct ext2_group_desc * gdp;
807 - if ((inode->i_ino != EXT2_ROOT_INO && inode->i_ino != EXT2_ACL_IDX_INO &&
808 - inode->i_ino != EXT2_ACL_DATA_INO &&
809 + if ((inode->i_ino != EXT2_ROOT_INO &&
810 inode->i_ino < EXT2_FIRST_INO(inode->i_sb)) ||
811 inode->i_ino > le32_to_cpu(inode->i_sb->u.ext2_sb.s_es->s_inodes_count)) {
812 ext2_error (inode->i_sb, "ext2_read_inode",
813 @@ -974,10 +985,7 @@ void ext2_read_inode (struct inode * ino
814 for (block = 0; block < EXT2_N_BLOCKS; block++)
815 inode->u.ext2_i.i_data[block] = raw_inode->i_block[block];
817 - if (inode->i_ino == EXT2_ACL_IDX_INO ||
818 - inode->i_ino == EXT2_ACL_DATA_INO)
819 - /* Nothing to do */ ;
820 - else if (S_ISREG(inode->i_mode)) {
821 + if (S_ISREG(inode->i_mode)) {
822 inode->i_op = &ext2_file_inode_operations;
823 inode->i_fop = &ext2_file_operations;
824 inode->i_mapping->a_ops = &ext2_aops;
825 @@ -986,15 +994,17 @@ void ext2_read_inode (struct inode * ino
826 inode->i_fop = &ext2_dir_operations;
827 inode->i_mapping->a_ops = &ext2_aops;
828 } else if (S_ISLNK(inode->i_mode)) {
829 - if (!inode->i_blocks)
830 + if (ext2_inode_is_fast_symlink(inode))
831 inode->i_op = &ext2_fast_symlink_inode_operations;
833 - inode->i_op = &page_symlink_inode_operations;
834 + inode->i_op = &ext2_symlink_inode_operations;
835 inode->i_mapping->a_ops = &ext2_aops;
839 + inode->i_op = &ext2_special_inode_operations;
840 init_special_inode(inode, inode->i_mode,
841 le32_to_cpu(raw_inode->i_block[0]));
844 inode->i_attr_flags = 0;
845 if (inode->u.ext2_i.i_flags & EXT2_SYNC_FL) {
846 --- linux-2.4.20/fs/ext2/namei.c~linux-2.4.20-xattr-0.8.54 2001-10-04 13:57:36.000000000 +0800
847 +++ linux-2.4.20-root/fs/ext2/namei.c 2003-05-07 18:08:03.000000000 +0800
850 #include <linux/fs.h>
851 #include <linux/ext2_fs.h>
852 +#include <linux/ext2_xattr.h>
853 #include <linux/pagemap.h>
856 @@ -136,7 +137,7 @@ static int ext2_symlink (struct inode *
858 if (l > sizeof (inode->u.ext2_i.i_data)) {
860 - inode->i_op = &page_symlink_inode_operations;
861 + inode->i_op = &ext2_symlink_inode_operations;
862 inode->i_mapping->a_ops = &ext2_aops;
863 err = block_symlink(inode, symname, l);
865 @@ -345,4 +346,15 @@ struct inode_operations ext2_dir_inode_o
869 + setxattr: ext2_setxattr,
870 + getxattr: ext2_getxattr,
871 + listxattr: ext2_listxattr,
872 + removexattr: ext2_removexattr,
875 +struct inode_operations ext2_special_inode_operations = {
876 + setxattr: ext2_setxattr,
877 + getxattr: ext2_getxattr,
878 + listxattr: ext2_listxattr,
879 + removexattr: ext2_removexattr,
881 --- linux-2.4.20/fs/ext2/super.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
882 +++ linux-2.4.20-root/fs/ext2/super.c 2003-05-07 18:08:03.000000000 +0800
884 #include <linux/string.h>
885 #include <linux/fs.h>
886 #include <linux/ext2_fs.h>
887 +#include <linux/ext2_xattr.h>
888 #include <linux/slab.h>
889 #include <linux/init.h>
890 #include <linux/locks.h>
891 @@ -125,6 +126,7 @@ void ext2_put_super (struct super_block
895 + ext2_xattr_put_super(sb);
896 if (!(sb->s_flags & MS_RDONLY)) {
897 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
899 @@ -175,6 +177,13 @@ static int parse_options (char * options
900 this_char = strtok (NULL, ",")) {
901 if ((value = strchr (this_char, '=')) != NULL)
903 +#ifdef CONFIG_EXT2_FS_XATTR_USER
904 + if (!strcmp (this_char, "user_xattr"))
905 + set_opt (*mount_options, XATTR_USER);
906 + else if (!strcmp (this_char, "nouser_xattr"))
907 + clear_opt (*mount_options, XATTR_USER);
910 if (!strcmp (this_char, "bsddf"))
911 clear_opt (*mount_options, MINIX_DF);
912 else if (!strcmp (this_char, "nouid32")) {
913 @@ -424,6 +433,9 @@ struct super_block * ext2_read_super (st
914 blocksize = BLOCK_SIZE;
916 sb->u.ext2_sb.s_mount_opt = 0;
917 +#ifdef CONFIG_EXT2_FS_XATTR_USER
918 + /* set_opt (sb->u.ext2_sb.s_mount_opt, XATTR_USER); */
920 if (!parse_options ((char *) data, &sb_block, &resuid, &resgid,
921 &sb->u.ext2_sb.s_mount_opt)) {
923 @@ -813,12 +825,27 @@ static DECLARE_FSTYPE_DEV(ext2_fs_type,
925 static int __init init_ext2_fs(void)
927 - return register_filesystem(&ext2_fs_type);
928 + int error = init_ext2_xattr();
931 + error = init_ext2_xattr_user();
934 + error = register_filesystem(&ext2_fs_type);
938 + exit_ext2_xattr_user();
944 static void __exit exit_ext2_fs(void)
946 unregister_filesystem(&ext2_fs_type);
947 + exit_ext2_xattr_user();
952 --- linux-2.4.20/fs/ext2/symlink.c~linux-2.4.20-xattr-0.8.54 2000-09-28 04:41:33.000000000 +0800
953 +++ linux-2.4.20-root/fs/ext2/symlink.c 2003-05-07 18:08:03.000000000 +0800
956 #include <linux/fs.h>
957 #include <linux/ext2_fs.h>
958 +#include <linux/ext2_xattr.h>
960 static int ext2_readlink(struct dentry *dentry, char *buffer, int buflen)
962 @@ -32,7 +33,20 @@ static int ext2_follow_link(struct dentr
963 return vfs_follow_link(nd, s);
966 +struct inode_operations ext2_symlink_inode_operations = {
967 + readlink: page_readlink,
968 + follow_link: page_follow_link,
969 + setxattr: ext2_setxattr,
970 + getxattr: ext2_getxattr,
971 + listxattr: ext2_listxattr,
972 + removexattr: ext2_removexattr,
975 struct inode_operations ext2_fast_symlink_inode_operations = {
976 readlink: ext2_readlink,
977 follow_link: ext2_follow_link,
978 + setxattr: ext2_setxattr,
979 + getxattr: ext2_getxattr,
980 + listxattr: ext2_listxattr,
981 + removexattr: ext2_removexattr,
983 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
984 +++ linux-2.4.20-root/fs/ext2/xattr.c 2003-05-07 18:08:03.000000000 +0800
987 + * linux/fs/ext2/xattr.c
989 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
991 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
992 + * Extended attributes for symlinks and special files added per
993 + * suggestion of Luka Renko <luka.renko@hermes.si>.
997 + * Extended attributes are stored on disk blocks allocated outside of
998 + * any inode. The i_file_acl field is then made to point to this allocated
999 + * block. If all extended attributes of an inode are identical, these
1000 + * inodes may share the same extended attribute block. Such situations
1001 + * are automatically detected by keeping a cache of recent attribute block
1002 + * numbers and hashes over the block's contents in memory.
1005 + * Extended attribute block layout:
1007 + * +------------------+
1010 + * | entry 2 | | growing downwards
1012 + * | four null bytes |
1015 + * | value 3 | | growing upwards
1017 + * +------------------+
1019 + * The block header is followed by multiple entry descriptors. These entry
1020 + * descriptors are variable in size, and alligned to EXT2_XATTR_PAD
1021 + * byte boundaries. The entry descriptors are sorted by attribute name,
1022 + * so that two extended attribute blocks can be compared efficiently.
1024 + * Attribute values are aligned to the end of the block, stored in
1025 + * no specific order. They are also padded to EXT2_XATTR_PAD byte
1026 + * boundaries. No additional gaps are left between them.
1028 + * Locking strategy
1029 + * ----------------
1030 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
1031 + * the xattr inode operations are called, so we are guaranteed that only one
1032 + * processes accesses extended attributes of an inode at any time.
1034 + * For writing we also grab the ext2_xattr_sem semaphore. This ensures that
1035 + * only a single process is modifying an extended attribute block, even
1036 + * if the block is shared among inodes.
1038 + * Note for porting to 2.5
1039 + * -----------------------
1040 + * The BKL will no longer be held in the xattr inode operations.
1043 +#include <linux/module.h>
1044 +#include <linux/locks.h>
1045 +#include <linux/slab.h>
1046 +#include <linux/fs.h>
1047 +#include <linux/ext2_fs.h>
1048 +#include <linux/ext2_xattr.h>
1049 +#include <linux/mbcache.h>
1050 +#include <linux/quotaops.h>
1051 +#include <asm/semaphore.h>
1052 +#include <linux/compatmac.h>
1054 +/* These symbols may be needed by a module. */
1055 +EXPORT_SYMBOL(ext2_xattr_register);
1056 +EXPORT_SYMBOL(ext2_xattr_unregister);
1057 +EXPORT_SYMBOL(ext2_xattr_get);
1058 +EXPORT_SYMBOL(ext2_xattr_list);
1059 +EXPORT_SYMBOL(ext2_xattr_set);
1061 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
1062 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
1065 +#define HDR(bh) ((struct ext2_xattr_header *)((bh)->b_data))
1066 +#define ENTRY(ptr) ((struct ext2_xattr_entry *)(ptr))
1067 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
1068 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
1070 +#ifdef EXT2_XATTR_DEBUG
1071 +# define ea_idebug(inode, f...) do { \
1072 + printk(KERN_DEBUG "inode %s:%ld: ", \
1073 + kdevname(inode->i_dev), inode->i_ino); \
1077 +# define ea_bdebug(bh, f...) do { \
1078 + printk(KERN_DEBUG "block %s:%ld: ", \
1079 + kdevname(bh->b_dev), bh->b_blocknr); \
1084 +# define ea_idebug(f...)
1085 +# define ea_bdebug(f...)
1088 +static int ext2_xattr_set2(struct inode *, struct buffer_head *,
1089 + struct ext2_xattr_header *);
1091 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1093 +static int ext2_xattr_cache_insert(struct buffer_head *);
1094 +static struct buffer_head *ext2_xattr_cache_find(struct inode *,
1095 + struct ext2_xattr_header *);
1096 +static void ext2_xattr_cache_remove(struct buffer_head *);
1097 +static void ext2_xattr_rehash(struct ext2_xattr_header *,
1098 + struct ext2_xattr_entry *);
1100 +static struct mb_cache *ext2_xattr_cache;
1103 +# define ext2_xattr_cache_insert(bh) 0
1104 +# define ext2_xattr_cache_find(inode, header) NULL
1105 +# define ext2_xattr_cache_remove(bh) while(0) {}
1106 +# define ext2_xattr_rehash(header, entry) while(0) {}
1110 + * If a file system does not share extended attributes among inodes,
1111 + * we should not need the ext2_xattr_sem semaphore. However, the
1112 + * filesystem may still contain shared blocks, so we always take
1116 +DECLARE_MUTEX(ext2_xattr_sem);
1119 +ext2_xattr_new_block(struct inode *inode, int * errp, int force)
1121 + struct super_block *sb = inode->i_sb;
1122 + int goal = le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block) +
1123 + EXT2_I(inode)->i_block_group * EXT2_BLOCKS_PER_GROUP(sb);
1125 + /* How can we enforce the allocation? */
1126 + int block = ext2_new_block(inode, goal, 0, 0, errp);
1129 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
1135 +ext2_xattr_quota_alloc(struct inode *inode, int force)
1137 + /* How can we enforce the allocation? */
1139 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
1141 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
1143 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
1151 +ext2_xattr_quota_free(struct inode *inode)
1153 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
1154 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1158 +ext2_xattr_free_block(struct inode * inode, unsigned long block)
1160 + ext2_free_blocks(inode, block, 1);
1161 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1165 +# define ext2_xattr_quota_free(inode) \
1166 + DQUOT_FREE_BLOCK(inode, 1)
1167 +# define ext2_xattr_free_block(inode, block) \
1168 + ext2_free_blocks(inode, block, 1)
1171 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
1173 +static inline struct buffer_head *
1174 +sb_bread(struct super_block *sb, int block)
1176 + return bread(sb->s_dev, block, sb->s_blocksize);
1179 +static inline struct buffer_head *
1180 +sb_getblk(struct super_block *sb, int block)
1182 + return getblk(sb->s_dev, block, sb->s_blocksize);
1187 +struct ext2_xattr_handler *ext2_xattr_handlers[EXT2_XATTR_INDEX_MAX];
1188 +rwlock_t ext2_handler_lock = RW_LOCK_UNLOCKED;
1191 +ext2_xattr_register(int name_index, struct ext2_xattr_handler *handler)
1193 + int error = -EINVAL;
1195 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1196 + write_lock(&ext2_handler_lock);
1197 + if (!ext2_xattr_handlers[name_index-1]) {
1198 + ext2_xattr_handlers[name_index-1] = handler;
1201 + write_unlock(&ext2_handler_lock);
1207 +ext2_xattr_unregister(int name_index, struct ext2_xattr_handler *handler)
1209 + if (name_index > 0 || name_index <= EXT2_XATTR_INDEX_MAX) {
1210 + write_lock(&ext2_handler_lock);
1211 + ext2_xattr_handlers[name_index-1] = NULL;
1212 + write_unlock(&ext2_handler_lock);
1216 +static inline const char *
1217 +strcmp_prefix(const char *a, const char *a_prefix)
1219 + while (*a_prefix && *a == *a_prefix) {
1223 + return *a_prefix ? NULL : a;
1227 + * Decode the extended attribute name, and translate it into
1228 + * the name_index and name suffix.
1230 +static struct ext2_xattr_handler *
1231 +ext2_xattr_resolve_name(const char **name)
1233 + struct ext2_xattr_handler *handler = NULL;
1238 + read_lock(&ext2_handler_lock);
1239 + for (i=0; i<EXT2_XATTR_INDEX_MAX; i++) {
1240 + if (ext2_xattr_handlers[i]) {
1241 + const char *n = strcmp_prefix(*name,
1242 + ext2_xattr_handlers[i]->prefix);
1244 + handler = ext2_xattr_handlers[i];
1250 + read_unlock(&ext2_handler_lock);
1254 +static inline struct ext2_xattr_handler *
1255 +ext2_xattr_handler(int name_index)
1257 + struct ext2_xattr_handler *handler = NULL;
1258 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1259 + read_lock(&ext2_handler_lock);
1260 + handler = ext2_xattr_handlers[name_index-1];
1261 + read_unlock(&ext2_handler_lock);
1267 + * Inode operation getxattr()
1269 + * dentry->d_inode->i_sem down
1270 + * BKL held [before 2.5.x]
1273 +ext2_getxattr(struct dentry *dentry, const char *name,
1274 + void *buffer, size_t size)
1276 + struct ext2_xattr_handler *handler;
1277 + struct inode *inode = dentry->d_inode;
1279 + handler = ext2_xattr_resolve_name(&name);
1282 + return handler->get(inode, name, buffer, size);
1286 + * Inode operation listxattr()
1288 + * dentry->d_inode->i_sem down
1289 + * BKL held [before 2.5.x]
1292 +ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
1294 + return ext2_xattr_list(dentry->d_inode, buffer, size);
1298 + * Inode operation setxattr()
1300 + * dentry->d_inode->i_sem down
1301 + * BKL held [before 2.5.x]
1304 +ext2_setxattr(struct dentry *dentry, const char *name,
1305 + const void *value, size_t size, int flags)
1307 + struct ext2_xattr_handler *handler;
1308 + struct inode *inode = dentry->d_inode;
1311 + value = ""; /* empty EA, do not remove */
1312 + handler = ext2_xattr_resolve_name(&name);
1315 + return handler->set(inode, name, value, size, flags);
1319 + * Inode operation removexattr()
1321 + * dentry->d_inode->i_sem down
1322 + * BKL held [before 2.5.x]
1325 +ext2_removexattr(struct dentry *dentry, const char *name)
1327 + struct ext2_xattr_handler *handler;
1328 + struct inode *inode = dentry->d_inode;
1330 + handler = ext2_xattr_resolve_name(&name);
1333 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
1337 + * ext2_xattr_get()
1339 + * Copy an extended attribute into the buffer
1340 + * provided, or compute the buffer size required.
1341 + * Buffer is NULL to compute the size of the buffer required.
1343 + * Returns a negative error number on failure, or the number of bytes
1344 + * used / required on success.
1347 +ext2_xattr_get(struct inode *inode, int name_index, const char *name,
1348 + void *buffer, size_t buffer_size)
1350 + struct buffer_head *bh = NULL;
1351 + struct ext2_xattr_entry *entry;
1352 + unsigned int block, size;
1354 + int name_len, error;
1356 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
1357 + name_index, name, buffer, (long)buffer_size);
1361 + if (!EXT2_I(inode)->i_file_acl)
1363 + block = EXT2_I(inode)->i_file_acl;
1364 + ea_idebug(inode, "reading block %d", block);
1365 + bh = sb_bread(inode->i_sb, block);
1368 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1369 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1370 + end = bh->b_data + bh->b_size;
1371 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1372 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1373 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
1374 + "inode %ld: bad block %d", inode->i_ino, block);
1378 + /* find named attribute */
1379 + name_len = strlen(name);
1382 + if (name_len > 255)
1384 + entry = FIRST_ENTRY(bh);
1385 + while (!IS_LAST_ENTRY(entry)) {
1386 + struct ext2_xattr_entry *next =
1387 + EXT2_XATTR_NEXT(entry);
1388 + if ((char *)next >= end)
1390 + if (name_index == entry->e_name_index &&
1391 + name_len == entry->e_name_len &&
1392 + memcmp(name, entry->e_name, name_len) == 0)
1396 + /* Check the remaining name entries */
1397 + while (!IS_LAST_ENTRY(entry)) {
1398 + struct ext2_xattr_entry *next =
1399 + EXT2_XATTR_NEXT(entry);
1400 + if ((char *)next >= end)
1404 + if (ext2_xattr_cache_insert(bh))
1405 + ea_idebug(inode, "cache insert failed");
1409 + /* check the buffer size */
1410 + if (entry->e_value_block != 0)
1412 + size = le32_to_cpu(entry->e_value_size);
1413 + if (size > inode->i_sb->s_blocksize ||
1414 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
1417 + if (ext2_xattr_cache_insert(bh))
1418 + ea_idebug(inode, "cache insert failed");
1421 + if (size > buffer_size)
1423 + /* return value of attribute */
1424 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
1436 + * ext2_xattr_list()
1438 + * Copy a list of attribute names into the buffer
1439 + * provided, or compute the buffer size required.
1440 + * Buffer is NULL to compute the size of the buffer required.
1442 + * Returns a negative error number on failure, or the number of bytes
1443 + * used / required on success.
1446 +ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
1448 + struct buffer_head *bh = NULL;
1449 + struct ext2_xattr_entry *entry;
1450 + unsigned int block, size = 0;
1454 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
1455 + buffer, (long)buffer_size);
1457 + if (!EXT2_I(inode)->i_file_acl)
1459 + block = EXT2_I(inode)->i_file_acl;
1460 + ea_idebug(inode, "reading block %d", block);
1461 + bh = sb_bread(inode->i_sb, block);
1464 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1465 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1466 + end = bh->b_data + bh->b_size;
1467 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1468 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1469 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
1470 + "inode %ld: bad block %d", inode->i_ino, block);
1474 + /* compute the size required for the list of attribute names */
1475 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1476 + entry = EXT2_XATTR_NEXT(entry)) {
1477 + struct ext2_xattr_handler *handler;
1478 + struct ext2_xattr_entry *next =
1479 + EXT2_XATTR_NEXT(entry);
1480 + if ((char *)next >= end)
1483 + handler = ext2_xattr_handler(entry->e_name_index);
1485 + size += handler->list(NULL, inode, entry->e_name,
1486 + entry->e_name_len);
1489 + if (ext2_xattr_cache_insert(bh))
1490 + ea_idebug(inode, "cache insert failed");
1496 + if (size > buffer_size)
1500 + /* list the attribute names */
1502 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1503 + entry = EXT2_XATTR_NEXT(entry)) {
1504 + struct ext2_xattr_handler *handler;
1506 + handler = ext2_xattr_handler(entry->e_name_index);
1508 + buf += handler->list(buf, inode, entry->e_name,
1509 + entry->e_name_len);
1520 + * If the EXT2_FEATURE_COMPAT_EXT_ATTR feature of this file system is
1521 + * not set, set it.
1523 +static void ext2_xattr_update_super_block(struct super_block *sb)
1525 + if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
1529 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
1530 + EXT2_SB(sb)->s_feature_compat |= EXT2_FEATURE_COMPAT_EXT_ATTR;
1532 + EXT2_SB(sb)->s_es->s_feature_compat |=
1533 + cpu_to_le32(EXT2_FEATURE_COMPAT_EXT_ATTR);
1535 + mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
1540 + * ext2_xattr_set()
1542 + * Create, replace or remove an extended attribute for this inode. Buffer
1543 + * is NULL to remove an existing extended attribute, and non-NULL to
1544 + * either replace an existing extended attribute, or create a new extended
1545 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
1546 + * specify that an extended attribute must exist and must not exist
1547 + * previous to the call, respectively.
1549 + * Returns 0, or a negative error number on failure.
1552 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
1553 + const void *value, size_t value_len, int flags)
1555 + struct super_block *sb = inode->i_sb;
1556 + struct buffer_head *bh = NULL;
1557 + struct ext2_xattr_header *header = NULL;
1558 + struct ext2_xattr_entry *here, *last;
1559 + unsigned int name_len;
1560 + int block = EXT2_I(inode)->i_file_acl;
1561 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
1565 + * header -- Points either into bh, or to a temporarily
1566 + * allocated buffer.
1567 + * here -- The named entry found, or the place for inserting, within
1568 + * the block pointed to by header.
1569 + * last -- Points right after the last named entry within the block
1570 + * pointed to by header.
1571 + * min_offs -- The offset of the first value (values are aligned
1572 + * towards the end of the block).
1573 + * end -- Points right after the block pointed to by header.
1576 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
1577 + name_index, name, value, (long)value_len);
1579 + if (IS_RDONLY(inode))
1581 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1583 + if (value == NULL)
1587 + name_len = strlen(name);
1588 + if (name_len > 255 || value_len > sb->s_blocksize)
1590 + down(&ext2_xattr_sem);
1593 + /* The inode already has an extended attribute block. */
1595 + bh = sb_bread(sb, block);
1599 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1600 + atomic_read(&(bh->b_count)),
1601 + le32_to_cpu(HDR(bh)->h_refcount));
1603 + end = bh->b_data + bh->b_size;
1604 + if (header->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1605 + header->h_blocks != cpu_to_le32(1)) {
1606 +bad_block: ext2_error(sb, "ext2_xattr_set",
1607 + "inode %ld: bad block %d", inode->i_ino, block);
1611 + /* Find the named attribute. */
1612 + here = FIRST_ENTRY(bh);
1613 + while (!IS_LAST_ENTRY(here)) {
1614 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(here);
1615 + if ((char *)next >= end)
1617 + if (!here->e_value_block && here->e_value_size) {
1618 + int offs = le16_to_cpu(here->e_value_offs);
1619 + if (offs < min_offs)
1622 + not_found = name_index - here->e_name_index;
1624 + not_found = name_len - here->e_name_len;
1626 + not_found = memcmp(name, here->e_name,name_len);
1627 + if (not_found <= 0)
1632 + /* We still need to compute min_offs and last. */
1633 + while (!IS_LAST_ENTRY(last)) {
1634 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(last);
1635 + if ((char *)next >= end)
1637 + if (!last->e_value_block && last->e_value_size) {
1638 + int offs = le16_to_cpu(last->e_value_offs);
1639 + if (offs < min_offs)
1645 + /* Check whether we have enough space left. */
1646 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
1648 + /* We will use a new extended attribute block. */
1649 + free = sb->s_blocksize -
1650 + sizeof(struct ext2_xattr_header) - sizeof(__u32);
1651 + here = last = NULL; /* avoid gcc uninitialized warning. */
1655 + /* Request to remove a nonexistent attribute? */
1657 + if (flags & XATTR_REPLACE)
1660 + if (value == NULL)
1663 + free -= EXT2_XATTR_LEN(name_len);
1665 + /* Request to create an existing attribute? */
1667 + if (flags & XATTR_CREATE)
1669 + if (!here->e_value_block && here->e_value_size) {
1670 + unsigned int size = le32_to_cpu(here->e_value_size);
1672 + if (le16_to_cpu(here->e_value_offs) + size >
1673 + sb->s_blocksize || size > sb->s_blocksize)
1675 + free += EXT2_XATTR_SIZE(size);
1678 + free -= EXT2_XATTR_SIZE(value_len);
1683 + /* Here we know that we can set the new attribute. */
1686 + if (header->h_refcount == cpu_to_le32(1)) {
1687 + ea_bdebug(bh, "modifying in-place");
1688 + ext2_xattr_cache_remove(bh);
1692 + ea_bdebug(bh, "cloning");
1693 + header = kmalloc(bh->b_size, GFP_KERNEL);
1695 + if (header == NULL)
1697 + memcpy(header, HDR(bh), bh->b_size);
1698 + header->h_refcount = cpu_to_le32(1);
1699 + offset = (char *)header - bh->b_data;
1700 + here = ENTRY((char *)here + offset);
1701 + last = ENTRY((char *)last + offset);
1704 + /* Allocate a buffer where we construct the new block. */
1705 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
1707 + if (header == NULL)
1709 + memset(header, 0, sb->s_blocksize);
1710 + end = (char *)header + sb->s_blocksize;
1711 + header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC);
1712 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
1713 + last = here = ENTRY(header+1);
1717 + /* Insert the new name. */
1718 + int size = EXT2_XATTR_LEN(name_len);
1719 + int rest = (char *)last - (char *)here;
1720 + memmove((char *)here + size, here, rest);
1721 + memset(here, 0, size);
1722 + here->e_name_index = name_index;
1723 + here->e_name_len = name_len;
1724 + memcpy(here->e_name, name, name_len);
1726 + /* Remove the old value. */
1727 + if (!here->e_value_block && here->e_value_size) {
1728 + char *first_val = (char *)header + min_offs;
1729 + int offs = le16_to_cpu(here->e_value_offs);
1730 + char *val = (char *)header + offs;
1731 + size_t size = EXT2_XATTR_SIZE(
1732 + le32_to_cpu(here->e_value_size));
1733 + memmove(first_val + size, first_val, val - first_val);
1734 + memset(first_val, 0, size);
1735 + here->e_value_offs = 0;
1738 + /* Adjust all value offsets. */
1739 + last = ENTRY(header+1);
1740 + while (!IS_LAST_ENTRY(last)) {
1741 + int o = le16_to_cpu(last->e_value_offs);
1742 + if (!last->e_value_block && o < offs)
1743 + last->e_value_offs =
1744 + cpu_to_le16(o + size);
1745 + last = EXT2_XATTR_NEXT(last);
1748 + if (value == NULL) {
1749 + /* Remove this attribute. */
1750 + if (EXT2_XATTR_NEXT(ENTRY(header+1)) == last) {
1751 + /* This block is now empty. */
1752 + error = ext2_xattr_set2(inode, bh, NULL);
1755 + /* Remove the old name. */
1756 + int size = EXT2_XATTR_LEN(name_len);
1757 + last = ENTRY((char *)last - size);
1758 + memmove(here, (char*)here + size,
1759 + (char*)last - (char*)here);
1760 + memset(last, 0, size);
1765 + if (value != NULL) {
1766 + /* Insert the new value. */
1767 + here->e_value_size = cpu_to_le32(value_len);
1769 + size_t size = EXT2_XATTR_SIZE(value_len);
1770 + char *val = (char *)header + min_offs - size;
1771 + here->e_value_offs =
1772 + cpu_to_le16((char *)val - (char *)header);
1773 + memset(val + size - EXT2_XATTR_PAD, 0,
1774 + EXT2_XATTR_PAD); /* Clear the pad bytes. */
1775 + memcpy(val, value, value_len);
1778 + ext2_xattr_rehash(header, here);
1780 + error = ext2_xattr_set2(inode, bh, header);
1784 + if (!(bh && header == HDR(bh)))
1786 + up(&ext2_xattr_sem);
1792 + * Second half of ext2_xattr_set(): Update the file system.
1795 +ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
1796 + struct ext2_xattr_header *header)
1798 + struct super_block *sb = inode->i_sb;
1799 + struct buffer_head *new_bh = NULL;
1803 + new_bh = ext2_xattr_cache_find(inode, header);
1806 + * We found an identical block in the cache.
1807 + * The old block will be released after updating
1810 + ea_bdebug(old_bh, "reusing block %ld",
1811 + new_bh->b_blocknr);
1814 + if (ext2_xattr_quota_alloc(inode, 1))
1817 + HDR(new_bh)->h_refcount = cpu_to_le32(
1818 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
1819 + ea_bdebug(new_bh, "refcount now=%d",
1820 + le32_to_cpu(HDR(new_bh)->h_refcount));
1821 + } else if (old_bh && header == HDR(old_bh)) {
1822 + /* Keep this block. */
1824 + (void)ext2_xattr_cache_insert(new_bh);
1826 + /* We need to allocate a new block */
1827 + int force = EXT2_I(inode)->i_file_acl != 0;
1828 + int block = ext2_xattr_new_block(inode, &error, force);
1831 + ea_idebug(inode, "creating block %d", block);
1833 + new_bh = sb_getblk(sb, block);
1835 + ext2_xattr_free_block(inode, block);
1839 + lock_buffer(new_bh);
1840 + memcpy(new_bh->b_data, header, new_bh->b_size);
1841 + mark_buffer_uptodate(new_bh, 1);
1842 + unlock_buffer(new_bh);
1843 + (void)ext2_xattr_cache_insert(new_bh);
1845 + ext2_xattr_update_super_block(sb);
1847 + mark_buffer_dirty(new_bh);
1848 + if (IS_SYNC(inode)) {
1849 + ll_rw_block(WRITE, 1, &new_bh);
1850 + wait_on_buffer(new_bh);
1852 + if (buffer_req(new_bh) && !buffer_uptodate(new_bh))
1857 + /* Update the inode. */
1858 + EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
1859 + inode->i_ctime = CURRENT_TIME;
1860 + if (IS_SYNC(inode)) {
1861 + error = ext2_sync_inode (inode);
1865 + mark_inode_dirty(inode);
1868 + if (old_bh && old_bh != new_bh) {
1870 + * If there was an old block, and we are not still using it,
1871 + * we now release the old block.
1873 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
1875 + if (refcount == 1) {
1876 + /* Free the old block. */
1877 + ea_bdebug(old_bh, "freeing");
1878 + ext2_xattr_free_block(inode, old_bh->b_blocknr);
1879 + mark_buffer_clean(old_bh);
1881 + /* Decrement the refcount only. */
1883 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
1884 + ext2_xattr_quota_free(inode);
1885 + mark_buffer_dirty(old_bh);
1886 + ea_bdebug(old_bh, "refcount now=%d", refcount);
1891 + if (old_bh != new_bh)
1898 + * ext2_xattr_delete_inode()
1900 + * Free extended attribute resources associated with this inode. This
1901 + * is called immediately before an inode is freed.
1904 +ext2_xattr_delete_inode(struct inode *inode)
1906 + struct buffer_head *bh;
1907 + unsigned int block = EXT2_I(inode)->i_file_acl;
1911 + down(&ext2_xattr_sem);
1913 + bh = sb_bread(inode->i_sb, block);
1915 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1916 + "inode %ld: block %d read error", inode->i_ino, block);
1919 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
1920 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1921 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1922 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1923 + "inode %ld: bad block %d", inode->i_ino, block);
1926 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
1927 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
1928 + ext2_xattr_cache_remove(bh);
1929 + ext2_xattr_free_block(inode, block);
1933 + HDR(bh)->h_refcount = cpu_to_le32(
1934 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
1935 + mark_buffer_dirty(bh);
1936 + if (IS_SYNC(inode)) {
1937 + ll_rw_block(WRITE, 1, &bh);
1938 + wait_on_buffer(bh);
1940 + ext2_xattr_quota_free(inode);
1942 + EXT2_I(inode)->i_file_acl = 0;
1946 + up(&ext2_xattr_sem);
1950 + * ext2_xattr_put_super()
1952 + * This is called when a file system is unmounted.
1955 +ext2_xattr_put_super(struct super_block *sb)
1957 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1958 + mb_cache_shrink(ext2_xattr_cache, sb->s_dev);
1962 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1965 + * ext2_xattr_cache_insert()
1967 + * Create a new entry in the extended attribute cache, and insert
1968 + * it unless such an entry is already in the cache.
1970 + * Returns 0, or a negative error number on failure.
1973 +ext2_xattr_cache_insert(struct buffer_head *bh)
1975 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
1976 + struct mb_cache_entry *ce;
1979 + ce = mb_cache_entry_alloc(ext2_xattr_cache);
1982 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
1984 + mb_cache_entry_free(ce);
1985 + if (error == -EBUSY) {
1986 + ea_bdebug(bh, "already in cache (%d cache entries)",
1987 + atomic_read(&ext2_xattr_cache->c_entry_count));
1991 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
1992 + atomic_read(&ext2_xattr_cache->c_entry_count));
1993 + mb_cache_entry_release(ce);
1999 + * ext2_xattr_cmp()
2001 + * Compare two extended attribute blocks for equality.
2003 + * Returns 0 if the blocks are equal, 1 if they differ, and
2004 + * a negative error number on errors.
2007 +ext2_xattr_cmp(struct ext2_xattr_header *header1,
2008 + struct ext2_xattr_header *header2)
2010 + struct ext2_xattr_entry *entry1, *entry2;
2012 + entry1 = ENTRY(header1+1);
2013 + entry2 = ENTRY(header2+1);
2014 + while (!IS_LAST_ENTRY(entry1)) {
2015 + if (IS_LAST_ENTRY(entry2))
2017 + if (entry1->e_hash != entry2->e_hash ||
2018 + entry1->e_name_len != entry2->e_name_len ||
2019 + entry1->e_value_size != entry2->e_value_size ||
2020 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
2022 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
2024 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
2025 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
2026 + le32_to_cpu(entry1->e_value_size)))
2029 + entry1 = EXT2_XATTR_NEXT(entry1);
2030 + entry2 = EXT2_XATTR_NEXT(entry2);
2032 + if (!IS_LAST_ENTRY(entry2))
2038 + * ext2_xattr_cache_find()
2040 + * Find an identical extended attribute block.
2042 + * Returns a pointer to the block found, or NULL if such a block was
2043 + * not found or an error occurred.
2045 +static struct buffer_head *
2046 +ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
2048 + __u32 hash = le32_to_cpu(header->h_hash);
2049 + struct mb_cache_entry *ce;
2051 + if (!header->h_hash)
2052 + return NULL; /* never share */
2053 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
2054 + ce = mb_cache_entry_find_first(ext2_xattr_cache, 0, inode->i_dev, hash);
2056 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
2059 + ext2_error(inode->i_sb, "ext2_xattr_cache_find",
2060 + "inode %ld: block %ld read error",
2061 + inode->i_ino, ce->e_block);
2062 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
2063 + EXT2_XATTR_REFCOUNT_MAX) {
2064 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
2065 + le32_to_cpu(HDR(bh)->h_refcount),
2066 + EXT2_XATTR_REFCOUNT_MAX);
2067 + } else if (!ext2_xattr_cmp(header, HDR(bh))) {
2068 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
2069 + mb_cache_entry_release(ce);
2073 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
2079 + * ext2_xattr_cache_remove()
2081 + * Remove the cache entry of a block from the cache. Called when a
2082 + * block becomes invalid.
2085 +ext2_xattr_cache_remove(struct buffer_head *bh)
2087 + struct mb_cache_entry *ce;
2089 + ce = mb_cache_entry_get(ext2_xattr_cache, bh->b_dev, bh->b_blocknr);
2091 + ea_bdebug(bh, "removing (%d cache entries remaining)",
2092 + atomic_read(&ext2_xattr_cache->c_entry_count)-1);
2093 + mb_cache_entry_free(ce);
2095 + ea_bdebug(bh, "no cache entry");
2098 +#define NAME_HASH_SHIFT 5
2099 +#define VALUE_HASH_SHIFT 16
2102 + * ext2_xattr_hash_entry()
2104 + * Compute the hash of an extended attribute.
2106 +static inline void ext2_xattr_hash_entry(struct ext2_xattr_header *header,
2107 + struct ext2_xattr_entry *entry)
2110 + char *name = entry->e_name;
2113 + for (n=0; n < entry->e_name_len; n++) {
2114 + hash = (hash << NAME_HASH_SHIFT) ^
2115 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
2119 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
2120 + __u32 *value = (__u32 *)((char *)header +
2121 + le16_to_cpu(entry->e_value_offs));
2122 + for (n = (le32_to_cpu(entry->e_value_size) +
2123 + EXT2_XATTR_ROUND) >> EXT2_XATTR_PAD_BITS; n; n--) {
2124 + hash = (hash << VALUE_HASH_SHIFT) ^
2125 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
2126 + le32_to_cpu(*value++);
2129 + entry->e_hash = cpu_to_le32(hash);
2132 +#undef NAME_HASH_SHIFT
2133 +#undef VALUE_HASH_SHIFT
2135 +#define BLOCK_HASH_SHIFT 16
2138 + * ext2_xattr_rehash()
2140 + * Re-compute the extended attribute hash value after an entry has changed.
2142 +static void ext2_xattr_rehash(struct ext2_xattr_header *header,
2143 + struct ext2_xattr_entry *entry)
2145 + struct ext2_xattr_entry *here;
2148 + ext2_xattr_hash_entry(header, entry);
2149 + here = ENTRY(header+1);
2150 + while (!IS_LAST_ENTRY(here)) {
2151 + if (!here->e_hash) {
2152 + /* Block is not shared if an entry's hash value == 0 */
2156 + hash = (hash << BLOCK_HASH_SHIFT) ^
2157 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
2158 + le32_to_cpu(here->e_hash);
2159 + here = EXT2_XATTR_NEXT(here);
2161 + header->h_hash = cpu_to_le32(hash);
2164 +#undef BLOCK_HASH_SHIFT
2167 +init_ext2_xattr(void)
2169 + ext2_xattr_cache = mb_cache_create("ext2_xattr", NULL,
2170 + sizeof(struct mb_cache_entry) +
2171 + sizeof(struct mb_cache_entry_index), 1, 61);
2172 + if (!ext2_xattr_cache)
2179 +exit_ext2_xattr(void)
2181 + mb_cache_destroy(ext2_xattr_cache);
2184 +#else /* CONFIG_EXT2_FS_XATTR_SHARING */
2187 +init_ext2_xattr(void)
2193 +exit_ext2_xattr(void)
2197 +#endif /* CONFIG_EXT2_FS_XATTR_SHARING */
2198 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
2199 +++ linux-2.4.20-root/fs/ext2/xattr_user.c 2003-05-07 18:08:03.000000000 +0800
2202 + * linux/fs/ext2/xattr_user.c
2203 + * Handler for extended user attributes.
2205 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2208 +#include <linux/module.h>
2209 +#include <linux/string.h>
2210 +#include <linux/fs.h>
2211 +#include <linux/ext2_fs.h>
2212 +#include <linux/ext2_xattr.h>
2214 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2215 +# include <linux/ext2_acl.h>
2218 +#define XATTR_USER_PREFIX "user."
2221 +ext2_xattr_user_list(char *list, struct inode *inode,
2222 + const char *name, int name_len)
2224 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
2226 + if (!test_opt(inode->i_sb, XATTR_USER))
2230 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
2231 + memcpy(list+prefix_len, name, name_len);
2232 + list[prefix_len + name_len] = '\0';
2234 + return prefix_len + name_len + 1;
2238 +ext2_xattr_user_get(struct inode *inode, const char *name,
2239 + void *buffer, size_t size)
2243 + if (strcmp(name, "") == 0)
2245 + if (!test_opt(inode->i_sb, XATTR_USER))
2247 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2248 + error = ext2_permission_locked(inode, MAY_READ);
2250 + error = permission(inode, MAY_READ);
2255 + return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name,
2260 +ext2_xattr_user_set(struct inode *inode, const char *name,
2261 + const void *value, size_t size, int flags)
2265 + if (strcmp(name, "") == 0)
2267 + if (!test_opt(inode->i_sb, XATTR_USER))
2269 + if ( !S_ISREG(inode->i_mode) &&
2270 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
2272 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2273 + error = ext2_permission_locked(inode, MAY_WRITE);
2275 + error = permission(inode, MAY_WRITE);
2280 + return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name,
2281 + value, size, flags);
2284 +struct ext2_xattr_handler ext2_xattr_user_handler = {
2285 + prefix: XATTR_USER_PREFIX,
2286 + list: ext2_xattr_user_list,
2287 + get: ext2_xattr_user_get,
2288 + set: ext2_xattr_user_set,
2292 +init_ext2_xattr_user(void)
2294 + return ext2_xattr_register(EXT2_XATTR_INDEX_USER,
2295 + &ext2_xattr_user_handler);
2299 +exit_ext2_xattr_user(void)
2301 + ext2_xattr_unregister(EXT2_XATTR_INDEX_USER,
2302 + &ext2_xattr_user_handler);
2304 --- linux-2.4.20/fs/ext3/Makefile~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2305 +++ linux-2.4.20-root/fs/ext3/Makefile 2003-05-07 18:10:33.000000000 +0800
2308 -# Makefile for the linux ext2-filesystem routines.
2309 +# Makefile for the linux ext3-filesystem routines.
2311 # Note! Dependencies are done automagically by 'make dep', which also
2312 # removes any old dependencies. DON'T put your own dependencies here
2317 -export-objs := super.o inode.o
2318 +export-objs := ext3-exports.o
2320 obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
2321 - ioctl.o namei.o super.o symlink.o hash.o
2322 + ioctl.o namei.o super.o symlink.o hash.o ext3-exports.o
2323 obj-m := $(O_TARGET)
2325 +export-objs += xattr.o
2326 +obj-$(CONFIG_EXT3_FS_XATTR) += xattr.o
2327 +obj-$(CONFIG_EXT3_FS_XATTR_USER) += xattr_user.o
2329 include $(TOPDIR)/Rules.make
2330 --- linux-2.4.20/fs/ext3/file.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2331 +++ linux-2.4.20-root/fs/ext3/file.c 2003-05-07 18:08:03.000000000 +0800
2333 #include <linux/locks.h>
2334 #include <linux/jbd.h>
2335 #include <linux/ext3_fs.h>
2336 +#include <linux/ext3_xattr.h>
2337 #include <linux/ext3_jbd.h>
2338 #include <linux/smp_lock.h>
2340 @@ -126,5 +127,9 @@ struct file_operations ext3_file_operati
2341 struct inode_operations ext3_file_inode_operations = {
2342 truncate: ext3_truncate, /* BKL held */
2343 setattr: ext3_setattr, /* BKL held */
2344 + setxattr: ext3_setxattr, /* BKL held */
2345 + getxattr: ext3_getxattr, /* BKL held */
2346 + listxattr: ext3_listxattr, /* BKL held */
2347 + removexattr: ext3_removexattr, /* BKL held */
2350 --- linux-2.4.20/fs/ext3/ialloc.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
2351 +++ linux-2.4.20-root/fs/ext3/ialloc.c 2003-05-07 18:08:03.000000000 +0800
2353 #include <linux/jbd.h>
2354 #include <linux/ext3_fs.h>
2355 #include <linux/ext3_jbd.h>
2356 +#include <linux/ext3_xattr.h>
2357 #include <linux/stat.h>
2358 #include <linux/string.h>
2359 #include <linux/locks.h>
2360 @@ -216,6 +217,7 @@ void ext3_free_inode (handle_t *handle,
2361 * as writing the quota to disk may need the lock as well.
2364 + ext3_xattr_delete_inode(handle, inode);
2365 DQUOT_FREE_INODE(inode);
2368 --- linux-2.4.20/fs/ext3/inode.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
2369 +++ linux-2.4.20-root/fs/ext3/inode.c 2003-05-07 18:08:03.000000000 +0800
2372 #undef SEARCH_FROM_ZERO
2375 + * Test whether an inode is a fast symlink.
2377 +static inline int ext3_inode_is_fast_symlink(struct inode *inode)
2379 + int ea_blocks = inode->u.ext3_i.i_file_acl ?
2380 + (inode->i_sb->s_blocksize >> 9) : 0;
2382 + return (S_ISLNK(inode->i_mode) &&
2383 + inode->i_blocks - ea_blocks == 0);
2386 /* The ext3 forget function must perform a revoke if we are freeing data
2387 * which has been journaled. Metadata (eg. indirect blocks) must be
2388 * revoked in all cases.
2390 * still needs to be revoked.
2393 -static int ext3_forget(handle_t *handle, int is_metadata,
2394 +int ext3_forget(handle_t *handle, int is_metadata,
2395 struct inode *inode, struct buffer_head *bh,
2398 @@ -164,9 +176,7 @@ void ext3_delete_inode (struct inode * i
2402 - if (is_bad_inode(inode) ||
2403 - inode->i_ino == EXT3_ACL_IDX_INO ||
2404 - inode->i_ino == EXT3_ACL_DATA_INO)
2405 + if (is_bad_inode(inode))
2409 @@ -1855,6 +1865,8 @@ void ext3_truncate(struct inode * inode)
2410 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
2411 S_ISLNK(inode->i_mode)))
2413 + if (ext3_inode_is_fast_symlink(inode))
2415 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2418 @@ -2002,8 +2014,6 @@ int ext3_get_inode_loc (struct inode *in
2419 struct ext3_group_desc * gdp;
2421 if ((inode->i_ino != EXT3_ROOT_INO &&
2422 - inode->i_ino != EXT3_ACL_IDX_INO &&
2423 - inode->i_ino != EXT3_ACL_DATA_INO &&
2424 inode->i_ino != EXT3_JOURNAL_INO &&
2425 inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
2426 inode->i_ino > le32_to_cpu(
2427 @@ -2130,10 +2140,7 @@ void ext3_read_inode(struct inode * inod
2431 - if (inode->i_ino == EXT3_ACL_IDX_INO ||
2432 - inode->i_ino == EXT3_ACL_DATA_INO)
2433 - /* Nothing to do */ ;
2434 - else if (S_ISREG(inode->i_mode)) {
2435 + if (S_ISREG(inode->i_mode)) {
2436 inode->i_op = &ext3_file_inode_operations;
2437 inode->i_fop = &ext3_file_operations;
2438 inode->i_mapping->a_ops = &ext3_aops;
2439 @@ -2141,15 +2148,17 @@ void ext3_read_inode(struct inode * inod
2440 inode->i_op = &ext3_dir_inode_operations;
2441 inode->i_fop = &ext3_dir_operations;
2442 } else if (S_ISLNK(inode->i_mode)) {
2443 - if (!inode->i_blocks)
2444 + if (ext3_inode_is_fast_symlink(inode))
2445 inode->i_op = &ext3_fast_symlink_inode_operations;
2447 - inode->i_op = &page_symlink_inode_operations;
2448 + inode->i_op = &ext3_symlink_inode_operations;
2449 inode->i_mapping->a_ops = &ext3_aops;
2453 + inode->i_op = &ext3_special_inode_operations;
2454 init_special_inode(inode, inode->i_mode,
2455 le32_to_cpu(iloc.raw_inode->i_block[0]));
2457 /* inode->i_attr_flags = 0; unused */
2458 if (inode->u.ext3_i.i_flags & EXT3_SYNC_FL) {
2459 /* inode->i_attr_flags |= ATTR_FLAG_SYNCRONOUS; unused */
2460 --- linux-2.4.20/fs/ext3/namei.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:05.000000000 +0800
2461 +++ linux-2.4.20-root/fs/ext3/namei.c 2003-05-07 18:08:03.000000000 +0800
2463 #include <linux/sched.h>
2464 #include <linux/ext3_fs.h>
2465 #include <linux/ext3_jbd.h>
2466 +#include <linux/ext3_xattr.h>
2467 #include <linux/fcntl.h>
2468 #include <linux/stat.h>
2469 #include <linux/string.h>
2470 @@ -1611,7 +1612,7 @@ static int ext3_mkdir(struct inode * dir
2474 - inode = ext3_new_inode (handle, dir, S_IFDIR);
2475 + inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
2476 err = PTR_ERR(inode);
2479 @@ -1619,7 +1620,6 @@ static int ext3_mkdir(struct inode * dir
2480 inode->i_op = &ext3_dir_inode_operations;
2481 inode->i_fop = &ext3_dir_operations;
2482 inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
2483 - inode->i_blocks = 0;
2484 dir_block = ext3_bread (handle, inode, 0, 1, &err);
2486 inode->i_nlink--; /* is this nlink == 0? */
2487 @@ -1646,9 +1646,6 @@ static int ext3_mkdir(struct inode * dir
2488 BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
2489 ext3_journal_dirty_metadata(handle, dir_block);
2491 - inode->i_mode = S_IFDIR | mode;
2492 - if (dir->i_mode & S_ISGID)
2493 - inode->i_mode |= S_ISGID;
2494 ext3_mark_inode_dirty(handle, inode);
2495 err = ext3_add_entry (handle, dentry, inode);
2497 @@ -2017,7 +2014,7 @@ static int ext3_symlink (struct inode *
2500 if (l > sizeof (EXT3_I(inode)->i_data)) {
2501 - inode->i_op = &page_symlink_inode_operations;
2502 + inode->i_op = &ext3_symlink_inode_operations;
2503 inode->i_mapping->a_ops = &ext3_aops;
2505 * block_symlink() calls back into ext3_prepare/commit_write.
2506 @@ -2244,4 +2241,16 @@ struct inode_operations ext3_dir_inode_o
2507 rmdir: ext3_rmdir, /* BKL held */
2508 mknod: ext3_mknod, /* BKL held */
2509 rename: ext3_rename, /* BKL held */
2510 + setxattr: ext3_setxattr, /* BKL held */
2511 + getxattr: ext3_getxattr, /* BKL held */
2512 + listxattr: ext3_listxattr, /* BKL held */
2513 + removexattr: ext3_removexattr, /* BKL held */
2516 +struct inode_operations ext3_special_inode_operations = {
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 --- linux-2.4.20/fs/ext3/super.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2524 +++ linux-2.4.20-root/fs/ext3/super.c 2003-05-07 18:08:39.000000000 +0800
2526 #include <linux/jbd.h>
2527 #include <linux/ext3_fs.h>
2528 #include <linux/ext3_jbd.h>
2529 +#include <linux/ext3_xattr.h>
2530 #include <linux/slab.h>
2531 #include <linux/init.h>
2532 #include <linux/locks.h>
2533 @@ -404,6 +405,7 @@ void ext3_put_super (struct super_block
2534 kdev_t j_dev = sbi->s_journal->j_dev;
2537 + ext3_xattr_put_super(sb);
2538 journal_destroy(sbi->s_journal);
2539 if (!(sb->s_flags & MS_RDONLY)) {
2540 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
2541 @@ -499,6 +501,7 @@ static int parse_options (char * options
2544 unsigned long *mount_options = &sbi->s_mount_opt;
2546 uid_t *resuid = &sbi->s_resuid;
2547 gid_t *resgid = &sbi->s_resgid;
2549 @@ -511,6 +514,13 @@ static int parse_options (char * options
2550 this_char = strtok (NULL, ",")) {
2551 if ((value = strchr (this_char, '=')) != NULL)
2553 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2554 + if (!strcmp (this_char, "user_xattr"))
2555 + set_opt (*mount_options, XATTR_USER);
2556 + else if (!strcmp (this_char, "nouser_xattr"))
2557 + clear_opt (*mount_options, XATTR_USER);
2560 if (!strcmp (this_char, "bsddf"))
2561 clear_opt (*mount_options, MINIX_DF);
2562 else if (!strcmp (this_char, "nouid32")) {
2563 @@ -928,6 +938,12 @@ struct super_block * ext3_read_super (st
2564 sbi->s_mount_opt = 0;
2565 sbi->s_resuid = EXT3_DEF_RESUID;
2566 sbi->s_resgid = EXT3_DEF_RESGID;
2568 + /* Default extended attribute flags */
2569 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2570 + /* set_opt(sbi->s_mount_opt, XATTR_USER); */
2573 if (!parse_options ((char *) data, &sb_block, sbi, &journal_inum, 0)) {
2576 @@ -1767,17 +1783,29 @@ static DECLARE_FSTYPE_DEV(ext3_fs_type,
2578 static int __init init_ext3_fs(void)
2580 - return register_filesystem(&ext3_fs_type);
2581 + int error = init_ext3_xattr();
2584 + error = init_ext3_xattr_user();
2587 + error = register_filesystem(&ext3_fs_type);
2591 + exit_ext3_xattr_user();
2593 + exit_ext3_xattr();
2597 static void __exit exit_ext3_fs(void)
2599 unregister_filesystem(&ext3_fs_type);
2600 + exit_ext3_xattr_user();
2601 + exit_ext3_xattr();
2604 -EXPORT_SYMBOL(ext3_force_commit);
2605 -EXPORT_SYMBOL(ext3_bread);
2607 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
2608 MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
2609 MODULE_LICENSE("GPL");
2610 --- linux-2.4.20/fs/ext3/symlink.c~linux-2.4.20-xattr-0.8.54 2001-11-10 06:25:04.000000000 +0800
2611 +++ linux-2.4.20-root/fs/ext3/symlink.c 2003-05-07 18:08:03.000000000 +0800
2613 #include <linux/fs.h>
2614 #include <linux/jbd.h>
2615 #include <linux/ext3_fs.h>
2616 +#include <linux/ext3_xattr.h>
2618 static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen)
2620 @@ -33,7 +34,20 @@ static int ext3_follow_link(struct dentr
2621 return vfs_follow_link(nd, s);
2624 +struct inode_operations ext3_symlink_inode_operations = {
2625 + readlink: page_readlink, /* BKL not held. Don't need */
2626 + follow_link: page_follow_link, /* BKL not held. Don't need */
2627 + setxattr: ext3_setxattr, /* BKL held */
2628 + getxattr: ext3_getxattr, /* BKL held */
2629 + listxattr: ext3_listxattr, /* BKL held */
2630 + removexattr: ext3_removexattr, /* BKL held */
2633 struct inode_operations ext3_fast_symlink_inode_operations = {
2634 readlink: ext3_readlink, /* BKL not held. Don't need */
2635 follow_link: ext3_follow_link, /* BKL not held. Don't need */
2636 + setxattr: ext3_setxattr, /* BKL held */
2637 + getxattr: ext3_getxattr, /* BKL held */
2638 + listxattr: ext3_listxattr, /* BKL held */
2639 + removexattr: ext3_removexattr, /* BKL held */
2641 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
2642 +++ linux-2.4.20-root/fs/ext3/xattr.c 2003-05-07 18:09:23.000000000 +0800
2645 + * linux/fs/ext3/xattr.c
2647 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2649 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
2650 + * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
2651 + * Extended attributes for symlinks and special files added per
2652 + * suggestion of Luka Renko <luka.renko@hermes.si>.
2656 + * Extended attributes are stored on disk blocks allocated outside of
2657 + * any inode. The i_file_acl field is then made to point to this allocated
2658 + * block. If all extended attributes of an inode are identical, these
2659 + * inodes may share the same extended attribute block. Such situations
2660 + * are automatically detected by keeping a cache of recent attribute block
2661 + * numbers and hashes over the block's contents in memory.
2664 + * Extended attribute block layout:
2666 + * +------------------+
2669 + * | entry 2 | | growing downwards
2671 + * | four null bytes |
2674 + * | value 3 | | growing upwards
2676 + * +------------------+
2678 + * The block header is followed by multiple entry descriptors. These entry
2679 + * descriptors are variable in size, and alligned to EXT3_XATTR_PAD
2680 + * byte boundaries. The entry descriptors are sorted by attribute name,
2681 + * so that two extended attribute blocks can be compared efficiently.
2683 + * Attribute values are aligned to the end of the block, stored in
2684 + * no specific order. They are also padded to EXT3_XATTR_PAD byte
2685 + * boundaries. No additional gaps are left between them.
2687 + * Locking strategy
2688 + * ----------------
2689 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
2690 + * the xattr inode operations are called, so we are guaranteed that only one
2691 + * processes accesses extended attributes of an inode at any time.
2693 + * For writing we also grab the ext3_xattr_sem semaphore. This ensures that
2694 + * only a single process is modifying an extended attribute block, even
2695 + * if the block is shared among inodes.
2697 + * Note for porting to 2.5
2698 + * -----------------------
2699 + * The BKL will no longer be held in the xattr inode operations.
2702 +#include <linux/module.h>
2703 +#include <linux/fs.h>
2704 +#include <linux/locks.h>
2705 +#include <linux/slab.h>
2706 +#include <linux/ext3_jbd.h>
2707 +#include <linux/ext3_fs.h>
2708 +#include <linux/ext3_xattr.h>
2709 +#include <linux/mbcache.h>
2710 +#include <linux/quotaops.h>
2711 +#include <asm/semaphore.h>
2712 +#include <linux/compatmac.h>
2714 +#define EXT3_EA_USER "user."
2716 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
2717 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
2720 +#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data))
2721 +#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr))
2722 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
2723 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
2725 +#ifdef EXT3_XATTR_DEBUG
2726 +# define ea_idebug(inode, f...) do { \
2727 + printk(KERN_DEBUG "inode %s:%ld: ", \
2728 + kdevname(inode->i_dev), inode->i_ino); \
2732 +# define ea_bdebug(bh, f...) do { \
2733 + printk(KERN_DEBUG "block %s:%ld: ", \
2734 + kdevname(bh->b_dev), bh->b_blocknr); \
2739 +# define ea_idebug(f...)
2740 +# define ea_bdebug(f...)
2743 +static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *,
2744 + struct ext3_xattr_header *);
2746 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
2748 +static int ext3_xattr_cache_insert(struct buffer_head *);
2749 +static struct buffer_head *ext3_xattr_cache_find(struct inode *,
2750 + struct ext3_xattr_header *);
2751 +static void ext3_xattr_cache_remove(struct buffer_head *);
2752 +static void ext3_xattr_rehash(struct ext3_xattr_header *,
2753 + struct ext3_xattr_entry *);
2755 +static struct mb_cache *ext3_xattr_cache;
2758 +# define ext3_xattr_cache_insert(bh) 0
2759 +# define ext3_xattr_cache_find(inode, header) NULL
2760 +# define ext3_xattr_cache_remove(bh) while(0) {}
2761 +# define ext3_xattr_rehash(header, entry) while(0) {}
2765 + * If a file system does not share extended attributes among inodes,
2766 + * we should not need the ext3_xattr_sem semaphore. However, the
2767 + * filesystem may still contain shared blocks, so we always take
2771 +DECLARE_MUTEX(ext3_xattr_sem);
2774 +ext3_xattr_new_block(handle_t *handle, struct inode *inode,
2775 + int * errp, int force)
2777 + struct super_block *sb = inode->i_sb;
2778 + int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
2779 + EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb);
2781 + /* How can we enforce the allocation? */
2782 + int block = ext3_new_block(handle, inode, goal, 0, 0, errp);
2785 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2791 +ext3_xattr_quota_alloc(struct inode *inode, int force)
2793 + /* How can we enforce the allocation? */
2795 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
2797 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2799 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
2807 +ext3_xattr_quota_free(struct inode *inode)
2809 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
2810 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2814 +ext3_xattr_free_block(handle_t *handle, struct inode * inode,
2815 + unsigned long block)
2817 + ext3_free_blocks(handle, inode, block, 1);
2818 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2822 +# define ext3_xattr_quota_free(inode) \
2823 + DQUOT_FREE_BLOCK(inode, 1)
2824 +# define ext3_xattr_free_block(handle, inode, block) \
2825 + ext3_free_blocks(handle, inode, block, 1)
2828 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
2830 +static inline struct buffer_head *
2831 +sb_bread(struct super_block *sb, int block)
2833 + return bread(sb->s_dev, block, sb->s_blocksize);
2836 +static inline struct buffer_head *
2837 +sb_getblk(struct super_block *sb, int block)
2839 + return getblk(sb->s_dev, block, sb->s_blocksize);
2844 +struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
2845 +rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
2848 +ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
2850 + int error = -EINVAL;
2852 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2853 + write_lock(&ext3_handler_lock);
2854 + if (!ext3_xattr_handlers[name_index-1]) {
2855 + ext3_xattr_handlers[name_index-1] = handler;
2858 + write_unlock(&ext3_handler_lock);
2864 +ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
2866 + if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
2867 + write_lock(&ext3_handler_lock);
2868 + ext3_xattr_handlers[name_index-1] = NULL;
2869 + write_unlock(&ext3_handler_lock);
2873 +static inline const char *
2874 +strcmp_prefix(const char *a, const char *a_prefix)
2876 + while (*a_prefix && *a == *a_prefix) {
2880 + return *a_prefix ? NULL : a;
2884 + * Decode the extended attribute name, and translate it into
2885 + * the name_index and name suffix.
2887 +static inline struct ext3_xattr_handler *
2888 +ext3_xattr_resolve_name(const char **name)
2890 + struct ext3_xattr_handler *handler = NULL;
2895 + read_lock(&ext3_handler_lock);
2896 + for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
2897 + if (ext3_xattr_handlers[i]) {
2898 + const char *n = strcmp_prefix(*name,
2899 + ext3_xattr_handlers[i]->prefix);
2901 + handler = ext3_xattr_handlers[i];
2907 + read_unlock(&ext3_handler_lock);
2911 +static inline struct ext3_xattr_handler *
2912 +ext3_xattr_handler(int name_index)
2914 + struct ext3_xattr_handler *handler = NULL;
2915 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2916 + read_lock(&ext3_handler_lock);
2917 + handler = ext3_xattr_handlers[name_index-1];
2918 + read_unlock(&ext3_handler_lock);
2924 + * Inode operation getxattr()
2926 + * dentry->d_inode->i_sem down
2927 + * BKL held [before 2.5.x]
2930 +ext3_getxattr(struct dentry *dentry, const char *name,
2931 + void *buffer, size_t size)
2933 + struct ext3_xattr_handler *handler;
2934 + struct inode *inode = dentry->d_inode;
2936 + handler = ext3_xattr_resolve_name(&name);
2939 + return handler->get(inode, name, buffer, size);
2943 + * Inode operation listxattr()
2945 + * dentry->d_inode->i_sem down
2946 + * BKL held [before 2.5.x]
2949 +ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
2951 + return ext3_xattr_list(dentry->d_inode, buffer, size);
2955 + * Inode operation setxattr()
2957 + * dentry->d_inode->i_sem down
2958 + * BKL held [before 2.5.x]
2961 +ext3_setxattr(struct dentry *dentry, const char *name,
2962 + const void *value, size_t size, int flags)
2964 + struct ext3_xattr_handler *handler;
2965 + struct inode *inode = dentry->d_inode;
2968 + value = ""; /* empty EA, do not remove */
2969 + handler = ext3_xattr_resolve_name(&name);
2972 + return handler->set(inode, name, value, size, flags);
2976 + * Inode operation removexattr()
2978 + * dentry->d_inode->i_sem down
2979 + * BKL held [before 2.5.x]
2982 +ext3_removexattr(struct dentry *dentry, const char *name)
2984 + struct ext3_xattr_handler *handler;
2985 + struct inode *inode = dentry->d_inode;
2987 + handler = ext3_xattr_resolve_name(&name);
2990 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
2994 + * ext3_xattr_get()
2996 + * Copy an extended attribute into the buffer
2997 + * provided, or compute the buffer size required.
2998 + * Buffer is NULL to compute the size of the buffer required.
3000 + * Returns a negative error number on failure, or the number of bytes
3001 + * used / required on success.
3004 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
3005 + void *buffer, size_t buffer_size)
3007 + struct buffer_head *bh = NULL;
3008 + struct ext3_xattr_entry *entry;
3009 + unsigned int block, size;
3011 + int name_len, error;
3013 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
3014 + name_index, name, buffer, (long)buffer_size);
3018 + if (!EXT3_I(inode)->i_file_acl)
3020 + block = EXT3_I(inode)->i_file_acl;
3021 + ea_idebug(inode, "reading block %d", block);
3022 + bh = sb_bread(inode->i_sb, block);
3025 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3026 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
3027 + end = bh->b_data + bh->b_size;
3028 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3029 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3030 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_get",
3031 + "inode %ld: bad block %d", inode->i_ino, block);
3035 + /* find named attribute */
3036 + name_len = strlen(name);
3039 + if (name_len > 255)
3041 + entry = FIRST_ENTRY(bh);
3042 + while (!IS_LAST_ENTRY(entry)) {
3043 + struct ext3_xattr_entry *next =
3044 + EXT3_XATTR_NEXT(entry);
3045 + if ((char *)next >= end)
3047 + if (name_index == entry->e_name_index &&
3048 + name_len == entry->e_name_len &&
3049 + memcmp(name, entry->e_name, name_len) == 0)
3053 + /* Check the remaining name entries */
3054 + while (!IS_LAST_ENTRY(entry)) {
3055 + struct ext3_xattr_entry *next =
3056 + EXT3_XATTR_NEXT(entry);
3057 + if ((char *)next >= end)
3061 + if (ext3_xattr_cache_insert(bh))
3062 + ea_idebug(inode, "cache insert failed");
3066 + /* check the buffer size */
3067 + if (entry->e_value_block != 0)
3069 + size = le32_to_cpu(entry->e_value_size);
3070 + if (size > inode->i_sb->s_blocksize ||
3071 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
3074 + if (ext3_xattr_cache_insert(bh))
3075 + ea_idebug(inode, "cache insert failed");
3078 + if (size > buffer_size)
3080 + /* return value of attribute */
3081 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
3093 + * ext3_xattr_list()
3095 + * Copy a list of attribute names into the buffer
3096 + * provided, or compute the buffer size required.
3097 + * Buffer is NULL to compute the size of the buffer required.
3099 + * Returns a negative error number on failure, or the number of bytes
3100 + * used / required on success.
3103 +ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
3105 + struct buffer_head *bh = NULL;
3106 + struct ext3_xattr_entry *entry;
3107 + unsigned int block, size = 0;
3111 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
3112 + buffer, (long)buffer_size);
3114 + if (!EXT3_I(inode)->i_file_acl)
3116 + block = EXT3_I(inode)->i_file_acl;
3117 + ea_idebug(inode, "reading block %d", block);
3118 + bh = sb_bread(inode->i_sb, block);
3121 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3122 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
3123 + end = bh->b_data + bh->b_size;
3124 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3125 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3126 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_list",
3127 + "inode %ld: bad block %d", inode->i_ino, block);
3131 + /* compute the size required for the list of attribute names */
3132 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
3133 + entry = EXT3_XATTR_NEXT(entry)) {
3134 + struct ext3_xattr_handler *handler;
3135 + struct ext3_xattr_entry *next =
3136 + EXT3_XATTR_NEXT(entry);
3137 + if ((char *)next >= end)
3140 + handler = ext3_xattr_handler(entry->e_name_index);
3142 + size += handler->list(NULL, inode, entry->e_name,
3143 + entry->e_name_len);
3146 + if (ext3_xattr_cache_insert(bh))
3147 + ea_idebug(inode, "cache insert failed");
3153 + if (size > buffer_size)
3157 + /* list the attribute names */
3159 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
3160 + entry = EXT3_XATTR_NEXT(entry)) {
3161 + struct ext3_xattr_handler *handler;
3163 + handler = ext3_xattr_handler(entry->e_name_index);
3165 + buf += handler->list(buf, inode, entry->e_name,
3166 + entry->e_name_len);
3177 + * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is
3178 + * not set, set it.
3180 +static void ext3_xattr_update_super_block(handle_t *handle,
3181 + struct super_block *sb)
3183 + if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
3187 + ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
3188 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
3189 + EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR;
3191 + EXT3_SB(sb)->s_es->s_feature_compat |=
3192 + cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
3194 + ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
3199 + * ext3_xattr_set()
3201 + * Create, replace or remove an extended attribute for this inode. Buffer
3202 + * is NULL to remove an existing extended attribute, and non-NULL to
3203 + * either replace an existing extended attribute, or create a new extended
3204 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
3205 + * specify that an extended attribute must exist and must not exist
3206 + * previous to the call, respectively.
3208 + * Returns 0, or a negative error number on failure.
3211 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
3212 + const char *name, const void *value, size_t value_len, int flags)
3214 + struct super_block *sb = inode->i_sb;
3215 + struct buffer_head *bh = NULL;
3216 + struct ext3_xattr_header *header = NULL;
3217 + struct ext3_xattr_entry *here, *last;
3218 + unsigned int name_len;
3219 + int block = EXT3_I(inode)->i_file_acl;
3220 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
3224 + * header -- Points either into bh, or to a temporarily
3225 + * allocated buffer.
3226 + * here -- The named entry found, or the place for inserting, within
3227 + * the block pointed to by header.
3228 + * last -- Points right after the last named entry within the block
3229 + * pointed to by header.
3230 + * min_offs -- The offset of the first value (values are aligned
3231 + * towards the end of the block).
3232 + * end -- Points right after the block pointed to by header.
3235 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
3236 + name_index, name, value, (long)value_len);
3238 + if (IS_RDONLY(inode))
3240 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3242 + if (value == NULL)
3246 + name_len = strlen(name);
3247 + if (name_len > 255 || value_len > sb->s_blocksize)
3249 + down(&ext3_xattr_sem);
3252 + /* The inode already has an extended attribute block. */
3253 + bh = sb_bread(sb, block);
3257 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3258 + atomic_read(&(bh->b_count)),
3259 + le32_to_cpu(HDR(bh)->h_refcount));
3261 + end = bh->b_data + bh->b_size;
3262 + if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3263 + header->h_blocks != cpu_to_le32(1)) {
3264 +bad_block: ext3_error(sb, "ext3_xattr_set",
3265 + "inode %ld: bad block %d", inode->i_ino, block);
3269 + /* Find the named attribute. */
3270 + here = FIRST_ENTRY(bh);
3271 + while (!IS_LAST_ENTRY(here)) {
3272 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here);
3273 + if ((char *)next >= end)
3275 + if (!here->e_value_block && here->e_value_size) {
3276 + int offs = le16_to_cpu(here->e_value_offs);
3277 + if (offs < min_offs)
3280 + not_found = name_index - here->e_name_index;
3282 + not_found = name_len - here->e_name_len;
3284 + not_found = memcmp(name, here->e_name,name_len);
3285 + if (not_found <= 0)
3290 + /* We still need to compute min_offs and last. */
3291 + while (!IS_LAST_ENTRY(last)) {
3292 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last);
3293 + if ((char *)next >= end)
3295 + if (!last->e_value_block && last->e_value_size) {
3296 + int offs = le16_to_cpu(last->e_value_offs);
3297 + if (offs < min_offs)
3303 + /* Check whether we have enough space left. */
3304 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
3306 + /* We will use a new extended attribute block. */
3307 + free = sb->s_blocksize -
3308 + sizeof(struct ext3_xattr_header) - sizeof(__u32);
3309 + here = last = NULL; /* avoid gcc uninitialized warning. */
3313 + /* Request to remove a nonexistent attribute? */
3315 + if (flags & XATTR_REPLACE)
3318 + if (value == NULL)
3321 + free -= EXT3_XATTR_LEN(name_len);
3323 + /* Request to create an existing attribute? */
3325 + if (flags & XATTR_CREATE)
3327 + if (!here->e_value_block && here->e_value_size) {
3328 + unsigned int size = le32_to_cpu(here->e_value_size);
3330 + if (le16_to_cpu(here->e_value_offs) + size >
3331 + sb->s_blocksize || size > sb->s_blocksize)
3333 + free += EXT3_XATTR_SIZE(size);
3336 + free -= EXT3_XATTR_SIZE(value_len);
3341 + /* Here we know that we can set the new attribute. */
3344 + if (header->h_refcount == cpu_to_le32(1)) {
3345 + ea_bdebug(bh, "modifying in-place");
3346 + ext3_xattr_cache_remove(bh);
3347 + error = ext3_journal_get_write_access(handle, bh);
3353 + ea_bdebug(bh, "cloning");
3354 + header = kmalloc(bh->b_size, GFP_KERNEL);
3356 + if (header == NULL)
3358 + memcpy(header, HDR(bh), bh->b_size);
3359 + header->h_refcount = cpu_to_le32(1);
3360 + offset = (char *)header - bh->b_data;
3361 + here = ENTRY((char *)here + offset);
3362 + last = ENTRY((char *)last + offset);
3365 + /* Allocate a buffer where we construct the new block. */
3366 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
3368 + if (header == NULL)
3370 + memset(header, 0, sb->s_blocksize);
3371 + end = (char *)header + sb->s_blocksize;
3372 + header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
3373 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
3374 + last = here = ENTRY(header+1);
3378 + /* Insert the new name. */
3379 + int size = EXT3_XATTR_LEN(name_len);
3380 + int rest = (char *)last - (char *)here;
3381 + memmove((char *)here + size, here, rest);
3382 + memset(here, 0, size);
3383 + here->e_name_index = name_index;
3384 + here->e_name_len = name_len;
3385 + memcpy(here->e_name, name, name_len);
3387 + /* Remove the old value. */
3388 + if (!here->e_value_block && here->e_value_size) {
3389 + char *first_val = (char *)header + min_offs;
3390 + int offs = le16_to_cpu(here->e_value_offs);
3391 + char *val = (char *)header + offs;
3392 + size_t size = EXT3_XATTR_SIZE(
3393 + le32_to_cpu(here->e_value_size));
3394 + memmove(first_val + size, first_val, val - first_val);
3395 + memset(first_val, 0, size);
3396 + here->e_value_offs = 0;
3399 + /* Adjust all value offsets. */
3400 + last = ENTRY(header+1);
3401 + while (!IS_LAST_ENTRY(last)) {
3402 + int o = le16_to_cpu(last->e_value_offs);
3403 + if (!last->e_value_block && o < offs)
3404 + last->e_value_offs =
3405 + cpu_to_le16(o + size);
3406 + last = EXT3_XATTR_NEXT(last);
3409 + if (value == NULL) {
3410 + /* Remove this attribute. */
3411 + if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) {
3412 + /* This block is now empty. */
3413 + error = ext3_xattr_set2(handle, inode, bh,NULL);
3416 + /* Remove the old name. */
3417 + int size = EXT3_XATTR_LEN(name_len);
3418 + last = ENTRY((char *)last - size);
3419 + memmove(here, (char*)here + size,
3420 + (char*)last - (char*)here);
3421 + memset(last, 0, size);
3426 + if (value != NULL) {
3427 + /* Insert the new value. */
3428 + here->e_value_size = cpu_to_le32(value_len);
3430 + size_t size = EXT3_XATTR_SIZE(value_len);
3431 + char *val = (char *)header + min_offs - size;
3432 + here->e_value_offs =
3433 + cpu_to_le16((char *)val - (char *)header);
3434 + memset(val + size - EXT3_XATTR_PAD, 0,
3435 + EXT3_XATTR_PAD); /* Clear the pad bytes. */
3436 + memcpy(val, value, value_len);
3439 + ext3_xattr_rehash(header, here);
3441 + error = ext3_xattr_set2(handle, inode, bh, header);
3445 + if (!(bh && header == HDR(bh)))
3447 + up(&ext3_xattr_sem);
3453 + * Second half of ext3_xattr_set(): Update the file system.
3456 +ext3_xattr_set2(handle_t *handle, struct inode *inode,
3457 + struct buffer_head *old_bh, struct ext3_xattr_header *header)
3459 + struct super_block *sb = inode->i_sb;
3460 + struct buffer_head *new_bh = NULL;
3464 + new_bh = ext3_xattr_cache_find(inode, header);
3467 + * We found an identical block in the cache.
3468 + * The old block will be released after updating
3471 + ea_bdebug(old_bh, "reusing block %ld",
3472 + new_bh->b_blocknr);
3475 + if (ext3_xattr_quota_alloc(inode, 1))
3478 + error = ext3_journal_get_write_access(handle, new_bh);
3481 + HDR(new_bh)->h_refcount = cpu_to_le32(
3482 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
3483 + ea_bdebug(new_bh, "refcount now=%d",
3484 + le32_to_cpu(HDR(new_bh)->h_refcount));
3485 + } else if (old_bh && header == HDR(old_bh)) {
3486 + /* Keep this block. */
3488 + (void)ext3_xattr_cache_insert(new_bh);
3490 + /* We need to allocate a new block */
3491 + int force = EXT3_I(inode)->i_file_acl != 0;
3492 + int block = ext3_xattr_new_block(handle, inode,
3496 + ea_idebug(inode, "creating block %d", block);
3498 + new_bh = sb_getblk(sb, block);
3500 +getblk_failed: ext3_xattr_free_block(handle, inode, block);
3504 + lock_buffer(new_bh);
3505 + error = ext3_journal_get_create_access(handle, new_bh);
3507 + unlock_buffer(new_bh);
3508 + goto getblk_failed;
3510 + memcpy(new_bh->b_data, header, new_bh->b_size);
3511 + mark_buffer_uptodate(new_bh, 1);
3512 + unlock_buffer(new_bh);
3513 + (void)ext3_xattr_cache_insert(new_bh);
3515 + ext3_xattr_update_super_block(handle, sb);
3517 + error = ext3_journal_dirty_metadata(handle, new_bh);
3522 + /* Update the inode. */
3523 + EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
3524 + inode->i_ctime = CURRENT_TIME;
3525 + ext3_mark_inode_dirty(handle, inode);
3526 + if (IS_SYNC(inode))
3527 + handle->h_sync = 1;
3530 + if (old_bh && old_bh != new_bh) {
3532 + * If there was an old block, and we are not still using it,
3533 + * we now release the old block.
3535 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
3537 + error = ext3_journal_get_write_access(handle, old_bh);
3540 + if (refcount == 1) {
3541 + /* Free the old block. */
3542 + ea_bdebug(old_bh, "freeing");
3543 + ext3_xattr_free_block(handle, inode, old_bh->b_blocknr);
3545 + /* ext3_forget() calls bforget() for us, but we
3546 + let our caller release old_bh, so we need to
3547 + duplicate the handle before. */
3549 + ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr);
3551 + /* Decrement the refcount only. */
3553 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
3554 + ext3_xattr_quota_free(inode);
3555 + ext3_journal_dirty_metadata(handle, old_bh);
3556 + ea_bdebug(old_bh, "refcount now=%d", refcount);
3561 + if (old_bh != new_bh)
3568 + * ext3_xattr_delete_inode()
3570 + * Free extended attribute resources associated with this inode. This
3571 + * is called immediately before an inode is freed.
3574 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
3576 + struct buffer_head *bh;
3577 + unsigned int block = EXT3_I(inode)->i_file_acl;
3581 + down(&ext3_xattr_sem);
3583 + bh = sb_bread(inode->i_sb, block);
3585 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3586 + "inode %ld: block %d read error", inode->i_ino, block);
3589 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
3590 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3591 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3592 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3593 + "inode %ld: bad block %d", inode->i_ino, block);
3596 + ext3_journal_get_write_access(handle, bh);
3597 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
3598 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
3599 + ext3_xattr_cache_remove(bh);
3600 + ext3_xattr_free_block(handle, inode, block);
3601 + ext3_forget(handle, 1, inode, bh, block);
3604 + HDR(bh)->h_refcount = cpu_to_le32(
3605 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
3606 + ext3_journal_dirty_metadata(handle, bh);
3607 + if (IS_SYNC(inode))
3608 + handle->h_sync = 1;
3609 + ext3_xattr_quota_free(inode);
3611 + EXT3_I(inode)->i_file_acl = 0;
3615 + up(&ext3_xattr_sem);
3619 + * ext3_xattr_put_super()
3621 + * This is called when a file system is unmounted.
3624 +ext3_xattr_put_super(struct super_block *sb)
3626 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3627 + mb_cache_shrink(ext3_xattr_cache, sb->s_dev);
3631 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3634 + * ext3_xattr_cache_insert()
3636 + * Create a new entry in the extended attribute cache, and insert
3637 + * it unless such an entry is already in the cache.
3639 + * Returns 0, or a negative error number on failure.
3642 +ext3_xattr_cache_insert(struct buffer_head *bh)
3644 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
3645 + struct mb_cache_entry *ce;
3648 + ce = mb_cache_entry_alloc(ext3_xattr_cache);
3651 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
3653 + mb_cache_entry_free(ce);
3654 + if (error == -EBUSY) {
3655 + ea_bdebug(bh, "already in cache (%d cache entries)",
3656 + atomic_read(&ext3_xattr_cache->c_entry_count));
3660 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
3661 + atomic_read(&ext3_xattr_cache->c_entry_count));
3662 + mb_cache_entry_release(ce);
3668 + * ext3_xattr_cmp()
3670 + * Compare two extended attribute blocks for equality.
3672 + * Returns 0 if the blocks are equal, 1 if they differ, and
3673 + * a negative error number on errors.
3676 +ext3_xattr_cmp(struct ext3_xattr_header *header1,
3677 + struct ext3_xattr_header *header2)
3679 + struct ext3_xattr_entry *entry1, *entry2;
3681 + entry1 = ENTRY(header1+1);
3682 + entry2 = ENTRY(header2+1);
3683 + while (!IS_LAST_ENTRY(entry1)) {
3684 + if (IS_LAST_ENTRY(entry2))
3686 + if (entry1->e_hash != entry2->e_hash ||
3687 + entry1->e_name_len != entry2->e_name_len ||
3688 + entry1->e_value_size != entry2->e_value_size ||
3689 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
3691 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
3693 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
3694 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
3695 + le32_to_cpu(entry1->e_value_size)))
3698 + entry1 = EXT3_XATTR_NEXT(entry1);
3699 + entry2 = EXT3_XATTR_NEXT(entry2);
3701 + if (!IS_LAST_ENTRY(entry2))
3707 + * ext3_xattr_cache_find()
3709 + * Find an identical extended attribute block.
3711 + * Returns a pointer to the block found, or NULL if such a block was
3712 + * not found or an error occurred.
3714 +static struct buffer_head *
3715 +ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header)
3717 + __u32 hash = le32_to_cpu(header->h_hash);
3718 + struct mb_cache_entry *ce;
3720 + if (!header->h_hash)
3721 + return NULL; /* never share */
3722 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
3723 + ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash);
3725 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
3728 + ext3_error(inode->i_sb, "ext3_xattr_cache_find",
3729 + "inode %ld: block %ld read error",
3730 + inode->i_ino, ce->e_block);
3731 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
3732 + EXT3_XATTR_REFCOUNT_MAX) {
3733 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
3734 + le32_to_cpu(HDR(bh)->h_refcount),
3735 + EXT3_XATTR_REFCOUNT_MAX);
3736 + } else if (!ext3_xattr_cmp(header, HDR(bh))) {
3737 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
3738 + mb_cache_entry_release(ce);
3742 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
3748 + * ext3_xattr_cache_remove()
3750 + * Remove the cache entry of a block from the cache. Called when a
3751 + * block becomes invalid.
3754 +ext3_xattr_cache_remove(struct buffer_head *bh)
3756 + struct mb_cache_entry *ce;
3758 + ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr);
3760 + ea_bdebug(bh, "removing (%d cache entries remaining)",
3761 + atomic_read(&ext3_xattr_cache->c_entry_count)-1);
3762 + mb_cache_entry_free(ce);
3764 + ea_bdebug(bh, "no cache entry");
3767 +#define NAME_HASH_SHIFT 5
3768 +#define VALUE_HASH_SHIFT 16
3771 + * ext3_xattr_hash_entry()
3773 + * Compute the hash of an extended attribute.
3775 +static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
3776 + struct ext3_xattr_entry *entry)
3779 + char *name = entry->e_name;
3782 + for (n=0; n < entry->e_name_len; n++) {
3783 + hash = (hash << NAME_HASH_SHIFT) ^
3784 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
3788 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
3789 + __u32 *value = (__u32 *)((char *)header +
3790 + le16_to_cpu(entry->e_value_offs));
3791 + for (n = (le32_to_cpu(entry->e_value_size) +
3792 + EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
3793 + hash = (hash << VALUE_HASH_SHIFT) ^
3794 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
3795 + le32_to_cpu(*value++);
3798 + entry->e_hash = cpu_to_le32(hash);
3801 +#undef NAME_HASH_SHIFT
3802 +#undef VALUE_HASH_SHIFT
3804 +#define BLOCK_HASH_SHIFT 16
3807 + * ext3_xattr_rehash()
3809 + * Re-compute the extended attribute hash value after an entry has changed.
3811 +static void ext3_xattr_rehash(struct ext3_xattr_header *header,
3812 + struct ext3_xattr_entry *entry)
3814 + struct ext3_xattr_entry *here;
3817 + ext3_xattr_hash_entry(header, entry);
3818 + here = ENTRY(header+1);
3819 + while (!IS_LAST_ENTRY(here)) {
3820 + if (!here->e_hash) {
3821 + /* Block is not shared if an entry's hash value == 0 */
3825 + hash = (hash << BLOCK_HASH_SHIFT) ^
3826 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
3827 + le32_to_cpu(here->e_hash);
3828 + here = EXT3_XATTR_NEXT(here);
3830 + header->h_hash = cpu_to_le32(hash);
3833 +#undef BLOCK_HASH_SHIFT
3836 +init_ext3_xattr(void)
3838 + ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
3839 + sizeof(struct mb_cache_entry) +
3840 + sizeof(struct mb_cache_entry_index), 1, 61);
3841 + if (!ext3_xattr_cache)
3848 +exit_ext3_xattr(void)
3850 + if (ext3_xattr_cache)
3851 + mb_cache_destroy(ext3_xattr_cache);
3852 + ext3_xattr_cache = NULL;
3855 +#else /* CONFIG_EXT3_FS_XATTR_SHARING */
3858 +init_ext3_xattr(void)
3864 +exit_ext3_xattr(void)
3868 +#endif /* CONFIG_EXT3_FS_XATTR_SHARING */
3869 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
3870 +++ linux-2.4.20-root/fs/ext3/xattr_user.c 2003-05-07 18:08:03.000000000 +0800
3873 + * linux/fs/ext3/xattr_user.c
3874 + * Handler for extended user attributes.
3876 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
3879 +#include <linux/module.h>
3880 +#include <linux/string.h>
3881 +#include <linux/fs.h>
3882 +#include <linux/ext3_jbd.h>
3883 +#include <linux/ext3_fs.h>
3884 +#include <linux/ext3_xattr.h>
3886 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3887 +# include <linux/ext3_acl.h>
3890 +#define XATTR_USER_PREFIX "user."
3893 +ext3_xattr_user_list(char *list, struct inode *inode,
3894 + const char *name, int name_len)
3896 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
3898 + if (!test_opt(inode->i_sb, XATTR_USER))
3902 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
3903 + memcpy(list+prefix_len, name, name_len);
3904 + list[prefix_len + name_len] = '\0';
3906 + return prefix_len + name_len + 1;
3910 +ext3_xattr_user_get(struct inode *inode, const char *name,
3911 + void *buffer, size_t size)
3915 + if (strcmp(name, "") == 0)
3917 + if (!test_opt(inode->i_sb, XATTR_USER))
3919 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3920 + error = ext3_permission_locked(inode, MAY_READ);
3922 + error = permission(inode, MAY_READ);
3927 + return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name,
3932 +ext3_xattr_user_set(struct inode *inode, const char *name,
3933 + const void *value, size_t size, int flags)
3938 + if (strcmp(name, "") == 0)
3940 + if (!test_opt(inode->i_sb, XATTR_USER))
3942 + if ( !S_ISREG(inode->i_mode) &&
3943 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
3945 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3946 + error = ext3_permission_locked(inode, MAY_WRITE);
3948 + error = permission(inode, MAY_WRITE);
3953 + handle = ext3_journal_start(inode, EXT3_XATTR_TRANS_BLOCKS);
3954 + if (IS_ERR(handle))
3955 + return PTR_ERR(handle);
3956 + error = ext3_xattr_set(handle, inode, EXT3_XATTR_INDEX_USER, name,
3957 + value, size, flags);
3958 + ext3_journal_stop(handle, inode);
3963 +struct ext3_xattr_handler ext3_xattr_user_handler = {
3964 + prefix: XATTR_USER_PREFIX,
3965 + list: ext3_xattr_user_list,
3966 + get: ext3_xattr_user_get,
3967 + set: ext3_xattr_user_set,
3971 +init_ext3_xattr_user(void)
3973 + return ext3_xattr_register(EXT3_XATTR_INDEX_USER,
3974 + &ext3_xattr_user_handler);
3978 +exit_ext3_xattr_user(void)
3980 + ext3_xattr_unregister(EXT3_XATTR_INDEX_USER,
3981 + &ext3_xattr_user_handler);
3983 --- 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
3984 +++ linux-2.4.20-root/fs/jfs/jfs_xattr.h 2003-05-07 18:08:03.000000000 +0800
3985 @@ -52,8 +52,10 @@ struct jfs_ea_list {
3986 #define END_EALIST(ealist) \
3987 ((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist)))
3989 -extern int __jfs_setxattr(struct inode *, const char *, void *, size_t, int);
3990 -extern int jfs_setxattr(struct dentry *, const char *, void *, size_t, int);
3991 +extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t,
3993 +extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
3995 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
3996 extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
3997 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
3998 --- linux-2.4.20/fs/jfs/xattr.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
3999 +++ linux-2.4.20-root/fs/jfs/xattr.c 2003-05-07 18:08:03.000000000 +0800
4000 @@ -641,7 +641,7 @@ static int ea_put(struct inode *inode, s
4003 static int can_set_xattr(struct inode *inode, const char *name,
4004 - void *value, size_t value_len)
4005 + const void *value, size_t value_len)
4007 if (IS_RDONLY(inode))
4009 @@ -660,7 +660,7 @@ static int can_set_xattr(struct inode *i
4010 return permission(inode, MAY_WRITE);
4013 -int __jfs_setxattr(struct inode *inode, const char *name, void *value,
4014 +int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
4015 size_t value_len, int flags)
4017 struct jfs_ea_list *ealist;
4018 @@ -799,7 +799,7 @@ int __jfs_setxattr(struct inode *inode,
4022 -int jfs_setxattr(struct dentry *dentry, const char *name, void *value,
4023 +int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
4024 size_t value_len, int flags)
4026 if (value == NULL) { /* empty EA, do not remove */
4027 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4028 +++ linux-2.4.20-root/fs/mbcache.c 2003-05-07 18:08:03.000000000 +0800
4031 + * linux/fs/mbcache.c
4032 + * (C) 2001-2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
4036 + * Filesystem Meta Information Block Cache (mbcache)
4038 + * The mbcache caches blocks of block devices that need to be located
4039 + * by their device/block number, as well as by other criteria (such
4040 + * as the block's contents).
4042 + * There can only be one cache entry in a cache per device and block number.
4043 + * Additional indexes need not be unique in this sense. The number of
4044 + * additional indexes (=other criteria) can be hardwired at compile time
4045 + * or specified at cache create time.
4047 + * Each cache entry is of fixed size. An entry may be `valid' or `invalid'
4048 + * in the cache. A valid entry is in the main hash tables of the cache,
4049 + * and may also be in the lru list. An invalid entry is not in any hashes
4052 + * A valid cache entry is only in the lru list if no handles refer to it.
4053 + * Invalid cache entries will be freed when the last handle to the cache
4054 + * entry is released. Entries that cannot be freed immediately are put
4055 + * back on the lru list.
4058 +#include <linux/kernel.h>
4059 +#include <linux/module.h>
4061 +#include <linux/fs.h>
4062 +#include <linux/slab.h>
4063 +#include <linux/sched.h>
4064 +#include <linux/cache_def.h>
4065 +#include <linux/version.h>
4066 +#include <linux/init.h>
4067 +#include <linux/mbcache.h>
4070 +#ifdef MB_CACHE_DEBUG
4071 +# define mb_debug(f...) do { \
4072 + printk(KERN_DEBUG f); \
4075 +#define mb_assert(c) do { if (!(c)) \
4076 + printk(KERN_ERR "assertion " #c " failed\n"); \
4079 +# define mb_debug(f...) do { } while(0)
4080 +# define mb_assert(c) do { } while(0)
4082 +#define mb_error(f...) do { \
4083 + printk(KERN_ERR f); \
4087 +MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>");
4088 +MODULE_DESCRIPTION("Meta block cache (for extended attributes)");
4089 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
4090 +MODULE_LICENSE("GPL");
4093 +EXPORT_SYMBOL(mb_cache_create);
4094 +EXPORT_SYMBOL(mb_cache_shrink);
4095 +EXPORT_SYMBOL(mb_cache_destroy);
4096 +EXPORT_SYMBOL(mb_cache_entry_alloc);
4097 +EXPORT_SYMBOL(mb_cache_entry_insert);
4098 +EXPORT_SYMBOL(mb_cache_entry_release);
4099 +EXPORT_SYMBOL(mb_cache_entry_takeout);
4100 +EXPORT_SYMBOL(mb_cache_entry_free);
4101 +EXPORT_SYMBOL(mb_cache_entry_dup);
4102 +EXPORT_SYMBOL(mb_cache_entry_get);
4103 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
4104 +EXPORT_SYMBOL(mb_cache_entry_find_first);
4105 +EXPORT_SYMBOL(mb_cache_entry_find_next);
4110 + * Global data: list of all mbcache's, lru list, and a spinlock for
4111 + * accessing cache data structures on SMP machines. The lru list is
4112 + * global across all mbcaches.
4115 +static LIST_HEAD(mb_cache_list);
4116 +static LIST_HEAD(mb_cache_lru_list);
4117 +static spinlock_t mb_cache_spinlock = SPIN_LOCK_UNLOCKED;
4120 +mb_cache_indexes(struct mb_cache *cache)
4122 +#ifdef MB_CACHE_INDEXES_COUNT
4123 + return MB_CACHE_INDEXES_COUNT;
4125 + return cache->c_indexes_count;
4130 + * What the mbcache registers as to get shrunk dynamically.
4134 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask);
4136 +static struct cache_definition mb_cache_definition = {
4138 + mb_cache_memory_pressure
4143 +__mb_cache_entry_is_hashed(struct mb_cache_entry *ce)
4145 + return !list_empty(&ce->e_block_list);
4150 +__mb_cache_entry_unhash(struct mb_cache_entry *ce)
4154 + if (__mb_cache_entry_is_hashed(ce)) {
4155 + list_del_init(&ce->e_block_list);
4156 + for (n=0; n<mb_cache_indexes(ce->e_cache); n++)
4157 + list_del(&ce->e_indexes[n].o_list);
4163 +__mb_cache_entry_forget(struct mb_cache_entry *ce, int gfp_mask)
4165 + struct mb_cache *cache = ce->e_cache;
4167 + mb_assert(atomic_read(&ce->e_used) == 0);
4168 + if (cache->c_op.free && cache->c_op.free(ce, gfp_mask)) {
4169 + /* free failed -- put back on the lru list
4170 + for freeing later. */
4171 + spin_lock(&mb_cache_spinlock);
4172 + list_add(&ce->e_lru_list, &mb_cache_lru_list);
4173 + spin_unlock(&mb_cache_spinlock);
4175 + kmem_cache_free(cache->c_entry_cache, ce);
4176 + atomic_dec(&cache->c_entry_count);
4182 +__mb_cache_entry_release_unlock(struct mb_cache_entry *ce)
4184 + if (atomic_dec_and_test(&ce->e_used)) {
4185 + if (__mb_cache_entry_is_hashed(ce))
4186 + list_add_tail(&ce->e_lru_list, &mb_cache_lru_list);
4188 + spin_unlock(&mb_cache_spinlock);
4189 + __mb_cache_entry_forget(ce, GFP_KERNEL);
4193 + spin_unlock(&mb_cache_spinlock);
4198 + * mb_cache_memory_pressure() memory pressure callback
4200 + * This function is called by the kernel memory management when memory
4203 + * @priority: Amount by which to shrink the cache (0 = highes priority)
4204 + * @gfp_mask: (ignored)
4207 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask)
4209 + LIST_HEAD(free_list);
4210 + struct list_head *l, *ltmp;
4213 + spin_lock(&mb_cache_spinlock);
4214 + list_for_each(l, &mb_cache_list) {
4215 + struct mb_cache *cache =
4216 + list_entry(l, struct mb_cache, c_cache_list);
4217 + mb_debug("cache %s (%d)", cache->c_name,
4218 + atomic_read(&cache->c_entry_count));
4219 + count += atomic_read(&cache->c_entry_count);
4221 + mb_debug("trying to free %d of %d entries",
4222 + count / (priority ? priority : 1), count);
4224 + count /= priority;
4225 + while (count-- && !list_empty(&mb_cache_lru_list)) {
4226 + struct mb_cache_entry *ce =
4227 + list_entry(mb_cache_lru_list.next,
4228 + struct mb_cache_entry, e_lru_list);
4229 + list_del(&ce->e_lru_list);
4230 + __mb_cache_entry_unhash(ce);
4231 + list_add_tail(&ce->e_lru_list, &free_list);
4233 + spin_unlock(&mb_cache_spinlock);
4234 + list_for_each_safe(l, ltmp, &free_list) {
4235 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4236 + e_lru_list), gfp_mask);
4242 + * mb_cache_create() create a new cache
4244 + * All entries in one cache are equal size. Cache entries may be from
4245 + * multiple devices. If this is the first mbcache created, registers
4246 + * the cache with kernel memory management. Returns NULL if no more
4247 + * memory was available.
4249 + * @name: name of the cache (informal)
4250 + * @cache_op: contains the callback called when freeing a cache entry
4251 + * @entry_size: The size of a cache entry, including
4252 + * struct mb_cache_entry
4253 + * @indexes_count: number of additional indexes in the cache. Must equal
4254 + * MB_CACHE_INDEXES_COUNT if the number of indexes is
4256 + * @bucket_count: number of hash buckets
4259 +mb_cache_create(const char *name, struct mb_cache_op *cache_op,
4260 + size_t entry_size, int indexes_count, int bucket_count)
4263 + struct mb_cache *cache = NULL;
4265 + if(entry_size < sizeof(struct mb_cache_entry) +
4266 + indexes_count * sizeof(struct mb_cache_entry_index))
4269 + MOD_INC_USE_COUNT;
4270 + cache = kmalloc(sizeof(struct mb_cache) +
4271 + indexes_count * sizeof(struct list_head), GFP_KERNEL);
4274 + cache->c_name = name;
4275 + cache->c_op.free = NULL;
4277 + cache->c_op.free = cache_op->free;
4278 + atomic_set(&cache->c_entry_count, 0);
4279 + cache->c_bucket_count = bucket_count;
4280 +#ifdef MB_CACHE_INDEXES_COUNT
4281 + mb_assert(indexes_count == MB_CACHE_INDEXES_COUNT);
4283 + cache->c_indexes_count = indexes_count;
4285 + cache->c_block_hash = kmalloc(bucket_count * sizeof(struct list_head),
4287 + if (!cache->c_block_hash)
4289 + for (n=0; n<bucket_count; n++)
4290 + INIT_LIST_HEAD(&cache->c_block_hash[n]);
4291 + for (m=0; m<indexes_count; m++) {
4292 + cache->c_indexes_hash[m] = kmalloc(bucket_count *
4293 + sizeof(struct list_head),
4295 + if (!cache->c_indexes_hash[m])
4297 + for (n=0; n<bucket_count; n++)
4298 + INIT_LIST_HEAD(&cache->c_indexes_hash[m][n]);
4300 + cache->c_entry_cache = kmem_cache_create(name, entry_size, 0,
4301 + 0 /*SLAB_POISON | SLAB_RED_ZONE*/, NULL, NULL);
4302 + if (!cache->c_entry_cache)
4305 + spin_lock(&mb_cache_spinlock);
4306 + list_add(&cache->c_cache_list, &mb_cache_list);
4307 + spin_unlock(&mb_cache_spinlock);
4313 + kfree(cache->c_indexes_hash[m]);
4314 + if (cache->c_block_hash)
4315 + kfree(cache->c_block_hash);
4318 + MOD_DEC_USE_COUNT;
4324 + * mb_cache_shrink()
4326 + * Removes all cache entires of a device from the cache. All cache entries
4327 + * currently in use cannot be freed, and thus remain in the cache.
4329 + * @cache: which cache to shrink
4330 + * @dev: which device's cache entries to shrink
4333 +mb_cache_shrink(struct mb_cache *cache, kdev_t dev)
4335 + LIST_HEAD(free_list);
4336 + struct list_head *l, *ltmp;
4338 + spin_lock(&mb_cache_spinlock);
4339 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4340 + struct mb_cache_entry *ce =
4341 + list_entry(l, struct mb_cache_entry, e_lru_list);
4342 + if (ce->e_dev == dev) {
4343 + list_del(&ce->e_lru_list);
4344 + list_add_tail(&ce->e_lru_list, &free_list);
4345 + __mb_cache_entry_unhash(ce);
4348 + spin_unlock(&mb_cache_spinlock);
4349 + list_for_each_safe(l, ltmp, &free_list) {
4350 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4351 + e_lru_list), GFP_KERNEL);
4357 + * mb_cache_destroy()
4359 + * Shrinks the cache to its minimum possible size (hopefully 0 entries),
4360 + * and then destroys it. If this was the last mbcache, un-registers the
4361 + * mbcache from kernel memory management.
4364 +mb_cache_destroy(struct mb_cache *cache)
4366 + LIST_HEAD(free_list);
4367 + struct list_head *l, *ltmp;
4370 + spin_lock(&mb_cache_spinlock);
4371 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4372 + struct mb_cache_entry *ce =
4373 + list_entry(l, struct mb_cache_entry, e_lru_list);
4374 + if (ce->e_cache == cache) {
4375 + list_del(&ce->e_lru_list);
4376 + list_add_tail(&ce->e_lru_list, &free_list);
4377 + __mb_cache_entry_unhash(ce);
4380 + list_del(&cache->c_cache_list);
4381 + spin_unlock(&mb_cache_spinlock);
4382 + list_for_each_safe(l, ltmp, &free_list) {
4383 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4384 + e_lru_list), GFP_KERNEL);
4387 + if (atomic_read(&cache->c_entry_count) > 0) {
4388 + mb_error("cache %s: %d orphaned entries",
4390 + atomic_read(&cache->c_entry_count));
4393 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
4394 + /* We don't have kmem_cache_destroy() in 2.2.x */
4395 + kmem_cache_shrink(cache->c_entry_cache);
4397 + kmem_cache_destroy(cache->c_entry_cache);
4399 + for (n=0; n < mb_cache_indexes(cache); n++)
4400 + kfree(cache->c_indexes_hash[n]);
4401 + kfree(cache->c_block_hash);
4404 + MOD_DEC_USE_COUNT;
4409 + * mb_cache_entry_alloc()
4411 + * Allocates a new cache entry. The new entry will not be valid initially,
4412 + * and thus cannot be looked up yet. It should be filled with data, and
4413 + * then inserted into the cache using mb_cache_entry_insert(). Returns NULL
4414 + * if no more memory was available.
4416 +struct mb_cache_entry *
4417 +mb_cache_entry_alloc(struct mb_cache *cache)
4419 + struct mb_cache_entry *ce;
4421 + atomic_inc(&cache->c_entry_count);
4422 + ce = kmem_cache_alloc(cache->c_entry_cache, GFP_KERNEL);
4424 + INIT_LIST_HEAD(&ce->e_lru_list);
4425 + INIT_LIST_HEAD(&ce->e_block_list);
4426 + ce->e_cache = cache;
4427 + atomic_set(&ce->e_used, 1);
4434 + * mb_cache_entry_insert()
4436 + * Inserts an entry that was allocated using mb_cache_entry_alloc() into
4437 + * the cache. After this, the cache entry can be looked up, but is not yet
4438 + * in the lru list as the caller still holds a handle to it. Returns 0 on
4439 + * success, or -EBUSY if a cache entry for that device + inode exists
4440 + * already (this may happen after a failed lookup, if another process has
4441 + * inserted the same cache entry in the meantime).
4443 + * @dev: device the cache entry belongs to
4444 + * @block: block number
4445 + * @keys: array of additional keys. There must be indexes_count entries
4446 + * in the array (as specified when creating the cache).
4449 +mb_cache_entry_insert(struct mb_cache_entry *ce, kdev_t dev,
4450 + unsigned long block, unsigned int keys[])
4452 + struct mb_cache *cache = ce->e_cache;
4453 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4454 + struct list_head *l;
4455 + int error = -EBUSY, n;
4457 + spin_lock(&mb_cache_spinlock);
4458 + list_for_each(l, &cache->c_block_hash[bucket]) {
4459 + struct mb_cache_entry *ce =
4460 + list_entry(l, struct mb_cache_entry, e_block_list);
4461 + if (ce->e_dev == dev && ce->e_block == block)
4464 + __mb_cache_entry_unhash(ce);
4466 + ce->e_block = block;
4467 + list_add(&ce->e_block_list, &cache->c_block_hash[bucket]);
4468 + for (n=0; n<mb_cache_indexes(cache); n++) {
4469 + ce->e_indexes[n].o_key = keys[n];
4470 + bucket = keys[n] % cache->c_bucket_count;
4471 + list_add(&ce->e_indexes[n].o_list,
4472 + &cache->c_indexes_hash[n][bucket]);
4475 + spin_unlock(&mb_cache_spinlock);
4481 + * mb_cache_entry_release()
4483 + * Release a handle to a cache entry. When the last handle to a cache entry
4484 + * is released it is either freed (if it is invalid) or otherwise inserted
4485 + * in to the lru list.
4488 +mb_cache_entry_release(struct mb_cache_entry *ce)
4490 + spin_lock(&mb_cache_spinlock);
4491 + __mb_cache_entry_release_unlock(ce);
4496 + * mb_cache_entry_takeout()
4498 + * Take a cache entry out of the cache, making it invalid. The entry can later
4499 + * be re-inserted using mb_cache_entry_insert(), or released using
4500 + * mb_cache_entry_release().
4503 +mb_cache_entry_takeout(struct mb_cache_entry *ce)
4505 + spin_lock(&mb_cache_spinlock);
4506 + mb_assert(list_empty(&ce->e_lru_list));
4507 + __mb_cache_entry_unhash(ce);
4508 + spin_unlock(&mb_cache_spinlock);
4513 + * mb_cache_entry_free()
4515 + * This is equivalent to the sequence mb_cache_entry_takeout() --
4516 + * mb_cache_entry_release().
4519 +mb_cache_entry_free(struct mb_cache_entry *ce)
4521 + spin_lock(&mb_cache_spinlock);
4522 + mb_assert(list_empty(&ce->e_lru_list));
4523 + __mb_cache_entry_unhash(ce);
4524 + __mb_cache_entry_release_unlock(ce);
4529 + * mb_cache_entry_dup()
4531 + * Duplicate a handle to a cache entry (does not duplicate the cache entry
4532 + * itself). After the call, both the old and the new handle must be released.
4534 +struct mb_cache_entry *
4535 +mb_cache_entry_dup(struct mb_cache_entry *ce)
4537 + atomic_inc(&ce->e_used);
4543 + * mb_cache_entry_get()
4545 + * Get a cache entry by device / block number. (There can only be one entry
4546 + * in the cache per device and block.) Returns NULL if no such cache entry
4549 +struct mb_cache_entry *
4550 +mb_cache_entry_get(struct mb_cache *cache, kdev_t dev, unsigned long block)
4552 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4553 + struct list_head *l;
4554 + struct mb_cache_entry *ce;
4556 + spin_lock(&mb_cache_spinlock);
4557 + list_for_each(l, &cache->c_block_hash[bucket]) {
4558 + ce = list_entry(l, struct mb_cache_entry, e_block_list);
4559 + if (ce->e_dev == dev && ce->e_block == block) {
4560 + if (!list_empty(&ce->e_lru_list))
4561 + list_del_init(&ce->e_lru_list);
4562 + atomic_inc(&ce->e_used);
4569 + spin_unlock(&mb_cache_spinlock);
4573 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
4575 +static struct mb_cache_entry *
4576 +__mb_cache_entry_find(struct list_head *l, struct list_head *head,
4577 + int index, kdev_t dev, unsigned int key)
4579 + while (l != head) {
4580 + struct mb_cache_entry *ce =
4581 + list_entry(l, struct mb_cache_entry,
4582 + e_indexes[index].o_list);
4583 + if (ce->e_dev == dev && ce->e_indexes[index].o_key == key) {
4584 + if (!list_empty(&ce->e_lru_list))
4585 + list_del_init(&ce->e_lru_list);
4586 + atomic_inc(&ce->e_used);
4596 + * mb_cache_entry_find_first()
4598 + * Find the first cache entry on a given device with a certain key in
4599 + * an additional index. Additonal matches can be found with
4600 + * mb_cache_entry_find_next(). Returns NULL if no match was found.
4602 + * @cache: the cache to search
4603 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4604 + * @dev: the device the cache entry should belong to
4605 + * @key: the key in the index
4607 +struct mb_cache_entry *
4608 +mb_cache_entry_find_first(struct mb_cache *cache, int index, kdev_t dev,
4611 + unsigned int bucket = key % cache->c_bucket_count;
4612 + struct list_head *l;
4613 + struct mb_cache_entry *ce;
4615 + mb_assert(index < mb_cache_indexes(cache));
4616 + spin_lock(&mb_cache_spinlock);
4617 + l = cache->c_indexes_hash[index][bucket].next;
4618 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4620 + spin_unlock(&mb_cache_spinlock);
4626 + * mb_cache_entry_find_next()
4628 + * Find the next cache entry on a given device with a certain key in an
4629 + * additional index. Returns NULL if no match could be found. The previous
4630 + * entry is atomatically released, so that mb_cache_entry_find_next() can
4631 + * be called like this:
4633 + * entry = mb_cache_entry_find_first();
4636 + * entry = mb_cache_entry_find_next(entry, ...);
4639 + * @prev: The previous match
4640 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4641 + * @dev: the device the cache entry should belong to
4642 + * @key: the key in the index
4644 +struct mb_cache_entry *
4645 +mb_cache_entry_find_next(struct mb_cache_entry *prev, int index, kdev_t dev,
4648 + struct mb_cache *cache = prev->e_cache;
4649 + unsigned int bucket = key % cache->c_bucket_count;
4650 + struct list_head *l;
4651 + struct mb_cache_entry *ce;
4653 + mb_assert(index < mb_cache_indexes(cache));
4654 + spin_lock(&mb_cache_spinlock);
4655 + l = prev->e_indexes[index].o_list.next;
4656 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4658 + __mb_cache_entry_release_unlock(prev);
4662 +#endif /* !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0) */
4664 +static int __init init_mbcache(void)
4666 + register_cache(&mb_cache_definition);
4670 +static void __exit exit_mbcache(void)
4672 + unregister_cache(&mb_cache_definition);
4675 +module_init(init_mbcache)
4676 +module_exit(exit_mbcache)
4678 --- 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
4679 +++ linux-2.4.20-root/include/asm-arm/unistd.h 2003-05-07 18:08:03.000000000 +0800
4681 #define __NR_security (__NR_SYSCALL_BASE+223)
4682 #define __NR_gettid (__NR_SYSCALL_BASE+224)
4683 #define __NR_readahead (__NR_SYSCALL_BASE+225)
4684 -#if 0 /* allocated in 2.5 */
4685 #define __NR_setxattr (__NR_SYSCALL_BASE+226)
4686 #define __NR_lsetxattr (__NR_SYSCALL_BASE+227)
4687 #define __NR_fsetxattr (__NR_SYSCALL_BASE+228)
4689 #define __NR_removexattr (__NR_SYSCALL_BASE+235)
4690 #define __NR_lremovexattr (__NR_SYSCALL_BASE+236)
4691 #define __NR_fremovexattr (__NR_SYSCALL_BASE+237)
4693 #define __NR_tkill (__NR_SYSCALL_BASE+238)
4695 * Please check 2.5 _before_ adding calls here,
4696 --- 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
4697 +++ linux-2.4.20-root/include/asm-ia64/unistd.h 2003-05-07 18:08:03.000000000 +0800
4698 @@ -206,8 +206,19 @@
4699 #define __NR_getdents64 1214
4700 #define __NR_getunwind 1215
4701 #define __NR_readahead 1216
4702 +#define __NR_setxattr 1217
4703 +#define __NR_lsetxattr 1218
4704 +#define __NR_fsetxattr 1219
4705 +#define __NR_getxattr 1220
4706 +#define __NR_lgetxattr 1221
4707 +#define __NR_fgetxattr 1222
4708 +#define __NR_listxattr 1223
4709 +#define __NR_llistxattr 1224
4710 +#define __NR_flistxattr 1225
4711 +#define __NR_removexattr 1226
4712 +#define __NR_lremovexattr 1227
4713 +#define __NR_fremovexattr 1228
4715 - * 1217-1228: reserved for xattr
4716 * 1230-1232: reserved for futex and sched_[sg]etaffinity.
4718 #define __NR_tkill 1229
4719 --- 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
4720 +++ linux-2.4.20-root/include/asm-ppc64/unistd.h 2003-05-07 18:08:03.000000000 +0800
4722 #define __NR_gettid 207
4723 #if 0 /* Reserved syscalls */
4724 #define __NR_tkill 208
4726 #define __NR_setxattr 209
4727 #define __NR_lsetxattr 210
4728 #define __NR_fsetxattr 211
4730 #define __NR_removexattr 218
4731 #define __NR_lremovexattr 219
4732 #define __NR_fremovexattr 220
4733 +#if 0 /* Reserved syscalls */
4734 #define __NR_futex 221
4737 --- 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
4738 +++ linux-2.4.20-root/include/asm-s390/unistd.h 2003-05-07 18:08:03.000000000 +0800
4739 @@ -212,9 +212,18 @@
4740 #define __NR_madvise 219
4741 #define __NR_getdents64 220
4742 #define __NR_fcntl64 221
4744 - * Numbers 224-235 are reserved for posix acl
4746 +#define __NR_setxattr 224
4747 +#define __NR_lsetxattr 225
4748 +#define __NR_fsetxattr 226
4749 +#define __NR_getxattr 227
4750 +#define __NR_lgetxattr 228
4751 +#define __NR_fgetxattr 229
4752 +#define __NR_listxattr 230
4753 +#define __NR_llistxattr 231
4754 +#define __NR_flistxattr 232
4755 +#define __NR_removexattr 233
4756 +#define __NR_lremovexattr 234
4757 +#define __NR_fremovexattr 235
4758 #define __NR_gettid 236
4759 #define __NR_tkill 237
4761 --- 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
4762 +++ linux-2.4.20-root/include/asm-s390x/unistd.h 2003-05-07 18:08:03.000000000 +0800
4763 @@ -180,9 +180,18 @@
4764 #define __NR_pivot_root 217
4765 #define __NR_mincore 218
4766 #define __NR_madvise 219
4768 - * Numbers 224-235 are reserved for posix acl
4770 +#define __NR_setxattr 224
4771 +#define __NR_lsetxattr 225
4772 +#define __NR_fsetxattr 226
4773 +#define __NR_getxattr 227
4774 +#define __NR_lgetxattr 228
4775 +#define __NR_fgetxattr 229
4776 +#define __NR_listxattr 230
4777 +#define __NR_llistxattr 231
4778 +#define __NR_flistxattr 232
4779 +#define __NR_removexattr 233
4780 +#define __NR_lremovexattr 234
4781 +#define __NR_fremovexattr 235
4782 #define __NR_gettid 236
4783 #define __NR_tkill 237
4785 --- 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
4786 +++ linux-2.4.20-root/include/asm-sparc/unistd.h 2003-05-07 18:08:03.000000000 +0800
4787 @@ -184,24 +184,24 @@
4788 /* #define __NR_exportfs 166 SunOS Specific */
4789 #define __NR_mount 167 /* Common */
4790 #define __NR_ustat 168 /* Common */
4791 -/* #define __NR_semsys 169 SunOS Specific */
4792 -/* #define __NR_msgsys 170 SunOS Specific */
4793 -/* #define __NR_shmsys 171 SunOS Specific */
4794 -/* #define __NR_auditsys 172 SunOS Specific */
4795 -/* #define __NR_rfssys 173 SunOS Specific */
4796 +#define __NR_setxattr 169 /* SunOS: semsys */
4797 +#define __NR_lsetxattr 170 /* SunOS: msgsys */
4798 +#define __NR_fsetxattr 171 /* SunOS: shmsys */
4799 +#define __NR_getxattr 172 /* SunOS: auditsys */
4800 +#define __NR_lgetxattr 173 /* SunOS: rfssys */
4801 #define __NR_getdents 174 /* Common */
4802 #define __NR_setsid 175 /* Common */
4803 #define __NR_fchdir 176 /* Common */
4804 -/* #define __NR_fchroot 177 SunOS Specific */
4805 -/* #define __NR_vpixsys 178 SunOS Specific */
4806 -/* #define __NR_aioread 179 SunOS Specific */
4807 -/* #define __NR_aiowrite 180 SunOS Specific */
4808 -/* #define __NR_aiowait 181 SunOS Specific */
4809 -/* #define __NR_aiocancel 182 SunOS Specific */
4810 +#define __NR_fgetxattr 177 /* SunOS: fchroot */
4811 +#define __NR_listxattr 178 /* SunOS: vpixsys */
4812 +#define __NR_llistxattr 179 /* SunOS: aioread */
4813 +#define __NR_flistxattr 180 /* SunOS: aiowrite */
4814 +#define __NR_removexattr 181 /* SunOS: aiowait */
4815 +#define __NR_lremovexattr 182 /* SunOS: aiocancel */
4816 #define __NR_sigpending 183 /* Common */
4817 #define __NR_query_module 184 /* Linux Specific */
4818 #define __NR_setpgid 185 /* Common */
4819 -/* #define __NR_pathconf 186 SunOS Specific */
4820 +#define __NR_fremovexattr 186 /* SunOS: pathconf */
4821 #define __NR_tkill 187 /* SunOS: fpathconf */
4822 /* #define __NR_sysconf 188 SunOS Specific */
4823 #define __NR_uname 189 /* Linux Specific */
4824 --- 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
4825 +++ linux-2.4.20-root/include/asm-sparc64/unistd.h 2003-05-07 18:08:03.000000000 +0800
4826 @@ -184,24 +184,24 @@
4827 /* #define __NR_exportfs 166 SunOS Specific */
4828 #define __NR_mount 167 /* Common */
4829 #define __NR_ustat 168 /* Common */
4830 -/* #define __NR_semsys 169 SunOS Specific */
4831 -/* #define __NR_msgsys 170 SunOS Specific */
4832 -/* #define __NR_shmsys 171 SunOS Specific */
4833 -/* #define __NR_auditsys 172 SunOS Specific */
4834 -/* #define __NR_rfssys 173 SunOS Specific */
4835 +#define __NR_setxattr 169 /* SunOS: semsys */
4836 +#define __NR_lsetxattr 170 /* SunOS: msgsys */
4837 +#define __NR_fsetxattr 171 /* SunOS: shmsys */
4838 +#define __NR_getxattr 172 /* SunOS: auditsys */
4839 +#define __NR_lgetxattr 173 /* SunOS: rfssys */
4840 #define __NR_getdents 174 /* Common */
4841 #define __NR_setsid 175 /* Common */
4842 #define __NR_fchdir 176 /* Common */
4843 -/* #define __NR_fchroot 177 SunOS Specific */
4844 -/* #define __NR_vpixsys 178 SunOS Specific */
4845 -/* #define __NR_aioread 179 SunOS Specific */
4846 -/* #define __NR_aiowrite 180 SunOS Specific */
4847 -/* #define __NR_aiowait 181 SunOS Specific */
4848 -/* #define __NR_aiocancel 182 SunOS Specific */
4849 +#define __NR_fgetxattr 177 /* SunOS: fchroot */
4850 +#define __NR_listxattr 178 /* SunOS: vpixsys */
4851 +#define __NR_llistxattr 179 /* SunOS: aioread */
4852 +#define __NR_flistxattr 180 /* SunOS: aiowrite */
4853 +#define __NR_removexattr 181 /* SunOS: aiowait */
4854 +#define __NR_lremovexattr 182 /* SunOS: aiocancel */
4855 #define __NR_sigpending 183 /* Common */
4856 #define __NR_query_module 184 /* Linux Specific */
4857 #define __NR_setpgid 185 /* Common */
4858 -/* #define __NR_pathconf 186 SunOS Specific */
4859 +#define __NR_fremovexattr 186 /* SunOS: pathconf */
4860 #define __NR_tkill 187 /* SunOS: fpathconf */
4861 /* #define __NR_sysconf 188 SunOS Specific */
4862 #define __NR_uname 189 /* Linux Specific */
4863 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4864 +++ linux-2.4.20-root/include/linux/cache_def.h 2003-05-07 18:08:03.000000000 +0800
4867 + * linux/cache_def.h
4868 + * Handling of caches defined in drivers, filesystems, ...
4870 + * Copyright (C) 2002 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
4873 +struct cache_definition {
4875 + void (*shrink)(int, unsigned int);
4876 + struct list_head link;
4879 +extern void register_cache(struct cache_definition *);
4880 +extern void unregister_cache(struct cache_definition *);
4881 --- linux-2.4.20/include/linux/errno.h~linux-2.4.20-xattr-0.8.54 2003-04-14 16:39:03.000000000 +0800
4882 +++ linux-2.4.20-root/include/linux/errno.h 2003-05-07 18:08:03.000000000 +0800
4887 +/* Defined for extended attributes */
4888 +#define ENOATTR ENODATA /* No such attribute */
4889 +#define ENOTSUP EOPNOTSUPP /* Operation not supported */
4892 --- 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
4893 +++ linux-2.4.20-root/include/linux/ext2_fs.h 2003-05-07 18:08:03.000000000 +0800
4896 #define EXT2_BAD_INO 1 /* Bad blocks inode */
4897 #define EXT2_ROOT_INO 2 /* Root inode */
4898 -#define EXT2_ACL_IDX_INO 3 /* ACL inode */
4899 -#define EXT2_ACL_DATA_INO 4 /* ACL inode */
4900 #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
4901 #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
4905 # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
4907 -#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
4908 #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
4910 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
4911 @@ -121,28 +118,6 @@
4917 -struct ext2_acl_header /* Header of Access Control Lists */
4920 - __u32 aclh_file_count;
4921 - __u32 aclh_acle_count;
4922 - __u32 aclh_first_acle;
4925 -struct ext2_acl_entry /* Access Control List Entry */
4928 - __u16 acle_perms; /* Access permissions */
4929 - __u16 acle_type; /* Type of entry */
4930 - __u16 acle_tag; /* User or group identity */
4932 - __u32 acle_next; /* Pointer on next entry for the */
4933 - /* same inode or on next free entry */
4937 * Structure of a blocks group descriptor
4939 struct ext2_group_desc
4940 @@ -314,6 +289,7 @@ struct ext2_inode {
4941 #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
4942 #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
4943 #define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
4944 +#define EXT2_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
4946 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
4947 #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
4948 @@ -397,6 +373,7 @@ struct ext2_super_block {
4951 #define EXT2_SB(sb) (&((sb)->u.ext2_sb))
4952 +#define EXT2_I(inode) (&((inode)->u.ext2_i))
4954 /* Assume that user mode programs are passing in an ext2fs superblock, not
4955 * a kernel struct super_block. This will allow us to call the feature-test
4956 @@ -466,7 +443,7 @@ struct ext2_super_block {
4957 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
4958 #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
4960 -#define EXT2_FEATURE_COMPAT_SUPP 0
4961 +#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
4962 #define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE
4963 #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
4964 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
4965 @@ -623,8 +600,10 @@ extern struct address_space_operations e
4968 extern struct inode_operations ext2_dir_inode_operations;
4969 +extern struct inode_operations ext2_special_inode_operations;
4972 +extern struct inode_operations ext2_symlink_inode_operations;
4973 extern struct inode_operations ext2_fast_symlink_inode_operations;
4975 #endif /* __KERNEL__ */
4976 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4977 +++ linux-2.4.20-root/include/linux/ext2_xattr.h 2003-05-07 18:08:03.000000000 +0800
4980 + File: linux/ext2_xattr.h
4982 + On-disk format of extended attributes for the ext2 filesystem.
4984 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
4987 +#include <linux/config.h>
4988 +#include <linux/init.h>
4989 +#include <linux/xattr.h>
4991 +/* Magic value in attribute blocks */
4992 +#define EXT2_XATTR_MAGIC 0xEA020000
4994 +/* Maximum number of references to one attribute block */
4995 +#define EXT2_XATTR_REFCOUNT_MAX 1024
4998 +#define EXT2_XATTR_INDEX_MAX 10
4999 +#define EXT2_XATTR_INDEX_USER 1
5000 +#define EXT2_XATTR_INDEX_POSIX_ACL_ACCESS 2
5001 +#define EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT 3
5003 +struct ext2_xattr_header {
5004 + __u32 h_magic; /* magic number for identification */
5005 + __u32 h_refcount; /* reference count */
5006 + __u32 h_blocks; /* number of disk blocks used */
5007 + __u32 h_hash; /* hash value of all attributes */
5008 + __u32 h_reserved[4]; /* zero right now */
5011 +struct ext2_xattr_entry {
5012 + __u8 e_name_len; /* length of name */
5013 + __u8 e_name_index; /* attribute name index */
5014 + __u16 e_value_offs; /* offset in disk block of value */
5015 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
5016 + __u32 e_value_size; /* size of attribute value */
5017 + __u32 e_hash; /* hash value of name and value */
5018 + char e_name[0]; /* attribute name */
5021 +#define EXT2_XATTR_PAD_BITS 2
5022 +#define EXT2_XATTR_PAD (1<<EXT2_XATTR_PAD_BITS)
5023 +#define EXT2_XATTR_ROUND (EXT2_XATTR_PAD-1)
5024 +#define EXT2_XATTR_LEN(name_len) \
5025 + (((name_len) + EXT2_XATTR_ROUND + \
5026 + sizeof(struct ext2_xattr_entry)) & ~EXT2_XATTR_ROUND)
5027 +#define EXT2_XATTR_NEXT(entry) \
5028 + ( (struct ext2_xattr_entry *)( \
5029 + (char *)(entry) + EXT2_XATTR_LEN((entry)->e_name_len)) )
5030 +#define EXT2_XATTR_SIZE(size) \
5031 + (((size) + EXT2_XATTR_ROUND) & ~EXT2_XATTR_ROUND)
5035 +# ifdef CONFIG_EXT2_FS_XATTR
5037 +struct ext2_xattr_handler {
5039 + size_t (*list)(char *list, struct inode *inode, const char *name,
5041 + int (*get)(struct inode *inode, const char *name, void *buffer,
5043 + int (*set)(struct inode *inode, const char *name, const void *buffer,
5044 + size_t size, int flags);
5047 +extern int ext2_xattr_register(int, struct ext2_xattr_handler *);
5048 +extern void ext2_xattr_unregister(int, struct ext2_xattr_handler *);
5050 +extern int ext2_setxattr(struct dentry *, const char *, const void *, size_t, int);
5051 +extern ssize_t ext2_getxattr(struct dentry *, const char *, void *, size_t);
5052 +extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
5053 +extern int ext2_removexattr(struct dentry *, const char *);
5055 +extern int ext2_xattr_get(struct inode *, int, const char *, void *, size_t);
5056 +extern int ext2_xattr_list(struct inode *, char *, size_t);
5057 +extern int ext2_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
5059 +extern void ext2_xattr_delete_inode(struct inode *);
5060 +extern void ext2_xattr_put_super(struct super_block *);
5062 +extern int init_ext2_xattr(void) __init;
5063 +extern void exit_ext2_xattr(void);
5065 +# else /* CONFIG_EXT2_FS_XATTR */
5066 +# define ext2_setxattr NULL
5067 +# define ext2_getxattr NULL
5068 +# define ext2_listxattr NULL
5069 +# define ext2_removexattr NULL
5072 +ext2_xattr_get(struct inode *inode, int name_index,
5073 + const char *name, void *buffer, size_t size)
5079 +ext2_xattr_list(struct inode *inode, char *buffer, size_t size)
5085 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
5086 + const void *value, size_t size, int flags)
5092 +ext2_xattr_delete_inode(struct inode *inode)
5097 +ext2_xattr_put_super(struct super_block *sb)
5102 +init_ext2_xattr(void)
5108 +exit_ext2_xattr(void)
5112 +# endif /* CONFIG_EXT2_FS_XATTR */
5114 +# ifdef CONFIG_EXT2_FS_XATTR_USER
5116 +extern int init_ext2_xattr_user(void) __init;
5117 +extern void exit_ext2_xattr_user(void);
5119 +# else /* CONFIG_EXT2_FS_XATTR_USER */
5122 +init_ext2_xattr_user(void)
5128 +exit_ext2_xattr_user(void)
5132 +# endif /* CONFIG_EXT2_FS_XATTR_USER */
5134 +#endif /* __KERNEL__ */
5136 --- 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
5137 +++ linux-2.4.20-root/include/linux/ext3_fs.h 2003-05-07 18:08:03.000000000 +0800
5140 #define EXT3_BAD_INO 1 /* Bad blocks inode */
5141 #define EXT3_ROOT_INO 2 /* Root inode */
5142 -#define EXT3_ACL_IDX_INO 3 /* ACL inode */
5143 -#define EXT3_ACL_DATA_INO 4 /* ACL inode */
5144 #define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
5145 #define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
5146 #define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
5149 # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
5151 -#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
5152 #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
5154 # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
5155 @@ -129,28 +126,6 @@
5161 -struct ext3_acl_header /* Header of Access Control Lists */
5164 - __u32 aclh_file_count;
5165 - __u32 aclh_acle_count;
5166 - __u32 aclh_first_acle;
5169 -struct ext3_acl_entry /* Access Control List Entry */
5172 - __u16 acle_perms; /* Access permissions */
5173 - __u16 acle_type; /* Type of entry */
5174 - __u16 acle_tag; /* User or group identity */
5176 - __u32 acle_next; /* Pointer on next entry for the */
5177 - /* same inode or on next free entry */
5181 * Structure of a blocks group descriptor
5183 struct ext3_group_desc
5184 @@ -344,6 +319,7 @@ struct ext3_inode {
5185 #define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */
5186 #define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */
5187 #define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
5188 +#define EXT3_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
5190 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
5191 #ifndef _LINUX_EXT2_FS_H
5192 @@ -520,7 +496,7 @@ struct ext3_super_block {
5193 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
5194 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
5196 -#define EXT3_FEATURE_COMPAT_SUPP 0
5197 +#define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
5198 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
5199 EXT3_FEATURE_INCOMPAT_RECOVER)
5200 #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
5201 @@ -703,6 +679,7 @@ extern void ext3_check_inodes_bitmap (st
5202 extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
5205 +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
5206 extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
5207 extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
5209 @@ -771,8 +748,10 @@ extern struct address_space_operations e
5212 extern struct inode_operations ext3_dir_inode_operations;
5213 +extern struct inode_operations ext3_special_inode_operations;
5216 +extern struct inode_operations ext3_symlink_inode_operations;
5217 extern struct inode_operations ext3_fast_symlink_inode_operations;
5220 --- 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
5221 +++ linux-2.4.20-root/include/linux/ext3_jbd.h 2003-05-07 18:08:03.000000000 +0800
5224 #define EXT3_SINGLEDATA_TRANS_BLOCKS 8
5226 +/* Extended attributes may touch two data buffers, two bitmap buffers,
5227 + * and two group and summaries. */
5229 +#define EXT3_XATTR_TRANS_BLOCKS 8
5231 /* Define the minimum size for a transaction which modifies data. This
5232 * needs to take into account the fact that we may end up modifying two
5233 * quota files too (one for the group, one for the user quota). The
5234 * superblock only gets updated once, of course, so don't bother
5235 * counting that again for the quota updates. */
5237 -#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2)
5238 +#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \
5239 + EXT3_XATTR_TRANS_BLOCKS - 2)
5241 extern int ext3_writepage_trans_blocks(struct inode *inode);
5243 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5244 +++ linux-2.4.20-root/include/linux/ext3_xattr.h 2003-05-07 18:08:03.000000000 +0800
5247 + File: linux/ext3_xattr.h
5249 + On-disk format of extended attributes for the ext3 filesystem.
5251 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5254 +#include <linux/config.h>
5255 +#include <linux/init.h>
5256 +#include <linux/xattr.h>
5258 +/* Magic value in attribute blocks */
5259 +#define EXT3_XATTR_MAGIC 0xEA020000
5261 +/* Maximum number of references to one attribute block */
5262 +#define EXT3_XATTR_REFCOUNT_MAX 1024
5265 +#define EXT3_XATTR_INDEX_MAX 10
5266 +#define EXT3_XATTR_INDEX_USER 1
5267 +#define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS 2
5268 +#define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT 3
5270 +struct ext3_xattr_header {
5271 + __u32 h_magic; /* magic number for identification */
5272 + __u32 h_refcount; /* reference count */
5273 + __u32 h_blocks; /* number of disk blocks used */
5274 + __u32 h_hash; /* hash value of all attributes */
5275 + __u32 h_reserved[4]; /* zero right now */
5278 +struct ext3_xattr_entry {
5279 + __u8 e_name_len; /* length of name */
5280 + __u8 e_name_index; /* attribute name index */
5281 + __u16 e_value_offs; /* offset in disk block of value */
5282 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
5283 + __u32 e_value_size; /* size of attribute value */
5284 + __u32 e_hash; /* hash value of name and value */
5285 + char e_name[0]; /* attribute name */
5288 +#define EXT3_XATTR_PAD_BITS 2
5289 +#define EXT3_XATTR_PAD (1<<EXT3_XATTR_PAD_BITS)
5290 +#define EXT3_XATTR_ROUND (EXT3_XATTR_PAD-1)
5291 +#define EXT3_XATTR_LEN(name_len) \
5292 + (((name_len) + EXT3_XATTR_ROUND + \
5293 + sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
5294 +#define EXT3_XATTR_NEXT(entry) \
5295 + ( (struct ext3_xattr_entry *)( \
5296 + (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
5297 +#define EXT3_XATTR_SIZE(size) \
5298 + (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
5302 +# ifdef CONFIG_EXT3_FS_XATTR
5304 +struct ext3_xattr_handler {
5306 + size_t (*list)(char *list, struct inode *inode, const char *name,
5308 + int (*get)(struct inode *inode, const char *name, void *buffer,
5310 + int (*set)(struct inode *inode, const char *name, const void *buffer,
5311 + size_t size, int flags);
5314 +extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
5315 +extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
5317 +extern int ext3_setxattr(struct dentry *, const char *, const void *, size_t, int);
5318 +extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
5319 +extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
5320 +extern int ext3_removexattr(struct dentry *, const char *);
5322 +extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
5323 +extern int ext3_xattr_list(struct inode *, char *, size_t);
5324 +extern int ext3_xattr_set(handle_t *handle, struct inode *, int, const char *, const void *, size_t, int);
5326 +extern void ext3_xattr_delete_inode(handle_t *, struct inode *);
5327 +extern void ext3_xattr_put_super(struct super_block *);
5329 +extern int init_ext3_xattr(void) __init;
5330 +extern void exit_ext3_xattr(void);
5332 +# else /* CONFIG_EXT3_FS_XATTR */
5333 +# define ext3_setxattr NULL
5334 +# define ext3_getxattr NULL
5335 +# define ext3_listxattr NULL
5336 +# define ext3_removexattr NULL
5339 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
5340 + void *buffer, size_t size)
5346 +ext3_xattr_list(struct inode *inode, void *buffer, size_t size)
5352 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
5353 + const char *name, const void *value, size_t size, int flags)
5359 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
5364 +ext3_xattr_put_super(struct super_block *sb)
5369 +init_ext3_xattr(void)
5375 +exit_ext3_xattr(void)
5379 +# endif /* CONFIG_EXT3_FS_XATTR */
5381 +# ifdef CONFIG_EXT3_FS_XATTR_USER
5383 +extern int init_ext3_xattr_user(void) __init;
5384 +extern void exit_ext3_xattr_user(void);
5386 +# else /* CONFIG_EXT3_FS_XATTR_USER */
5389 +init_ext3_xattr_user(void)
5395 +exit_ext3_xattr_user(void)
5399 +#endif /* CONFIG_EXT3_FS_XATTR_USER */
5401 +#endif /* __KERNEL__ */
5403 --- linux-2.4.20/include/linux/fs.h~linux-2.4.20-xattr-0.8.54 2003-05-05 19:00:55.000000000 +0800
5404 +++ linux-2.4.20-root/include/linux/fs.h 2003-05-07 18:08:03.000000000 +0800
5405 @@ -888,7 +888,7 @@ struct inode_operations {
5406 int (*setattr) (struct dentry *, struct iattr *);
5407 int (*setattr_raw) (struct inode *, struct iattr *);
5408 int (*getattr) (struct dentry *, struct iattr *);
5409 - int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
5410 + int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
5411 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
5412 ssize_t (*listxattr) (struct dentry *, char *, size_t);
5413 int (*removexattr) (struct dentry *, const char *);
5414 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5415 +++ linux-2.4.20-root/include/linux/mbcache.h 2003-05-07 18:08:03.000000000 +0800
5418 + File: linux/mbcache.h
5420 + (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
5423 +/* Hardwire the number of additional indexes */
5424 +#define MB_CACHE_INDEXES_COUNT 1
5426 +struct mb_cache_entry;
5428 +struct mb_cache_op {
5429 + int (*free)(struct mb_cache_entry *, int);
5433 + struct list_head c_cache_list;
5434 + const char *c_name;
5435 + struct mb_cache_op c_op;
5436 + atomic_t c_entry_count;
5437 + int c_bucket_count;
5438 +#ifndef MB_CACHE_INDEXES_COUNT
5439 + int c_indexes_count;
5441 + kmem_cache_t *c_entry_cache;
5442 + struct list_head *c_block_hash;
5443 + struct list_head *c_indexes_hash[0];
5446 +struct mb_cache_entry_index {
5447 + struct list_head o_list;
5448 + unsigned int o_key;
5451 +struct mb_cache_entry {
5452 + struct list_head e_lru_list;
5453 + struct mb_cache *e_cache;
5456 + unsigned long e_block;
5457 + struct list_head e_block_list;
5458 + struct mb_cache_entry_index e_indexes[0];
5461 +/* Functions on caches */
5463 +struct mb_cache * mb_cache_create(const char *, struct mb_cache_op *, size_t,
5465 +void mb_cache_shrink(struct mb_cache *, kdev_t);
5466 +void mb_cache_destroy(struct mb_cache *);
5468 +/* Functions on cache entries */
5470 +struct mb_cache_entry *mb_cache_entry_alloc(struct mb_cache *);
5471 +int mb_cache_entry_insert(struct mb_cache_entry *, kdev_t, unsigned long,
5473 +void mb_cache_entry_rehash(struct mb_cache_entry *, unsigned int[]);
5474 +void mb_cache_entry_release(struct mb_cache_entry *);
5475 +void mb_cache_entry_takeout(struct mb_cache_entry *);
5476 +void mb_cache_entry_free(struct mb_cache_entry *);
5477 +struct mb_cache_entry *mb_cache_entry_dup(struct mb_cache_entry *);
5478 +struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *, kdev_t,
5480 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
5481 +struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache, int,
5482 + kdev_t, unsigned int);
5483 +struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache_entry *, int,
5484 + kdev_t, unsigned int);
5486 --- linux-2.4.20/kernel/ksyms.c~linux-2.4.20-xattr-0.8.54 2003-05-05 17:43:15.000000000 +0800
5487 +++ linux-2.4.20-root/kernel/ksyms.c 2003-05-07 18:08:03.000000000 +0800
5490 #include <linux/config.h>
5491 #include <linux/slab.h>
5492 +#include <linux/cache_def.h>
5493 #include <linux/module.h>
5494 #include <linux/blkdev.h>
5495 #include <linux/cdrom.h>
5496 @@ -89,6 +90,7 @@ EXPORT_SYMBOL(exit_mm);
5497 EXPORT_SYMBOL(exit_files);
5498 EXPORT_SYMBOL(exit_fs);
5499 EXPORT_SYMBOL(exit_sighand);
5500 +EXPORT_SYMBOL(copy_fs_struct);
5502 /* internal kernel memory management */
5503 EXPORT_SYMBOL(_alloc_pages);
5504 @@ -107,6 +109,8 @@ EXPORT_SYMBOL(kmem_cache_validate);
5505 EXPORT_SYMBOL(kmem_cache_alloc);
5506 EXPORT_SYMBOL(kmem_cache_free);
5507 EXPORT_SYMBOL(kmem_cache_size);
5508 +EXPORT_SYMBOL(register_cache);
5509 +EXPORT_SYMBOL(unregister_cache);
5510 EXPORT_SYMBOL(kmalloc);
5511 EXPORT_SYMBOL(kfree);
5512 EXPORT_SYMBOL(vfree);
5513 --- linux-2.4.20/mm/vmscan.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
5514 +++ linux-2.4.20-root/mm/vmscan.c 2003-05-07 18:08:03.000000000 +0800
5516 #include <linux/kernel_stat.h>
5517 #include <linux/swap.h>
5518 #include <linux/swapctl.h>
5519 +#include <linux/cache_def.h>
5520 #include <linux/smp_lock.h>
5521 #include <linux/pagemap.h>
5522 #include <linux/init.h>
5525 #define DEF_PRIORITY (6)
5527 +static DECLARE_MUTEX(other_caches_sem);
5528 +static LIST_HEAD(cache_definitions);
5530 +void register_cache(struct cache_definition *cache)
5532 + down(&other_caches_sem);
5533 + list_add(&cache->link, &cache_definitions);
5534 + up(&other_caches_sem);
5537 +void unregister_cache(struct cache_definition *cache)
5539 + down(&other_caches_sem);
5540 + list_del(&cache->link);
5541 + up(&other_caches_sem);
5544 +static void shrink_other_caches(unsigned int priority, int gfp_mask)
5546 + struct list_head *p;
5548 + if (down_trylock(&other_caches_sem))
5551 + list_for_each_prev(p, &cache_definitions) {
5552 + struct cache_definition *cache =
5553 + list_entry(p, struct cache_definition, link);
5555 + cache->shrink(priority, gfp_mask);
5557 + up(&other_caches_sem);
5561 * The swap-out function returns 1 if it successfully
5562 * scanned all the pages it was asked to (`count').
5563 @@ -577,6 +611,7 @@ static int shrink_caches(zone_t * classz
5565 shrink_dcache_memory(priority, gfp_mask);
5566 shrink_icache_memory(priority, gfp_mask);
5567 + shrink_other_caches(priority, gfp_mask);
5569 shrink_dqcache_memory(DEF_PRIORITY, gfp_mask);
5571 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5572 +++ linux-root/fs/ext3/ext3-exports.c 2003-05-05 18:19:11.000000000 +0800
5574 +#include <linux/config.h>
5575 +#include <linux/module.h>
5576 +#include <linux/ext3_fs.h>
5577 +#include <linux/ext3_jbd.h>
5578 +#include <linux/ext3_xattr.h>
5580 +EXPORT_SYMBOL(ext3_force_commit);
5581 +EXPORT_SYMBOL(ext3_bread);
5582 +EXPORT_SYMBOL(ext3_xattr_register);
5583 +EXPORT_SYMBOL(ext3_xattr_unregister);
5584 +EXPORT_SYMBOL(ext3_xattr_get);
5585 +EXPORT_SYMBOL(ext3_xattr_list);
5586 +EXPORT_SYMBOL(ext3_xattr_set);