a141c73f23f5490e2fb359b1669e254e2bfda761
[hdw-linux/hdw-linux.git] / packages / ia32 / lilo / kernel_2_6_x.patch
1 diff -Nur lilo-22.5.9-orig/Makefile lilo-22.5.9/Makefile
2 --- lilo-22.5.9-orig/Makefile   2004-07-10 02:41:41.000000000 +0200
3 +++ lilo-22.5.9/Makefile        2004-07-10 03:10:28.000000000 +0200
4 @@ -84,7 +84,7 @@
5  LD86=ld86 -0
6  NASM=nasm
7  
8 -CFLAGS=$(OPT) -Wall -g $(PCONFIG)
9 +CFLAGS=$(OPT) -Wall -g $(PCONFIG) -I./kernel-headers
10  LDFLAGS=#-Xlinker -qmagic
11  LIBS=
12  
13 diff -Nur lilo-22.5.9-orig/kernel-headers/asm/boot.h lilo-22.5.9/kernel-headers/asm/boot.h
14 --- lilo-22.5.9-orig/kernel-headers/asm/boot.h  1970-01-01 01:00:00.000000000 +0100
15 +++ lilo-22.5.9/kernel-headers/asm/boot.h       2004-07-10 02:56:48.000000000 +0200
16 @@ -0,0 +1,15 @@
17 +#ifndef _LINUX_BOOT_H
18 +#define _LINUX_BOOT_H
19 +
20 +/* Don't touch these, unless you really know what you're doing. */
21 +#define DEF_INITSEG    0x9000
22 +#define DEF_SYSSEG     0x1000
23 +#define DEF_SETUPSEG   0x9020
24 +#define DEF_SYSSIZE    0x7F00
25 +
26 +/* Internal svga startup constants */
27 +#define NORMAL_VGA     0xffff          /* 80x25 mode */
28 +#define EXTENDED_VGA   0xfffe          /* 80x50 mode */
29 +#define ASK_VGA                0xfffd          /* ask for it at bootup */
30 +
31 +#endif
32 diff -Nur lilo-22.5.9-orig/kernel-headers/asm/ioctl.h lilo-22.5.9/kernel-headers/asm/ioctl.h
33 --- lilo-22.5.9-orig/kernel-headers/asm/ioctl.h 1970-01-01 01:00:00.000000000 +0100
34 +++ lilo-22.5.9/kernel-headers/asm/ioctl.h      2004-07-10 02:56:48.000000000 +0200
35 @@ -0,0 +1,75 @@
36 +/* $Id: kernel_2_6_x.patch,v 1.1 2004-07-21 08:58:08 hackbard Exp $
37 + *
38 + * linux/ioctl.h for Linux by H.H. Bergman.
39 + */
40 +
41 +#ifndef _ASMI386_IOCTL_H
42 +#define _ASMI386_IOCTL_H
43 +
44 +/* ioctl command encoding: 32 bits total, command in lower 16 bits,
45 + * size of the parameter structure in the lower 14 bits of the
46 + * upper 16 bits.
47 + * Encoding the size of the parameter structure in the ioctl request
48 + * is useful for catching programs compiled with old versions
49 + * and to avoid overwriting user space outside the user buffer area.
50 + * The highest 2 bits are reserved for indicating the ``access mode''.
51 + * NOTE: This limits the max parameter size to 16kB -1 !
52 + */
53 +
54 +/*
55 + * The following is for compatibility across the various Linux
56 + * platforms.  The i386 ioctl numbering scheme doesn't really enforce
57 + * a type field.  De facto, however, the top 8 bits of the lower 16
58 + * bits are indeed used as a type field, so we might just as well make
59 + * this explicit here.  Please be sure to use the decoding macros
60 + * below from now on.
61 + */
62 +#define _IOC_NRBITS    8
63 +#define _IOC_TYPEBITS  8
64 +#define _IOC_SIZEBITS  14
65 +#define _IOC_DIRBITS   2
66 +
67 +#define _IOC_NRMASK    ((1 << _IOC_NRBITS)-1)
68 +#define _IOC_TYPEMASK  ((1 << _IOC_TYPEBITS)-1)
69 +#define _IOC_SIZEMASK  ((1 << _IOC_SIZEBITS)-1)
70 +#define _IOC_DIRMASK   ((1 << _IOC_DIRBITS)-1)
71 +
72 +#define _IOC_NRSHIFT   0
73 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
74 +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
75 +#define _IOC_DIRSHIFT  (_IOC_SIZESHIFT+_IOC_SIZEBITS)
76 +
77 +/*
78 + * Direction bits.
79 + */
80 +#define _IOC_NONE      0U
81 +#define _IOC_WRITE     1U
82 +#define _IOC_READ      2U
83 +
84 +#define _IOC(dir,type,nr,size) \
85 +       (((dir)  << _IOC_DIRSHIFT) | \
86 +        ((type) << _IOC_TYPESHIFT) | \
87 +        ((nr)   << _IOC_NRSHIFT) | \
88 +        ((size) << _IOC_SIZESHIFT))
89 +
90 +/* used to create numbers */
91 +#define _IO(type,nr)           _IOC(_IOC_NONE,(type),(nr),0)
92 +#define _IOR(type,nr,size)     _IOC(_IOC_READ,(type),(nr),sizeof(size))
93 +#define _IOW(type,nr,size)     _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
94 +#define _IOWR(type,nr,size)    _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
95 +
96 +/* used to decode ioctl numbers.. */
97 +#define _IOC_DIR(nr)           (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
98 +#define _IOC_TYPE(nr)          (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
99 +#define _IOC_NR(nr)            (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
100 +#define _IOC_SIZE(nr)          (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
101 +
102 +/* ...and for the drivers/sound files... */
103 +
104 +#define IOC_IN         (_IOC_WRITE << _IOC_DIRSHIFT)
105 +#define IOC_OUT                (_IOC_READ << _IOC_DIRSHIFT)
106 +#define IOC_INOUT      ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
107 +#define IOCSIZE_MASK   (_IOC_SIZEMASK << _IOC_SIZESHIFT)
108 +#define IOCSIZE_SHIFT  (_IOC_SIZESHIFT)
109 +
110 +#endif /* _ASMI386_IOCTL_H */
111 diff -Nur lilo-22.5.9-orig/kernel-headers/asm/page.h lilo-22.5.9/kernel-headers/asm/page.h
112 --- lilo-22.5.9-orig/kernel-headers/asm/page.h  1970-01-01 01:00:00.000000000 +0100
113 +++ lilo-22.5.9/kernel-headers/asm/page.h       2004-07-10 02:56:48.000000000 +0200
114 @@ -0,0 +1,142 @@
115 +#ifndef _I386_PAGE_H
116 +#define _I386_PAGE_H
117 +
118 +/* PAGE_SHIFT determines the page size */
119 +#define PAGE_SHIFT     12
120 +#define PAGE_SIZE      (1UL << PAGE_SHIFT)
121 +#define PAGE_MASK      (~(PAGE_SIZE-1))
122 +
123 +#ifdef __KERNEL__
124 +#ifndef __ASSEMBLY__
125 +
126 +#include <linux/config.h>
127 +
128 +#ifdef CONFIG_X86_USE_3DNOW
129 +
130 +#include <asm/mmx.h>
131 +
132 +#define clear_page(page)       mmx_clear_page((void *)(page))
133 +#define copy_page(to,from)     mmx_copy_page(to,from)
134 +
135 +#else
136 +
137 +/*
138 + *     On older X86 processors its not a win to use MMX here it seems.
139 + *     Maybe the K6-III ?
140 + */
141
142 +#define clear_page(page)       memset((void *)(page), 0, PAGE_SIZE)
143 +#define copy_page(to,from)     memcpy((void *)(to), (void *)(from), PAGE_SIZE)
144 +
145 +#endif
146 +
147 +#define clear_user_page(page, vaddr)   clear_page(page)
148 +#define copy_user_page(to, from, vaddr)        copy_page(to, from)
149 +
150 +/*
151 + * These are used to make use of C type-checking..
152 + */
153 +#if CONFIG_X86_PAE
154 +typedef struct { unsigned long pte_low, pte_high; } pte_t;
155 +typedef struct { unsigned long long pmd; } pmd_t;
156 +typedef struct { unsigned long long pgd; } pgd_t;
157 +#define pte_val(x)     ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
158 +#else
159 +typedef struct { unsigned long pte_low; } pte_t;
160 +typedef struct { unsigned long pmd; } pmd_t;
161 +typedef struct { unsigned long pgd; } pgd_t;
162 +#define pte_val(x)     ((x).pte_low)
163 +#endif
164 +#define PTE_MASK       PAGE_MASK
165 +
166 +typedef struct { unsigned long pgprot; } pgprot_t;
167 +
168 +#define pmd_val(x)     ((x).pmd)
169 +#define pgd_val(x)     ((x).pgd)
170 +#define pgprot_val(x)  ((x).pgprot)
171 +
172 +#define __pte(x) ((pte_t) { (x) } )
173 +#define __pmd(x) ((pmd_t) { (x) } )
174 +#define __pgd(x) ((pgd_t) { (x) } )
175 +#define __pgprot(x)    ((pgprot_t) { (x) } )
176 +
177 +#endif /* !__ASSEMBLY__ */
178 +
179 +/* to align the pointer to the (next) page boundary */
180 +#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
181 +
182 +/*
183 + * This handles the memory map.. We could make this a config
184 + * option, but too many people screw it up, and too few need
185 + * it.
186 + *
187 + * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
188 + * a virtual address space of one gigabyte, which limits the
189 + * amount of physical memory you can use to about 950MB. 
190 + *
191 + * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
192 + * and CONFIG_HIGHMEM64G options in the kernel configuration.
193 + */
194 +
195 +#define __PAGE_OFFSET          (0xC0000000)
196 +
197 +/*
198 + * This much address space is reserved for vmalloc() and iomap()
199 + * as well as fixmap mappings.
200 + */
201 +#define __VMALLOC_RESERVE      (128 << 20)
202 +
203 +#ifndef __ASSEMBLY__
204 +
205 +/*
206 + * Tell the user there is some problem. Beep too, so we can
207 + * see^H^H^Hhear bugs in early bootup as well!
208 + * The offending file and line are encoded after the "officially
209 + * undefined" opcode for parsing in the trap handler.
210 + */
211 +
212 +#if 1  /* Set to zero for a slightly smaller kernel */
213 +#define BUG()                          \
214 + __asm__ __volatile__( "ud2\n"         \
215 +                       "\t.word %c0\n" \
216 +                       "\t.long %c1\n" \
217 +                        : : "i" (__LINE__), "i" (__FILE__))
218 +#else
219 +#define BUG() __asm__ __volatile__("ud2\n")
220 +#endif
221 +
222 +#define PAGE_BUG(page) do { \
223 +       BUG(); \
224 +} while (0)
225 +
226 +/* Pure 2^n version of get_order */
227 +static __inline__ int get_order(unsigned long size)
228 +{
229 +       int order;
230 +
231 +       size = (size-1) >> (PAGE_SHIFT-1);
232 +       order = -1;
233 +       do {
234 +               size >>= 1;
235 +               order++;
236 +       } while (size);
237 +       return order;
238 +}
239 +
240 +#endif /* __ASSEMBLY__ */
241 +
242 +#define PAGE_OFFSET            ((unsigned long)__PAGE_OFFSET)
243 +#define VMALLOC_RESERVE                ((unsigned long)__VMALLOC_RESERVE)
244 +#define __MAXMEM               (-__PAGE_OFFSET-__VMALLOC_RESERVE)
245 +#define MAXMEM                 ((unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE))
246 +#define __pa(x)                        ((unsigned long)(x)-PAGE_OFFSET)
247 +#define __va(x)                        ((void *)((unsigned long)(x)+PAGE_OFFSET))
248 +#define virt_to_page(kaddr)    (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
249 +#define VALID_PAGE(page)       ((page - mem_map) < max_mapnr)
250 +
251 +#define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
252 +                                VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
253 +
254 +#endif /* __KERNEL__ */
255 +
256 +#endif /* _I386_PAGE_H */
257 diff -Nur lilo-22.5.9-orig/kernel-headers/asm/types.h lilo-22.5.9/kernel-headers/asm/types.h
258 --- lilo-22.5.9-orig/kernel-headers/asm/types.h 1970-01-01 01:00:00.000000000 +0100
259 +++ lilo-22.5.9/kernel-headers/asm/types.h      2004-07-10 02:56:48.000000000 +0200
260 @@ -0,0 +1,57 @@
261 +#ifndef _I386_TYPES_H
262 +#define _I386_TYPES_H
263 +
264 +typedef unsigned short umode_t;
265 +
266 +/*
267 + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
268 + * header files exported to user space
269 + */
270 +
271 +typedef __signed__ char __s8;
272 +typedef unsigned char __u8;
273 +
274 +typedef __signed__ short __s16;
275 +typedef unsigned short __u16;
276 +
277 +typedef __signed__ int __s32;
278 +typedef unsigned int __u32;
279 +
280 +#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
281 +typedef __signed__ long long __s64;
282 +typedef unsigned long long __u64;
283 +#endif
284 +
285 +/*
286 + * These aren't exported outside the kernel to avoid name space clashes
287 + */
288 +#ifdef __KERNEL__
289 +
290 +#include <linux/config.h>
291 +
292 +typedef signed char s8;
293 +typedef unsigned char u8;
294 +
295 +typedef signed short s16;
296 +typedef unsigned short u16;
297 +
298 +typedef signed int s32;
299 +typedef unsigned int u32;
300 +
301 +typedef signed long long s64;
302 +typedef unsigned long long u64;
303 +
304 +#define BITS_PER_LONG 32
305 +
306 +/* DMA addresses come in generic and 64-bit flavours.  */
307 +
308 +#ifdef CONFIG_HIGHMEM64G
309 +typedef u64 dma_addr_t;
310 +#else
311 +typedef u32 dma_addr_t;
312 +#endif
313 +typedef u64 dma64_addr_t;
314 +
315 +#endif /* __KERNEL__ */
316 +
317 +#endif
318 diff -Nur lilo-22.5.9-orig/kernel-headers/asm/unistd.h lilo-22.5.9/kernel-headers/asm/unistd.h
319 --- lilo-22.5.9-orig/kernel-headers/asm/unistd.h        1970-01-01 01:00:00.000000000 +0100
320 +++ lilo-22.5.9/kernel-headers/asm/unistd.h     2004-07-10 02:55:27.000000000 +0200
321 @@ -0,0 +1,386 @@
322 +#ifndef _ASM_I386_UNISTD_H_
323 +#define _ASM_I386_UNISTD_H_
324 +
325 +/*
326 + * This file contains the system call numbers.
327 + */
328 +
329 +#define __NR_exit                1
330 +#define __NR_fork                2
331 +#define __NR_read                3
332 +#define __NR_write               4
333 +#define __NR_open                5
334 +#define __NR_close               6
335 +#define __NR_waitpid             7
336 +#define __NR_creat               8
337 +#define __NR_link                9
338 +#define __NR_unlink             10
339 +#define __NR_execve             11
340 +#define __NR_chdir              12
341 +#define __NR_time               13
342 +#define __NR_mknod              14
343 +#define __NR_chmod              15
344 +#define __NR_lchown             16
345 +#define __NR_break              17
346 +#define __NR_oldstat            18
347 +#define __NR_lseek              19
348 +#define __NR_getpid             20
349 +#define __NR_mount              21
350 +#define __NR_umount             22
351 +#define __NR_setuid             23
352 +#define __NR_getuid             24
353 +#define __NR_stime              25
354 +#define __NR_ptrace             26
355 +#define __NR_alarm              27
356 +#define __NR_oldfstat           28
357 +#define __NR_pause              29
358 +#define __NR_utime              30
359 +#define __NR_stty               31
360 +#define __NR_gtty               32
361 +#define __NR_access             33
362 +#define __NR_nice               34
363 +#define __NR_ftime              35
364 +#define __NR_sync               36
365 +#define __NR_kill               37
366 +#define __NR_rename             38
367 +#define __NR_mkdir              39
368 +#define __NR_rmdir              40
369 +#define __NR_dup                41
370 +#define __NR_pipe               42
371 +#define __NR_times              43
372 +#define __NR_prof               44
373 +#define __NR_brk                45
374 +#define __NR_setgid             46
375 +#define __NR_getgid             47
376 +#define __NR_signal             48
377 +#define __NR_geteuid            49
378 +#define __NR_getegid            50
379 +#define __NR_acct               51
380 +#define __NR_umount2            52
381 +#define __NR_lock               53
382 +#define __NR_ioctl              54
383 +#define __NR_fcntl              55
384 +#define __NR_mpx                56
385 +#define __NR_setpgid            57
386 +#define __NR_ulimit             58
387 +#define __NR_oldolduname        59
388 +#define __NR_umask              60
389 +#define __NR_chroot             61
390 +#define __NR_ustat              62
391 +#define __NR_dup2               63
392 +#define __NR_getppid            64
393 +#define __NR_getpgrp            65
394 +#define __NR_setsid             66
395 +#define __NR_sigaction          67
396 +#define __NR_sgetmask           68
397 +#define __NR_ssetmask           69
398 +#define __NR_setreuid           70
399 +#define __NR_setregid           71
400 +#define __NR_sigsuspend                 72
401 +#define __NR_sigpending                 73
402 +#define __NR_sethostname        74
403 +#define __NR_setrlimit          75
404 +#define __NR_getrlimit          76     /* Back compatible 2Gig limited rlimit */
405 +#define __NR_getrusage          77
406 +#define __NR_gettimeofday       78
407 +#define __NR_settimeofday       79
408 +#define __NR_getgroups          80
409 +#define __NR_setgroups          81
410 +#define __NR_select             82
411 +#define __NR_symlink            83
412 +#define __NR_oldlstat           84
413 +#define __NR_readlink           85
414 +#define __NR_uselib             86
415 +#define __NR_swapon             87
416 +#define __NR_reboot             88
417 +#define __NR_readdir            89
418 +#define __NR_mmap               90
419 +#define __NR_munmap             91
420 +#define __NR_truncate           92
421 +#define __NR_ftruncate          93
422 +#define __NR_fchmod             94
423 +#define __NR_fchown             95
424 +#define __NR_getpriority        96
425 +#define __NR_setpriority        97
426 +#define __NR_profil             98
427 +#define __NR_statfs             99
428 +#define __NR_fstatfs           100
429 +#define __NR_ioperm            101
430 +#define __NR_socketcall                102
431 +#define __NR_syslog            103
432 +#define __NR_setitimer         104
433 +#define __NR_getitimer         105
434 +#define __NR_stat              106
435 +#define __NR_lstat             107
436 +#define __NR_fstat             108
437 +#define __NR_olduname          109
438 +#define __NR_iopl              110
439 +#define __NR_vhangup           111
440 +#define __NR_idle              112
441 +#define __NR_vm86old           113
442 +#define __NR_wait4             114
443 +#define __NR_swapoff           115
444 +#define __NR_sysinfo           116
445 +#define __NR_ipc               117
446 +#define __NR_fsync             118
447 +#define __NR_sigreturn         119
448 +#define __NR_clone             120
449 +#define __NR_setdomainname     121
450 +#define __NR_uname             122
451 +#define __NR_modify_ldt                123
452 +#define __NR_adjtimex          124
453 +#define __NR_mprotect          125
454 +#define __NR_sigprocmask       126
455 +#define __NR_create_module     127
456 +#define __NR_init_module       128
457 +#define __NR_delete_module     129
458 +#define __NR_get_kernel_syms   130
459 +#define __NR_quotactl          131
460 +#define __NR_getpgid           132
461 +#define __NR_fchdir            133
462 +#define __NR_bdflush           134
463 +#define __NR_sysfs             135
464 +#define __NR_personality       136
465 +#define __NR_afs_syscall       137 /* Syscall for Andrew File System */
466 +#define __NR_setfsuid          138
467 +#define __NR_setfsgid          139
468 +#define __NR__llseek           140
469 +#define __NR_getdents          141
470 +#define __NR__newselect                142
471 +#define __NR_flock             143
472 +#define __NR_msync             144
473 +#define __NR_readv             145
474 +#define __NR_writev            146
475 +#define __NR_getsid            147
476 +#define __NR_fdatasync         148
477 +#define __NR__sysctl           149
478 +#define __NR_mlock             150
479 +#define __NR_munlock           151
480 +#define __NR_mlockall          152
481 +#define __NR_munlockall                153
482 +#define __NR_sched_setparam            154
483 +#define __NR_sched_getparam            155
484 +#define __NR_sched_setscheduler                156
485 +#define __NR_sched_getscheduler                157
486 +#define __NR_sched_yield               158
487 +#define __NR_sched_get_priority_max    159
488 +#define __NR_sched_get_priority_min    160
489 +#define __NR_sched_rr_get_interval     161
490 +#define __NR_nanosleep         162
491 +#define __NR_mremap            163
492 +#define __NR_setresuid         164
493 +#define __NR_getresuid         165
494 +#define __NR_vm86              166
495 +#define __NR_query_module      167
496 +#define __NR_poll              168
497 +#define __NR_nfsservctl                169
498 +#define __NR_setresgid         170
499 +#define __NR_getresgid         171
500 +#define __NR_prctl              172
501 +#define __NR_rt_sigreturn      173
502 +#define __NR_rt_sigaction      174
503 +#define __NR_rt_sigprocmask    175
504 +#define __NR_rt_sigpending     176
505 +#define __NR_rt_sigtimedwait   177
506 +#define __NR_rt_sigqueueinfo   178
507 +#define __NR_rt_sigsuspend     179
508 +#define __NR_pread             180
509 +#define __NR_pwrite            181
510 +#define __NR_chown             182
511 +#define __NR_getcwd            183
512 +#define __NR_capget            184
513 +#define __NR_capset            185
514 +#define __NR_sigaltstack       186
515 +#define __NR_sendfile          187
516 +#define __NR_getpmsg           188     /* some people actually want streams */
517 +#define __NR_putpmsg           189     /* some people actually want streams */
518 +#define __NR_vfork             190
519 +#define __NR_ugetrlimit                191     /* SuS compliant getrlimit */
520 +#define __NR_mmap2             192
521 +#define __NR_truncate64                193
522 +#define __NR_ftruncate64       194
523 +#define __NR_stat64            195
524 +#define __NR_lstat64           196
525 +#define __NR_fstat64           197
526 +#define __NR_lchown32          198
527 +#define __NR_getuid32          199
528 +#define __NR_getgid32          200
529 +#define __NR_geteuid32         201
530 +#define __NR_getegid32         202
531 +#define __NR_setreuid32                203
532 +#define __NR_setregid32                204
533 +#define __NR_getgroups32       205
534 +#define __NR_setgroups32       206
535 +#define __NR_fchown32          207
536 +#define __NR_setresuid32       208
537 +#define __NR_getresuid32       209
538 +#define __NR_setresgid32       210
539 +#define __NR_getresgid32       211
540 +#define __NR_chown32           212
541 +#define __NR_setuid32          213
542 +#define __NR_setgid32          214
543 +#define __NR_setfsuid32                215
544 +#define __NR_setfsgid32                216
545 +#define __NR_pivot_root                217
546 +#define __NR_mincore           218
547 +#define __NR_madvise           219
548 +#define __NR_madvise1          219     /* delete when C lib stub is removed */
549 +#define __NR_getdents64                220
550 +#define __NR_fcntl64           221
551 +#define __NR_security          223     /* syscall for security modules */
552 +#define __NR_gettid            224
553 +#define __NR_readahead         225
554 +#define __NR_setxattr          226
555 +#define __NR_lsetxattr         227
556 +#define __NR_fsetxattr         228
557 +#define __NR_getxattr          229
558 +#define __NR_lgetxattr         230
559 +#define __NR_fgetxattr         231
560 +#define __NR_listxattr         232
561 +#define __NR_llistxattr                233
562 +#define __NR_flistxattr                234
563 +#define __NR_removexattr       235
564 +#define __NR_lremovexattr      236
565 +#define __NR_fremovexattr      237
566 +#define __NR_tkill             238
567 +#define __NR_sendfile64                239
568 +#define __NR_futex             240
569 +#define __NR_sched_setaffinity 241
570 +#define __NR_sched_getaffinity 242
571 +#define __NR_set_thread_area   243
572 +#define __NR_get_thread_area   244
573 +#define __NR_io_setup          245
574 +#define __NR_io_destroy                246
575 +#define __NR_io_getevents      247
576 +#define __NR_io_submit         248
577 +#define __NR_io_cancel         249
578 +#define __NR_alloc_hugepages   250
579 +#define __NR_free_hugepages    251
580 +#define __NR_exit_group                252
581 +
582 +/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
583 +
584 +#define __syscall_return(type, res) \
585 +do { \
586 +       if ((unsigned long)(res) >= (unsigned long)(-125)) { \
587 +               errno = -(res); \
588 +               res = -1; \
589 +       } \
590 +       return (type) (res); \
591 +} while (0)
592 +
593 +/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
594 +#define _syscall0(type,name) \
595 +type name(void) \
596 +{ \
597 +long __res; \
598 +__asm__ volatile ("int $0x80" \
599 +       : "=a" (__res) \
600 +       : "0" (__NR_##name)); \
601 +__syscall_return(type,__res); \
602 +}
603 +
604 +#define _syscall1(type,name,type1,arg1) \
605 +type name(type1 arg1) \
606 +{ \
607 +long __res; \
608 +__asm__ volatile ("int $0x80" \
609 +       : "=a" (__res) \
610 +       : "0" (__NR_##name),"b" ((long)(arg1))); \
611 +__syscall_return(type,__res); \
612 +}
613 +
614 +#define _syscall2(type,name,type1,arg1,type2,arg2) \
615 +type name(type1 arg1,type2 arg2) \
616 +{ \
617 +long __res; \
618 +__asm__ volatile ("int $0x80" \
619 +       : "=a" (__res) \
620 +       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \
621 +__syscall_return(type,__res); \
622 +}
623 +
624 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
625 +type name(type1 arg1,type2 arg2,type3 arg3) \
626 +{ \
627 +long __res; \
628 +__asm__ volatile ("int $0x80" \
629 +       : "=a" (__res) \
630 +       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
631 +                 "d" ((long)(arg3))); \
632 +__syscall_return(type,__res); \
633 +}
634 +
635 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
636 +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
637 +{ \
638 +long __res; \
639 +__asm__ volatile ("int $0x80" \
640 +       : "=a" (__res) \
641 +       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
642 +         "d" ((long)(arg3)),"S" ((long)(arg4))); \
643 +__syscall_return(type,__res); \
644 +} 
645 +
646 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
647 +         type5,arg5) \
648 +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
649 +{ \
650 +long __res; \
651 +__asm__ volatile ("int $0x80" \
652 +       : "=a" (__res) \
653 +       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
654 +         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
655 +__syscall_return(type,__res); \
656 +}
657 +
658 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
659 +         type5,arg5,type6,arg6) \
660 +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
661 +{ \
662 +long __res; \
663 +__asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; int $0x80 ; pop %%ebp" \
664 +       : "=a" (__res) \
665 +       : "i" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
666 +         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
667 +         "0" ((long)(arg6))); \
668 +__syscall_return(type,__res); \
669 +}
670 +
671 +#ifdef __KERNEL_SYSCALLS__
672 +
673 +/*
674 + * we need this inline - forking from kernel space will result
675 + * in NO COPY ON WRITE (!!!), until an execve is executed. This
676 + * is no problem, but for the stack. This is handled by not letting
677 + * main() use the stack at all after fork(). Thus, no function
678 + * calls - which means inline code for fork too, as otherwise we
679 + * would use the stack upon exit from 'fork()'.
680 + *
681 + * Actually only pause and fork are needed inline, so that there
682 + * won't be any messing with the stack from main(), but we define
683 + * some others too.
684 + */
685 +#define __NR__exit __NR_exit
686 +static inline _syscall0(int,pause)
687 +static inline _syscall0(int,sync)
688 +static inline _syscall0(pid_t,setsid)
689 +static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
690 +static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
691 +static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
692 +static inline _syscall1(int,dup,int,fd)
693 +static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
694 +static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
695 +static inline _syscall1(int,close,int,fd)
696 +static inline _syscall1(int,_exit,int,exitcode)
697 +static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
698 +static inline _syscall1(int,delete_module,const char *,name)
699 +
700 +static inline pid_t wait(int * wait_stat)
701 +{
702 +       return waitpid(-1,wait_stat,0);
703 +}
704 +
705 +#endif
706 +
707 +#endif /* _ASM_I386_UNISTD_H_ */
708 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/config.h lilo-22.5.9/kernel-headers/linux/config.h
709 --- lilo-22.5.9-orig/kernel-headers/linux/config.h      1970-01-01 01:00:00.000000000 +0100
710 +++ lilo-22.5.9/kernel-headers/linux/config.h   2004-07-10 02:59:15.000000000 +0200
711 @@ -0,0 +1,6 @@
712 +#ifndef _LINUX_CONFIG_H
713 +#define _LINUX_CONFIG_H
714 +
715 +#include <linux/autoconf.h>
716 +
717 +#endif
718 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/fd.h lilo-22.5.9/kernel-headers/linux/fd.h
719 --- lilo-22.5.9-orig/kernel-headers/linux/fd.h  1970-01-01 01:00:00.000000000 +0100
720 +++ lilo-22.5.9/kernel-headers/linux/fd.h       2004-07-10 02:59:14.000000000 +0200
721 @@ -0,0 +1,372 @@
722 +#ifndef _LINUX_FD_H
723 +#define _LINUX_FD_H
724 +
725 +#include <linux/ioctl.h>
726 +
727 +/* New file layout: Now the ioctl definitions immediately follow the
728 + * definitions of the structures that they use */
729 +
730 +/*
731 + * Geometry
732 + */
733 +struct floppy_struct {
734 +       unsigned int    size,           /* nr of sectors total */
735 +                       sect,           /* sectors per track */
736 +                       head,           /* nr of heads */
737 +                       track,          /* nr of tracks */
738 +                       stretch;        /* !=0 means double track steps */
739 +#define FD_STRETCH 1
740 +#define FD_SWAPSIDES 2
741 +
742 +       unsigned char   gap,            /* gap1 size */
743 +
744 +                       rate,           /* data rate. |= 0x40 for perpendicular */
745 +#define FD_2M 0x4
746 +#define FD_SIZECODEMASK 0x38
747 +#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8)
748 +#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \
749 +                            512 : 128 << FD_SIZECODE(floppy) )
750 +#define FD_PERP 0x40
751 +
752 +                       spec1,          /* stepping rate, head unload time */
753 +                       fmt_gap;        /* gap2 size */
754 +       const char      * name; /* used only for predefined formats */
755 +};
756 +
757 +
758 +/* commands needing write access have 0x40 set */
759 +/* commands needing super user access have 0x80 set */
760 +
761 +#define FDCLRPRM _IO(2, 0x41)
762 +/* clear user-defined parameters */
763 +
764 +#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) 
765 +#define FDSETMEDIAPRM FDSETPRM
766 +/* set user-defined parameters for current media */
767 +
768 +#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) 
769 +#define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
770 +#define FDDEFMEDIAPRM FDDEFPRM
771 +#define FDGETMEDIAPRM FDGETPRM
772 +/* set/get disk parameters */
773 +
774 +
775 +#define        FDMSGON  _IO(2,0x45)
776 +#define        FDMSGOFF _IO(2,0x46)
777 +/* issue/don't issue kernel messages on media type change */
778 +
779 +
780 +/* 
781 + * Formatting (obsolete)
782 + */
783 +#define FD_FILL_BYTE 0xF6 /* format fill byte. */
784 +
785 +struct format_descr {
786 +       unsigned int device,head,track;
787 +};
788 +
789 +#define FDFMTBEG _IO(2,0x47)
790 +/* begin formatting a disk */
791 +#define        FDFMTTRK _IOW(2,0x48, struct format_descr)
792 +/* format the specified track */
793 +#define FDFMTEND _IO(2,0x49)
794 +/* end formatting a disk */
795 +
796 +
797 +/*
798 + * Error thresholds
799 + */
800 +struct floppy_max_errors {
801 +       unsigned int
802 +         abort,      /* number of errors to be reached before aborting */
803 +         read_track, /* maximal number of errors permitted to read an
804 +                      * entire track at once */
805 +         reset,      /* maximal number of errors before a reset is tried */
806 +         recal,      /* maximal number of errors before a recalibrate is
807 +                      * tried */
808 +
809 +         /*
810 +          * Threshold for reporting FDC errors to the console.
811 +          * Setting this to zero may flood your screen when using
812 +          * ultra cheap floppies ;-)
813 +          */
814 +         reporting;
815 +
816 +};
817 +
818 +#define FDSETEMSGTRESH _IO(2,0x4a)
819 +/* set fdc error reporting threshold */
820 +
821 +#define FDFLUSH  _IO(2,0x4b)
822 +/* flush buffers for media; either for verifying media, or for
823 + * handling a media change without closing the file descriptor */
824 +
825 +#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors)
826 +#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors)
827 +/* set/get abortion and read_track threshold. See also floppy_drive_params
828 + * structure */
829 +
830 +
831 +typedef char floppy_drive_name[16];
832 +#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name)
833 +/* get drive type: 5 1/4 or 3 1/2 */
834 +
835 +
836 +/*
837 + * Drive parameters (user modifiable)
838 + */
839 +struct floppy_drive_params {
840 +       signed char cmos;               /* CMOS type */
841 +       
842 +       /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms 
843 +        * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA).
844 +        */
845 +       unsigned long max_dtr;          /* Step rate, usec */
846 +       unsigned long hlt;              /* Head load/settle time, msec */
847 +       unsigned long hut;              /* Head unload time (remnant of 
848 +                                        * 8" drives) */
849 +       unsigned long srt;              /* Step rate, usec */
850 +
851 +       unsigned long spinup;           /* time needed for spinup (expressed
852 +                                        * in jiffies) */
853 +       unsigned long spindown;         /* timeout needed for spindown */
854 +       unsigned char spindown_offset;  /* decides in which position the disk
855 +                                        * will stop */
856 +       unsigned char select_delay;     /* delay to wait after select */
857 +       unsigned char rps;              /* rotations per second */
858 +       unsigned char tracks;           /* maximum number of tracks */
859 +       unsigned long timeout;          /* timeout for interrupt requests */
860 +       
861 +       unsigned char interleave_sect;  /* if there are more sectors, use 
862 +                                        * interleave */
863 +       
864 +       struct floppy_max_errors max_errors;
865 +       
866 +       char flags;                     /* various flags, including ftd_msg */
867 +/*
868 + * Announce successful media type detection and media information loss after
869 + * disk changes.
870 + * Also used to enable/disable printing of overrun warnings.
871 + */
872 +
873 +#define FTD_MSG 0x10
874 +#define FD_BROKEN_DCL 0x20
875 +#define FD_DEBUG 0x02
876 +#define FD_SILENT_DCL_CLEAR 0x4
877 +#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware 
878 +                               considerations */
879 +
880 +       char read_track;                /* use readtrack during probing? */
881 +
882 +/*
883 + * Auto-detection. Each drive type has eight formats which are
884 + * used in succession to try to read the disk. If the FDC cannot lock onto
885 + * the disk, the next format is tried. This uses the variable 'probing'.
886 + */
887 +       short autodetect[8];            /* autodetected formats */
888 +       
889 +       int checkfreq; /* how often should the drive be checked for disk 
890 +                       * changes */
891 +       int native_format; /* native format of this drive */
892 +};
893 +
894 +enum {
895 +       FD_NEED_TWADDLE_BIT,    /* more magic */
896 +       FD_VERIFY_BIT,          /* inquire for write protection */
897 +       FD_DISK_NEWCHANGE_BIT,  /* change detected, and no action undertaken yet
898 +                                * to clear media change status */
899 +       FD_UNUSED_BIT,
900 +       FD_DISK_CHANGED_BIT,    /* disk has been changed since last i/o */
901 +       FD_DISK_WRITABLE_BIT    /* disk is writable */
902 +};
903 +
904 +#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params)
905 +#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params)
906 +/* set/get drive parameters */
907 +
908 +
909 +/*
910 + * Current drive state (not directly modifiable by user, readonly)
911 + */
912 +struct floppy_drive_struct {
913 +       unsigned long flags;
914 +/* values for these flags */
915 +#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
916 +#define FD_VERIFY (1 << FD_VERIFY_BIT)
917 +#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
918 +#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
919 +#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
920 +
921 +       unsigned long spinup_date;
922 +       unsigned long select_date;
923 +       unsigned long first_read_date;
924 +       short probed_format;
925 +       short track; /* current track */
926 +       short maxblock; /* id of highest block read */
927 +       short maxtrack; /* id of highest half track read */
928 +       int generation; /* how many diskchanges? */
929 +
930 +/*
931 + * (User-provided) media information is _not_ discarded after a media change
932 + * if the corresponding keep_data flag is non-zero. Positive values are
933 + * decremented after each probe.
934 + */
935 +       int keep_data;
936 +       
937 +       /* Prevent "aliased" accesses. */
938 +       int fd_ref;
939 +       int fd_device;
940 +       unsigned long last_checked; /* when was the drive last checked for a disk 
941 +                          * change? */
942 +       
943 +       char *dmabuf;
944 +       int bufblocks;
945 +};
946 +
947 +#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct)
948 +#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct)
949 +/* get drive state: GET returns the cached state, POLL polls for new state */
950 +
951 +
952 +/*
953 + * reset FDC
954 + */
955 +enum reset_mode {
956 +       FD_RESET_IF_NEEDED,     /* reset only if the reset flags is set */
957 +       FD_RESET_IF_RAWCMD,     /* obsolete */
958 +       FD_RESET_ALWAYS         /* reset always */
959 +};
960 +#define FDRESET _IO(2, 0x54)
961 +
962 +
963 +/*
964 + * FDC state
965 + */
966 +struct floppy_fdc_state {      
967 +       int spec1;              /* spec1 value last used */
968 +       int spec2;              /* spec2 value last used */
969 +       int dtr;
970 +       unsigned char version;  /* FDC version code */
971 +       unsigned char dor;
972 +       unsigned long address;  /* io address */
973 +       unsigned int rawcmd:2;
974 +       unsigned int reset:1;
975 +       unsigned int need_configure:1;
976 +       unsigned int perp_mode:2;
977 +       unsigned int has_fifo:1;
978 +       unsigned int driver_version;    /* version code for floppy driver */
979 +#define FD_DRIVER_VERSION 0x100
980 +/* user programs using the floppy API should use floppy_fdc_state to
981 + * get the version number of the floppy driver that they are running
982 + * on. If this version number is bigger than the one compiled into the
983 + * user program (the FD_DRIVER_VERSION define), it should be prepared
984 + * to bigger structures
985 + */
986 +
987 +       unsigned char track[4];
988 +       /* Position of the heads of the 4 units attached to this FDC,
989 +        * as stored on the FDC. In the future, the position as stored
990 +        * on the FDC might not agree with the actual physical
991 +        * position of these drive heads. By allowing such
992 +        * disagreement, it will be possible to reset the FDC without
993 +        * incurring the expensive cost of repositioning all heads.
994 +        * Right now, these positions are hard wired to 0. */
995 +
996 +};
997 +
998 +#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state)
999 +
1000 +
1001 +/*
1002 + * Asynchronous Write error tracking
1003 + */
1004 +struct floppy_write_errors {
1005 +       /* Write error logging.
1006 +        *
1007 +        * These fields can be cleared with the FDWERRORCLR ioctl.
1008 +        * Only writes that were attempted but failed due to a physical media
1009 +        * error are logged.  write(2) calls that fail and return an error code
1010 +        * to the user process are not counted.
1011 +        */
1012 +
1013 +       unsigned int write_errors;  /* number of physical write errors 
1014 +                                    * encountered */
1015 +       
1016 +       /* position of first and last write errors */
1017 +       unsigned long first_error_sector;
1018 +       int           first_error_generation;
1019 +       unsigned long last_error_sector;
1020 +       int           last_error_generation;
1021 +       
1022 +       unsigned int badness; /* highest retry count for a read or write 
1023 +                              * operation */
1024 +};
1025 +
1026 +#define FDWERRORCLR  _IO(2, 0x56)
1027 +/* clear write error and badness information */
1028 +#define FDWERRORGET  _IOR(2, 0x17, struct floppy_write_errors)
1029 +/* get write error and badness information */
1030 +
1031 +
1032 +/*
1033 + * Raw commands
1034 + */
1035 +/* new interface flag: now we can do them in batches */
1036 +#define FDHAVEBATCHEDRAWCMD
1037 +
1038 +struct floppy_raw_cmd {
1039 +       unsigned int flags;
1040 +#define FD_RAW_READ 1
1041 +#define FD_RAW_WRITE 2
1042 +#define FD_RAW_NO_MOTOR 4
1043 +#define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */
1044 +#define FD_RAW_INTR 8    /* wait for an interrupt */
1045 +#define FD_RAW_SPIN 0x10 /* spin up the disk for this command */
1046 +#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command 
1047 +                                   * completion */
1048 +#define FD_RAW_NEED_DISK 0x40  /* this command needs a disk to be present */
1049 +#define FD_RAW_NEED_SEEK 0x80  /* this command uses an implied seek (soft) */
1050 +
1051 +/* more "in" flags */
1052 +#define FD_RAW_MORE 0x100  /* more records follow */
1053 +#define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */
1054 +#define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */
1055 +#define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure
1056 +                                 * detection too */
1057 +
1058 +/* more "out" flags */
1059 +#define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */
1060 +#define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */
1061 +
1062 +       void *data;
1063 +       char *kernel_data; /* location of data buffer in the kernel */
1064 +       struct floppy_raw_cmd *next; /* used for chaining of raw cmd's 
1065 +                                     * within the kernel */
1066 +       long length; /* in: length of dma transfer. out: remaining bytes */
1067 +       long phys_length; /* physical length, if different from dma length */
1068 +       int buffer_length; /* length of allocated buffer */
1069 +
1070 +       unsigned char rate;
1071 +       unsigned char cmd_count;
1072 +       unsigned char cmd[16];
1073 +       unsigned char reply_count;
1074 +       unsigned char reply[16];
1075 +       int track;
1076 +       int resultcode;
1077 +
1078 +       int reserved1;
1079 +       int reserved2;
1080 +};
1081 +
1082 +#define FDRAWCMD _IO(2, 0x58)
1083 +/* send a raw command to the fdc. Structure size not included, because of
1084 + * batches */
1085 +
1086 +#define FDTWADDLE _IO(2, 0x59)
1087 +/* flicker motor-on bit before reading a sector. Experimental */
1088 +
1089 +
1090 +#define FDEJECT _IO(2, 0x5a)
1091 +/* eject the disk */
1092 +
1093 +#endif
1094 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/fs.h lilo-22.5.9/kernel-headers/linux/fs.h
1095 --- lilo-22.5.9-orig/kernel-headers/linux/fs.h  1970-01-01 01:00:00.000000000 +0100
1096 +++ lilo-22.5.9/kernel-headers/linux/fs.h       2004-07-10 02:59:14.000000000 +0200
1097 @@ -0,0 +1,1675 @@
1098 +#ifndef _LINUX_FS_H
1099 +#define _LINUX_FS_H
1100 +
1101 +/*
1102 + * This file has definitions for some important file table
1103 + * structures etc.
1104 + */
1105 +
1106 +#include <linux/config.h>
1107 +#include <linux/linkage.h>
1108 +#include <linux/limits.h>
1109 +#include <linux/wait.h>
1110 +#include <linux/types.h>
1111 +#include <linux/vfs.h>
1112 +#include <linux/net.h>
1113 +#include <linux/kdev_t.h>
1114 +#include <linux/ioctl.h>
1115 +#include <linux/list.h>
1116 +#include <linux/dcache.h>
1117 +#include <linux/stat.h>
1118 +#include <linux/cache.h>
1119 +#include <linux/stddef.h>
1120 +#include <linux/string.h>
1121 +
1122 +#include <asm/atomic.h>
1123 +#include <asm/bitops.h>
1124 +
1125 +struct poll_table_struct;
1126 +
1127 +
1128 +/*
1129 + * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
1130 + * the file limit at runtime and only root can increase the per-process
1131 + * nr_file rlimit, so it's safe to set up a ridiculously high absolute
1132 + * upper limit on files-per-process.
1133 + *
1134 + * Some programs (notably those using select()) may have to be 
1135 + * recompiled to take full advantage of the new limits..  
1136 + */
1137 +
1138 +/* Fixed constants first: */
1139 +#undef NR_OPEN
1140 +#define NR_OPEN (1024*1024)    /* Absolute upper limit on fd num */
1141 +#define INR_OPEN 1024          /* Initial setting for nfile rlimits */
1142 +
1143 +#define BLOCK_SIZE_BITS 10
1144 +#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
1145 +
1146 +/* And dynamically-tunable limits and defaults: */
1147 +struct files_stat_struct {
1148 +       int nr_files;           /* read only */
1149 +       int nr_free_files;      /* read only */
1150 +       int max_files;          /* tunable */
1151 +};
1152 +extern struct files_stat_struct files_stat;
1153 +
1154 +struct inodes_stat_t {
1155 +       int nr_inodes;
1156 +       int nr_unused;
1157 +       int dummy[5];
1158 +};
1159 +extern struct inodes_stat_t inodes_stat;
1160 +
1161 +extern int leases_enable, dir_notify_enable, lease_break_time;
1162 +
1163 +#define NR_FILE  8192  /* this can well be larger on a larger system */
1164 +#define NR_RESERVED_FILES 10 /* reserved for root */
1165 +#define NR_SUPER 256
1166 +
1167 +#define MAY_EXEC 1
1168 +#define MAY_WRITE 2
1169 +#define MAY_READ 4
1170 +
1171 +#define FMODE_READ 1
1172 +#define FMODE_WRITE 2
1173 +
1174 +#define READ 0
1175 +#define WRITE 1
1176 +#define READA 2                /* read-ahead  - don't block if no resources */
1177 +#define SPECIAL 4      /* For non-blockdevice requests in request queue */
1178 +
1179 +#define SEL_IN         1
1180 +#define SEL_OUT                2
1181 +#define SEL_EX         4
1182 +
1183 +/* public flags for file_system_type */
1184 +#define FS_REQUIRES_DEV 1 
1185 +#define FS_NO_DCACHE   2 /* Only dcache the necessary things. */
1186 +#define FS_NO_PRELIM   4 /* prevent preloading of dentries, even if
1187 +                          * FS_NO_DCACHE is not set.
1188 +                          */
1189 +#define FS_SINGLE      8 /* Filesystem that can have only one superblock */
1190 +#define FS_NOMOUNT     16 /* Never mount from userland */
1191 +#define FS_LITTER      32 /* Keeps the tree in dcache */
1192 +#define FS_ODD_RENAME  32768   /* Temporary stuff; will go away as soon
1193 +                                 * as nfs_rename() will be cleaned up
1194 +                                 */
1195 +/*
1196 + * These are the fs-independent mount-flags: up to 32 flags are supported
1197 + */
1198 +#define MS_RDONLY       1      /* Mount read-only */
1199 +#define MS_NOSUID       2      /* Ignore suid and sgid bits */
1200 +#define MS_NODEV        4      /* Disallow access to device special files */
1201 +#define MS_NOEXEC       8      /* Disallow program execution */
1202 +#define MS_SYNCHRONOUS 16      /* Writes are synced at once */
1203 +#define MS_REMOUNT     32      /* Alter flags of a mounted FS */
1204 +#define MS_MANDLOCK    64      /* Allow mandatory locks on an FS */
1205 +#define MS_NOATIME     1024    /* Do not update access times. */
1206 +#define MS_NODIRATIME  2048    /* Do not update directory access times */
1207 +#define MS_BIND                4096
1208 +#define MS_MOVE                8192
1209 +#define MS_REC         16384
1210 +#define MS_VERBOSE     32768
1211 +#define MS_ACTIVE      (1<<30)
1212 +#define MS_NOUSER      (1<<31)
1213 +
1214 +/*
1215 + * Superblock flags that can be altered by MS_REMOUNT
1216 + */
1217 +#define MS_RMT_MASK    (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
1218 +                        MS_NODIRATIME)
1219 +
1220 +/*
1221 + * Old magic mount flag and mask
1222 + */
1223 +#define MS_MGC_VAL 0xC0ED0000
1224 +#define MS_MGC_MSK 0xffff0000
1225 +
1226 +/* Inode flags - they have nothing to superblock flags now */
1227 +
1228 +#define S_SYNC         1       /* Writes are synced at once */
1229 +#define S_NOATIME      2       /* Do not update access times */
1230 +#define S_QUOTA                4       /* Quota initialized for file */
1231 +#define S_APPEND       8       /* Append-only file */
1232 +#define S_IMMUTABLE    16      /* Immutable file */
1233 +#define S_DEAD         32      /* removed, but still open directory */
1234 +#define S_NOQUOTA      64      /* Inode is not counted to quota */
1235 +
1236 +/*
1237 + * Note that nosuid etc flags are inode-specific: setting some file-system
1238 + * flags just means all the inodes inherit those flags by default. It might be
1239 + * possible to override it selectively if you really wanted to with some
1240 + * ioctl() that is not currently implemented.
1241 + *
1242 + * Exception: MS_RDONLY is always applied to the entire file system.
1243 + *
1244 + * Unfortunately, it is possible to change a filesystems flags with it mounted
1245 + * with files in use.  This means that all of the inodes will not have their
1246 + * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
1247 + * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
1248 + */
1249 +#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
1250 +
1251 +#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
1252 +#define IS_SYNC(inode)         (__IS_FLG(inode, MS_SYNCHRONOUS) || ((inode)->i_flags & S_SYNC))
1253 +#define IS_MANDLOCK(inode)     __IS_FLG(inode, MS_MANDLOCK)
1254 +
1255 +#define IS_QUOTAINIT(inode)    ((inode)->i_flags & S_QUOTA)
1256 +#define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
1257 +#define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
1258 +#define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
1259 +#define IS_NOATIME(inode)      (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
1260 +#define IS_NODIRATIME(inode)   __IS_FLG(inode, MS_NODIRATIME)
1261 +
1262 +#define IS_DEADDIR(inode)      ((inode)->i_flags & S_DEAD)
1263 +
1264 +/* the read-only stuff doesn't really belong here, but any other place is
1265 +   probably as bad and I don't want to create yet another include file. */
1266 +
1267 +#define BLKROSET   _IO(0x12,93)        /* set device read-only (0 = read-write) */
1268 +#define BLKROGET   _IO(0x12,94)        /* get read-only status (0 = read_write) */
1269 +#define BLKRRPART  _IO(0x12,95)        /* re-read partition table */
1270 +#define BLKGETSIZE _IO(0x12,96)        /* return device size /512 (long *arg) */
1271 +#define BLKFLSBUF  _IO(0x12,97)        /* flush buffer cache */
1272 +#define BLKRASET   _IO(0x12,98)        /* Set read ahead for block device */
1273 +#define BLKRAGET   _IO(0x12,99)        /* get current read ahead setting */
1274 +#define BLKFRASET  _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
1275 +#define BLKFRAGET  _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
1276 +#define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
1277 +#define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
1278 +#define BLKSSZGET  _IO(0x12,104)/* get block device sector size */
1279 +#if 0
1280 +#define BLKPG      _IO(0x12,105)/* See blkpg.h */
1281 +#define BLKELVGET  _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
1282 +#define BLKELVSET  _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
1283 +/* This was here just to show that the number is taken -
1284 +   probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
1285 +#endif
1286 +/* A jump here: 108-111 have been used for various private purposes. */
1287 +#define BLKBSZGET  _IOR(0x12,112,sizeof(int))
1288 +#define BLKBSZSET  _IOW(0x12,113,sizeof(int))
1289 +#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64))        /* return device size in bytes (u64 *arg) */
1290 +
1291 +#define BMAP_IOCTL 1           /* obsolete - kept for compatibility */
1292 +#define FIBMAP    _IO(0x00,1)  /* bmap access */
1293 +#define FIGETBSZ   _IO(0x00,2) /* get the block size used for bmap */
1294 +
1295 +#ifdef __KERNEL__
1296 +
1297 +#include <asm/semaphore.h>
1298 +#include <asm/byteorder.h>
1299 +
1300 +extern void update_atime (struct inode *);
1301 +extern void update_mctime (struct inode *);
1302 +#define UPDATE_ATIME(inode) update_atime (inode)
1303 +
1304 +extern void buffer_init(unsigned long);
1305 +extern void inode_init(unsigned long);
1306 +extern void mnt_init(unsigned long);
1307 +extern void files_init(unsigned long mempages);
1308 +
1309 +/* bh state bits */
1310 +enum bh_state_bits {
1311 +       BH_Uptodate,    /* 1 if the buffer contains valid data */
1312 +       BH_Dirty,       /* 1 if the buffer is dirty */
1313 +       BH_Lock,        /* 1 if the buffer is locked */
1314 +       BH_Req,         /* 0 if the buffer has been invalidated */
1315 +       BH_Mapped,      /* 1 if the buffer has a disk mapping */
1316 +       BH_New,         /* 1 if the buffer is new and not yet written out */
1317 +       BH_Async,       /* 1 if the buffer is under end_buffer_io_async I/O */
1318 +       BH_Wait_IO,     /* 1 if we should write out this buffer */
1319 +       BH_Launder,     /* 1 if we can throttle on this buffer */
1320 +       BH_Attached,    /* 1 if b_inode_buffers is linked into a list */
1321 +       BH_JBD,         /* 1 if it has an attached journal_head */
1322 +       BH_Sync,        /* 1 if the buffer is a sync read */
1323 +
1324 +       BH_PrivateStart,/* not a state bit, but the first bit available
1325 +                        * for private allocation by other entities
1326 +                        */
1327 +};
1328 +
1329 +#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
1330 +
1331 +/*
1332 + * Try to keep the most commonly used fields in single cache lines (16
1333 + * bytes) to improve performance.  This ordering should be
1334 + * particularly beneficial on 32-bit processors.
1335 + * 
1336 + * We use the first 16 bytes for the data which is used in searches
1337 + * over the block hash lists (ie. getblk() and friends).
1338 + * 
1339 + * The second 16 bytes we use for lru buffer scans, as used by
1340 + * sync_buffers() and refill_freelist().  -- sct
1341 + */
1342 +struct buffer_head {
1343 +       /* First cache line: */
1344 +       struct buffer_head *b_next;     /* Hash queue list */
1345 +       unsigned long b_blocknr;        /* block number */
1346 +       unsigned short b_size;          /* block size */
1347 +       unsigned short b_list;          /* List that this buffer appears */
1348 +       kdev_t b_dev;                   /* device (B_FREE = free) */
1349 +
1350 +       atomic_t b_count;               /* users using this block */
1351 +       kdev_t b_rdev;                  /* Real device */
1352 +       unsigned long b_state;          /* buffer state bitmap (see above) */
1353 +       unsigned long b_flushtime;      /* Time when (dirty) buffer should be written */
1354 +
1355 +       struct buffer_head *b_next_free;/* lru/free list linkage */
1356 +       struct buffer_head *b_prev_free;/* doubly linked list of buffers */
1357 +       struct buffer_head *b_this_page;/* circular list of buffers in one page */
1358 +       struct buffer_head *b_reqnext;  /* request queue */
1359 +
1360 +       struct buffer_head **b_pprev;   /* doubly linked list of hash-queue */
1361 +       char * b_data;                  /* pointer to data block */
1362 +       struct page *b_page;            /* the page this bh is mapped to */
1363 +       void (*b_end_io)(struct buffer_head *bh, int uptodate); /* I/O completion */
1364 +       void *b_private;                /* reserved for b_end_io */
1365 +
1366 +       unsigned long b_rsector;        /* Real buffer location on disk */
1367 +       wait_queue_head_t b_wait;
1368 +
1369 +       struct list_head     b_inode_buffers;   /* doubly linked list of inode dirty buffers */
1370 +};
1371 +
1372 +typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
1373 +void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
1374 +
1375 +#define __buffer_state(bh, state)      (((bh)->b_state & (1UL << BH_##state)) != 0)
1376 +
1377 +#define buffer_uptodate(bh)    __buffer_state(bh,Uptodate)
1378 +#define buffer_dirty(bh)       __buffer_state(bh,Dirty)
1379 +#define buffer_locked(bh)      __buffer_state(bh,Lock)
1380 +#define buffer_req(bh)         __buffer_state(bh,Req)
1381 +#define buffer_mapped(bh)      __buffer_state(bh,Mapped)
1382 +#define buffer_new(bh)         __buffer_state(bh,New)
1383 +#define buffer_async(bh)       __buffer_state(bh,Async)
1384 +#define buffer_launder(bh)     __buffer_state(bh,Launder)
1385 +
1386 +#define bh_offset(bh)          ((unsigned long)(bh)->b_data & ~PAGE_MASK)
1387 +
1388 +extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long offset);
1389 +
1390 +#define touch_buffer(bh)       mark_page_accessed(bh->b_page)
1391 +
1392 +
1393 +#include <linux/pipe_fs_i.h>
1394 +#include <linux/minix_fs_i.h>
1395 +#include <linux/ext2_fs_i.h>
1396 +#include <linux/ext3_fs_i.h>
1397 +#include <linux/hpfs_fs_i.h>
1398 +#include <linux/ntfs_fs_i.h>
1399 +#include <linux/msdos_fs_i.h>
1400 +#include <linux/umsdos_fs_i.h>
1401 +#include <linux/iso_fs_i.h>
1402 +#include <linux/nfs_fs_i.h>
1403 +#include <linux/sysv_fs_i.h>
1404 +#include <linux/affs_fs_i.h>
1405 +#include <linux/ufs_fs_i.h>
1406 +#include <linux/efs_fs_i.h>
1407 +#include <linux/coda_fs_i.h>
1408 +#include <linux/romfs_fs_i.h>
1409 +#include <linux/shmem_fs.h>
1410 +#include <linux/smb_fs_i.h>
1411 +#include <linux/hfs_fs_i.h>
1412 +#include <linux/adfs_fs_i.h>
1413 +#include <linux/qnx4_fs_i.h>
1414 +#include <linux/reiserfs_fs_i.h>
1415 +#include <linux/bfs_fs_i.h>
1416 +#include <linux/udf_fs_i.h>
1417 +#include <linux/ncp_fs_i.h>
1418 +#include <linux/proc_fs_i.h>
1419 +#include <linux/usbdev_fs_i.h>
1420 +#include <linux/jffs2_fs_i.h>
1421 +#include <linux/cramfs_fs_sb.h>
1422 +
1423 +/*
1424 + * Attribute flags.  These should be or-ed together to figure out what
1425 + * has been changed!
1426 + */
1427 +#define ATTR_MODE      1
1428 +#define ATTR_UID       2
1429 +#define ATTR_GID       4
1430 +#define ATTR_SIZE      8
1431 +#define ATTR_ATIME     16
1432 +#define ATTR_MTIME     32
1433 +#define ATTR_CTIME     64
1434 +#define ATTR_ATIME_SET 128
1435 +#define ATTR_MTIME_SET 256
1436 +#define ATTR_FORCE     512     /* Not a change, but a change it */
1437 +#define ATTR_ATTR_FLAG 1024
1438 +
1439 +/*
1440 + * This is the Inode Attributes structure, used for notify_change().  It
1441 + * uses the above definitions as flags, to know which values have changed.
1442 + * Also, in this manner, a Filesystem can look at only the values it cares
1443 + * about.  Basically, these are the attributes that the VFS layer can
1444 + * request to change from the FS layer.
1445 + *
1446 + * Derek Atkins <warlord@MIT.EDU> 94-10-20
1447 + */
1448 +struct iattr {
1449 +       unsigned int    ia_valid;
1450 +       umode_t         ia_mode;
1451 +       uid_t           ia_uid;
1452 +       gid_t           ia_gid;
1453 +       loff_t          ia_size;
1454 +       time_t          ia_atime;
1455 +       time_t          ia_mtime;
1456 +       time_t          ia_ctime;
1457 +       unsigned int    ia_attr_flags;
1458 +};
1459 +
1460 +/*
1461 + * This is the inode attributes flag definitions
1462 + */
1463 +#define ATTR_FLAG_SYNCRONOUS   1       /* Syncronous write */
1464 +#define ATTR_FLAG_NOATIME      2       /* Don't update atime */
1465 +#define ATTR_FLAG_APPEND       4       /* Append-only file */
1466 +#define ATTR_FLAG_IMMUTABLE    8       /* Immutable file */
1467 +#define ATTR_FLAG_NODIRATIME   16      /* Don't update atime for directory */
1468 +
1469 +/*
1470 + * Includes for diskquotas and mount structures.
1471 + */
1472 +#include <linux/quota.h>
1473 +#include <linux/mount.h>
1474 +
1475 +/*
1476 + * oh the beauties of C type declarations.
1477 + */
1478 +struct page;
1479 +struct address_space;
1480 +struct kiobuf;
1481 +
1482 +struct address_space_operations {
1483 +       int (*writepage)(struct page *);
1484 +       int (*readpage)(struct file *, struct page *);
1485 +       int (*sync_page)(struct page *);
1486 +       /*
1487 +        * ext3 requires that a successful prepare_write() call be followed
1488 +        * by a commit_write() call - they must be balanced
1489 +        */
1490 +       int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
1491 +       int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
1492 +       /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
1493 +       int (*bmap)(struct address_space *, long);
1494 +       int (*flushpage) (struct page *, unsigned long);
1495 +       int (*releasepage) (struct page *, int);
1496 +#define KERNEL_HAS_O_DIRECT /* this is for modules out of the kernel */
1497 +       int (*direct_IO)(int, struct inode *, struct kiobuf *, unsigned long, int);
1498 +#define KERNEL_HAS_DIRECT_FILEIO /* Unfortunate kludge due to lack of foresight */
1499 +       int (*direct_fileIO)(int, struct file *, struct kiobuf *, unsigned long, int);
1500 +       void (*removepage)(struct page *); /* called when page gets removed from the inode */
1501 +};
1502 +
1503 +struct address_space {
1504 +       struct list_head        clean_pages;    /* list of clean pages */
1505 +       struct list_head        dirty_pages;    /* list of dirty pages */
1506 +       struct list_head        locked_pages;   /* list of locked pages */
1507 +       unsigned long           nrpages;        /* number of total pages */
1508 +       struct address_space_operations *a_ops; /* methods */
1509 +       struct inode            *host;          /* owner: inode, block_device */
1510 +       struct vm_area_struct   *i_mmap;        /* list of private mappings */
1511 +       struct vm_area_struct   *i_mmap_shared; /* list of shared mappings */
1512 +       spinlock_t              i_shared_lock;  /* and spinlock protecting it */
1513 +       int                     gfp_mask;       /* how to allocate the pages */
1514 +};
1515 +
1516 +struct char_device {
1517 +       struct list_head        hash;
1518 +       atomic_t                count;
1519 +       dev_t                   dev;
1520 +       atomic_t                openers;
1521 +       struct semaphore        sem;
1522 +};
1523 +
1524 +struct block_device {
1525 +       struct list_head        bd_hash;
1526 +       atomic_t                bd_count;
1527 +       struct inode *          bd_inode;
1528 +       dev_t                   bd_dev;  /* not a kdev_t - it's a search key */
1529 +       int                     bd_openers;
1530 +       const struct block_device_operations *bd_op;
1531 +       struct semaphore        bd_sem; /* open/close mutex */
1532 +       struct list_head        bd_inodes;
1533 +};
1534 +
1535 +struct inode {
1536 +       struct list_head        i_hash;
1537 +       struct list_head        i_list;
1538 +       struct list_head        i_dentry;
1539 +       
1540 +       struct list_head        i_dirty_buffers;
1541 +       struct list_head        i_dirty_data_buffers;
1542 +
1543 +       unsigned long           i_ino;
1544 +       atomic_t                i_count;
1545 +       kdev_t                  i_dev;
1546 +       umode_t                 i_mode;
1547 +       nlink_t                 i_nlink;
1548 +       uid_t                   i_uid;
1549 +       gid_t                   i_gid;
1550 +       kdev_t                  i_rdev;
1551 +       loff_t                  i_size;
1552 +       time_t                  i_atime;
1553 +       time_t                  i_mtime;
1554 +       time_t                  i_ctime;
1555 +       unsigned int            i_blkbits;
1556 +       unsigned long           i_blksize;
1557 +       unsigned long           i_blocks;
1558 +       unsigned long           i_version;
1559 +       unsigned short          i_bytes;
1560 +       struct semaphore        i_sem;
1561 +       struct rw_semaphore     i_alloc_sem;
1562 +       struct semaphore        i_zombie;
1563 +       struct inode_operations *i_op;
1564 +       struct file_operations  *i_fop; /* former ->i_op->default_file_ops */
1565 +       struct super_block      *i_sb;
1566 +       wait_queue_head_t       i_wait;
1567 +       struct file_lock        *i_flock;
1568 +       struct address_space    *i_mapping;
1569 +       struct address_space    i_data;
1570 +       struct dquot            *i_dquot[MAXQUOTAS];
1571 +       /* These three should probably be a union */
1572 +       struct list_head        i_devices;
1573 +       struct pipe_inode_info  *i_pipe;
1574 +       struct block_device     *i_bdev;
1575 +       struct char_device      *i_cdev;
1576 +
1577 +       unsigned long           i_dnotify_mask; /* Directory notify events */
1578 +       struct dnotify_struct   *i_dnotify; /* for directory notifications */
1579 +
1580 +       unsigned long           i_state;
1581 +
1582 +       unsigned int            i_flags;
1583 +       unsigned char           i_sock;
1584 +
1585 +       atomic_t                i_writecount;
1586 +       unsigned int            i_attr_flags;
1587 +       __u32                   i_generation;
1588 +       union {
1589 +               struct minix_inode_info         minix_i;
1590 +               struct ext2_inode_info          ext2_i;
1591 +               struct ext3_inode_info          ext3_i;
1592 +               struct hpfs_inode_info          hpfs_i;
1593 +               struct ntfs_inode_info          ntfs_i;
1594 +               struct msdos_inode_info         msdos_i;
1595 +               struct umsdos_inode_info        umsdos_i;
1596 +               struct iso_inode_info           isofs_i;
1597 +               struct nfs_inode_info           nfs_i;
1598 +               struct sysv_inode_info          sysv_i;
1599 +               struct affs_inode_info          affs_i;
1600 +               struct ufs_inode_info           ufs_i;
1601 +               struct efs_inode_info           efs_i;
1602 +               struct romfs_inode_info         romfs_i;
1603 +               struct shmem_inode_info         shmem_i;
1604 +               struct coda_inode_info          coda_i;
1605 +               struct smb_inode_info           smbfs_i;
1606 +               struct hfs_inode_info           hfs_i;
1607 +               struct adfs_inode_info          adfs_i;
1608 +               struct qnx4_inode_info          qnx4_i;
1609 +               struct reiserfs_inode_info      reiserfs_i;
1610 +               struct bfs_inode_info           bfs_i;
1611 +               struct udf_inode_info           udf_i;
1612 +               struct ncp_inode_info           ncpfs_i;
1613 +               struct proc_inode_info          proc_i;
1614 +               struct socket                   socket_i;
1615 +               struct usbdev_inode_info        usbdev_i;
1616 +               struct jffs2_inode_info         jffs2_i;
1617 +               void                            *generic_ip;
1618 +       } u;
1619 +};
1620 +
1621 +static inline void inode_add_bytes(struct inode *inode, loff_t bytes)
1622 +{
1623 +       inode->i_blocks += bytes >> 9;
1624 +       bytes &= 511;
1625 +       inode->i_bytes += bytes;
1626 +       if (inode->i_bytes >= 512) {
1627 +               inode->i_blocks++;
1628 +               inode->i_bytes -= 512;
1629 +       }
1630 +}
1631 +
1632 +static inline void inode_sub_bytes(struct inode *inode, loff_t bytes)
1633 +{
1634 +       inode->i_blocks -= bytes >> 9;
1635 +       bytes &= 511;
1636 +       if (inode->i_bytes < bytes) {
1637 +               inode->i_blocks--;
1638 +               inode->i_bytes += 512;
1639 +       }
1640 +       inode->i_bytes -= bytes;
1641 +}
1642 +
1643 +static inline loff_t inode_get_bytes(struct inode *inode)
1644 +{
1645 +       return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
1646 +}
1647 +
1648 +static inline void inode_set_bytes(struct inode *inode, loff_t bytes)
1649 +{
1650 +       inode->i_blocks = bytes >> 9;
1651 +       inode->i_bytes = bytes & 511;
1652 +}
1653 +
1654 +struct fown_struct {
1655 +       int pid;                /* pid or -pgrp where SIGIO should be sent */
1656 +       uid_t uid, euid;        /* uid/euid of process setting the owner */
1657 +       int signum;             /* posix.1b rt signal to be delivered on IO */
1658 +};
1659 +
1660 +struct file {
1661 +       struct list_head        f_list;
1662 +       struct dentry           *f_dentry;
1663 +       struct vfsmount         *f_vfsmnt;
1664 +       struct file_operations  *f_op;
1665 +       atomic_t                f_count;
1666 +       unsigned int            f_flags;
1667 +       mode_t                  f_mode;
1668 +       loff_t                  f_pos;
1669 +       unsigned long           f_reada, f_ramax, f_raend, f_ralen, f_rawin;
1670 +       struct fown_struct      f_owner;
1671 +       unsigned int            f_uid, f_gid;
1672 +       int                     f_error;
1673 +
1674 +       unsigned long           f_version;
1675 +
1676 +       /* needed for tty driver, and maybe others */
1677 +       void                    *private_data;
1678 +
1679 +       /* preallocated helper kiobuf to speedup O_DIRECT */
1680 +       struct kiobuf           *f_iobuf;
1681 +       long                    f_iobuf_lock;
1682 +};
1683 +extern spinlock_t files_lock;
1684 +#define file_list_lock() spin_lock(&files_lock);
1685 +#define file_list_unlock() spin_unlock(&files_lock);
1686 +
1687 +#define get_file(x)    atomic_inc(&(x)->f_count)
1688 +#define file_count(x)  atomic_read(&(x)->f_count)
1689 +
1690 +extern int init_private_file(struct file *, struct dentry *, int);
1691 +
1692 +#define        MAX_NON_LFS     ((1UL<<31) - 1)
1693 +
1694 +/* Page cache limit. The filesystems should put that into their s_maxbytes 
1695 +   limits, otherwise bad things can happen in VM. */ 
1696 +#if BITS_PER_LONG==32
1697 +#define MAX_LFS_FILESIZE       (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 
1698 +#elif BITS_PER_LONG==64
1699 +#define MAX_LFS_FILESIZE       0x7fffffffffffffff
1700 +#endif
1701 +
1702 +#define FL_POSIX       1
1703 +#define FL_FLOCK       2
1704 +#define FL_BROKEN      4       /* broken flock() emulation */
1705 +#define FL_ACCESS      8       /* for processes suspended by mandatory locking */
1706 +#define FL_LOCKD       16      /* lock held by rpc.lockd */
1707 +#define FL_LEASE       32      /* lease held on this file */
1708 +
1709 +/*
1710 + * The POSIX file lock owner is determined by
1711 + * the "struct files_struct" in the thread group
1712 + * (or NULL for no owner - BSD locks).
1713 + *
1714 + * Lockd stuffs a "host" pointer into this.
1715 + */
1716 +typedef struct files_struct *fl_owner_t;
1717 +
1718 +struct file_lock {
1719 +       struct file_lock *fl_next;      /* singly linked list for this inode  */
1720 +       struct list_head fl_link;       /* doubly linked list of all locks */
1721 +       struct list_head fl_block;      /* circular list of blocked processes */
1722 +       fl_owner_t fl_owner;
1723 +       unsigned int fl_pid;
1724 +       wait_queue_head_t fl_wait;
1725 +       struct file *fl_file;
1726 +       unsigned char fl_flags;
1727 +       unsigned char fl_type;
1728 +       loff_t fl_start;
1729 +       loff_t fl_end;
1730 +
1731 +       void (*fl_notify)(struct file_lock *);  /* unblock callback */
1732 +       void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
1733 +       void (*fl_remove)(struct file_lock *);  /* lock removal callback */
1734 +
1735 +       struct fasync_struct *  fl_fasync; /* for lease break notifications */
1736 +       unsigned long fl_break_time;    /* for nonblocking lease breaks */
1737 +
1738 +       union {
1739 +               struct nfs_lock_info    nfs_fl;
1740 +       } fl_u;
1741 +};
1742 +
1743 +/* The following constant reflects the upper bound of the file/locking space */
1744 +#ifndef OFFSET_MAX
1745 +#define INT_LIMIT(x)   (~((x)1 << (sizeof(x)*8 - 1)))
1746 +#define OFFSET_MAX     INT_LIMIT(loff_t)
1747 +#define OFFT_OFFSET_MAX        INT_LIMIT(off_t)
1748 +#endif
1749 +
1750 +extern struct list_head file_lock_list;
1751 +
1752 +#include <linux/fcntl.h>
1753 +
1754 +extern int fcntl_getlk(unsigned int, struct flock *);
1755 +extern int fcntl_setlk(unsigned int, unsigned int, struct flock *);
1756 +
1757 +extern int fcntl_getlk64(unsigned int, struct flock64 *);
1758 +extern int fcntl_setlk64(unsigned int, unsigned int, struct flock64 *);
1759 +
1760 +/* fs/locks.c */
1761 +extern void locks_init_lock(struct file_lock *);
1762 +extern void locks_copy_lock(struct file_lock *, struct file_lock *);
1763 +extern void locks_remove_posix(struct file *, fl_owner_t);
1764 +extern void locks_remove_flock(struct file *);
1765 +extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
1766 +extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
1767 +extern void posix_block_lock(struct file_lock *, struct file_lock *);
1768 +extern void posix_unblock_lock(struct file_lock *);
1769 +extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);
1770 +extern int __get_lease(struct inode *inode, unsigned int flags);
1771 +extern time_t lease_get_mtime(struct inode *);
1772 +extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
1773 +extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
1774 +extern void steal_locks(fl_owner_t from);
1775 +
1776 +struct fasync_struct {
1777 +       int     magic;
1778 +       int     fa_fd;
1779 +       struct  fasync_struct   *fa_next; /* singly linked list */
1780 +       struct  file            *fa_file;
1781 +};
1782 +
1783 +#define FASYNC_MAGIC 0x4601
1784 +
1785 +/* SMP safe fasync helpers: */
1786 +extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
1787 +/* can be called from interrupts */
1788 +extern void kill_fasync(struct fasync_struct **, int, int);
1789 +/* only for net: no internal synchronization */
1790 +extern void __kill_fasync(struct fasync_struct *, int, int);
1791 +
1792 +struct nameidata {
1793 +       struct dentry *dentry;
1794 +       struct vfsmount *mnt;
1795 +       struct qstr last;
1796 +       unsigned int flags;
1797 +       int last_type;
1798 +};
1799 +
1800 +/*
1801 + *     Umount options
1802 + */
1803 +
1804 +#define MNT_FORCE      0x00000001      /* Attempt to forcibily umount */
1805 +#define MNT_DETACH     0x00000002      /* Just detach from the tree */
1806 +
1807 +#include <linux/minix_fs_sb.h>
1808 +#include <linux/ext2_fs_sb.h>
1809 +#include <linux/ext3_fs_sb.h>
1810 +#include <linux/hpfs_fs_sb.h>
1811 +#include <linux/ntfs_fs_sb.h>
1812 +#include <linux/msdos_fs_sb.h>
1813 +#include <linux/iso_fs_sb.h>
1814 +#include <linux/nfs_fs_sb.h>
1815 +#include <linux/sysv_fs_sb.h>
1816 +#include <linux/affs_fs_sb.h>
1817 +#include <linux/ufs_fs_sb.h>
1818 +#include <linux/efs_fs_sb.h>
1819 +#include <linux/romfs_fs_sb.h>
1820 +#include <linux/smb_fs_sb.h>
1821 +#include <linux/hfs_fs_sb.h>
1822 +#include <linux/adfs_fs_sb.h>
1823 +#include <linux/qnx4_fs_sb.h>
1824 +#include <linux/reiserfs_fs_sb.h>
1825 +#include <linux/bfs_fs_sb.h>
1826 +#include <linux/udf_fs_sb.h>
1827 +#include <linux/ncp_fs_sb.h>
1828 +#include <linux/usbdev_fs_sb.h>
1829 +#include <linux/cramfs_fs_sb.h>
1830 +#include <linux/jffs2_fs_sb.h>
1831 +
1832 +extern struct list_head super_blocks;
1833 +extern spinlock_t sb_lock;
1834 +
1835 +#define sb_entry(list) list_entry((list), struct super_block, s_list)
1836 +#define S_BIAS (1<<30)
1837 +struct super_block {
1838 +       struct list_head        s_list;         /* Keep this first */
1839 +       kdev_t                  s_dev;
1840 +       unsigned long           s_blocksize;
1841 +       unsigned char           s_blocksize_bits;
1842 +       unsigned char           s_dirt;
1843 +       unsigned long long      s_maxbytes;     /* Max file size */
1844 +       struct file_system_type *s_type;
1845 +       struct super_operations *s_op;
1846 +       struct dquot_operations *dq_op;
1847 +       struct quotactl_ops     *s_qcop;
1848 +       unsigned long           s_flags;
1849 +       unsigned long           s_magic;
1850 +       struct dentry           *s_root;
1851 +       struct rw_semaphore     s_umount;
1852 +       struct semaphore        s_lock;
1853 +       int                     s_count;
1854 +       atomic_t                s_active;
1855 +
1856 +       struct list_head        s_dirty;        /* dirty inodes */
1857 +       struct list_head        s_locked_inodes;/* inodes being synced */
1858 +       struct list_head        s_files;
1859 +
1860 +       struct block_device     *s_bdev;
1861 +       struct list_head        s_instances;
1862 +       struct quota_info       s_dquot;        /* Diskquota specific options */
1863 +
1864 +       union {
1865 +               struct minix_sb_info    minix_sb;
1866 +               struct ext2_sb_info     ext2_sb;
1867 +               struct ext3_sb_info     ext3_sb;
1868 +               struct hpfs_sb_info     hpfs_sb;
1869 +               struct ntfs_sb_info     ntfs_sb;
1870 +               struct msdos_sb_info    msdos_sb;
1871 +               struct isofs_sb_info    isofs_sb;
1872 +               struct nfs_sb_info      nfs_sb;
1873 +               struct sysv_sb_info     sysv_sb;
1874 +               struct affs_sb_info     affs_sb;
1875 +               struct ufs_sb_info      ufs_sb;
1876 +               struct efs_sb_info      efs_sb;
1877 +               struct shmem_sb_info    shmem_sb;
1878 +               struct romfs_sb_info    romfs_sb;
1879 +               struct smb_sb_info      smbfs_sb;
1880 +               struct hfs_sb_info      hfs_sb;
1881 +               struct adfs_sb_info     adfs_sb;
1882 +               struct qnx4_sb_info     qnx4_sb;
1883 +               struct reiserfs_sb_info reiserfs_sb;
1884 +               struct bfs_sb_info      bfs_sb;
1885 +               struct udf_sb_info      udf_sb;
1886 +               struct ncp_sb_info      ncpfs_sb;
1887 +               struct usbdev_sb_info   usbdevfs_sb;
1888 +               struct jffs2_sb_info    jffs2_sb;
1889 +               struct cramfs_sb_info   cramfs_sb;
1890 +               void                    *generic_sbp;
1891 +       } u;
1892 +       /*
1893 +        * The next field is for VFS *only*. No filesystems have any business
1894 +        * even looking at it. You had been warned.
1895 +        */
1896 +       struct semaphore s_vfs_rename_sem;      /* Kludge */
1897 +
1898 +       /* The next field is used by knfsd when converting a (inode number based)
1899 +        * file handle into a dentry. As it builds a path in the dcache tree from
1900 +        * the bottom up, there may for a time be a subpath of dentrys which is not
1901 +        * connected to the main tree.  This semaphore ensure that there is only ever
1902 +        * one such free path per filesystem.  Note that unconnected files (or other
1903 +        * non-directories) are allowed, but not unconnected diretories.
1904 +        */
1905 +       struct semaphore s_nfsd_free_path_sem;
1906 +};
1907 +
1908 +/*
1909 + * VFS helper functions..
1910 + */
1911 +extern int vfs_create(struct inode *, struct dentry *, int);
1912 +extern int vfs_mkdir(struct inode *, struct dentry *, int);
1913 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
1914 +extern int vfs_symlink(struct inode *, struct dentry *, const char *);
1915 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1916 +extern int vfs_rmdir(struct inode *, struct dentry *);
1917 +extern int vfs_unlink(struct inode *, struct dentry *);
1918 +extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1919 +
1920 +/*
1921 + * File types
1922 + */
1923 +#define DT_UNKNOWN     0
1924 +#define DT_FIFO                1
1925 +#define DT_CHR         2
1926 +#define DT_DIR         4
1927 +#define DT_BLK         6
1928 +#define DT_REG         8
1929 +#define DT_LNK         10
1930 +#define DT_SOCK                12
1931 +#define DT_WHT         14
1932 +
1933 +/*
1934 + * This is the "filldir" function type, used by readdir() to let
1935 + * the kernel specify what kind of dirent layout it wants to have.
1936 + * This allows the kernel to read directories into kernel space or
1937 + * to have different dirent layouts depending on the binary type.
1938 + */
1939 +typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
1940 +
1941 +struct block_device_operations {
1942 +       int (*open) (struct inode *, struct file *);
1943 +       int (*release) (struct inode *, struct file *);
1944 +       int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
1945 +       int (*check_media_change) (kdev_t);
1946 +       int (*revalidate) (kdev_t);
1947 +       struct module *owner;
1948 +};
1949 +
1950 +/*
1951 + * NOTE:
1952 + * read, write, poll, fsync, readv, writev can be called
1953 + *   without the big kernel lock held in all filesystems.
1954 + */
1955 +struct file_operations {
1956 +       struct module *owner;
1957 +       loff_t (*llseek) (struct file *, loff_t, int);
1958 +       ssize_t (*read) (struct file *, char *, size_t, loff_t *);
1959 +       ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
1960 +       int (*readdir) (struct file *, void *, filldir_t);
1961 +       unsigned int (*poll) (struct file *, struct poll_table_struct *);
1962 +       int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
1963 +       int (*mmap) (struct file *, struct vm_area_struct *);
1964 +       int (*open) (struct inode *, struct file *);
1965 +       int (*flush) (struct file *);
1966 +       int (*release) (struct inode *, struct file *);
1967 +       int (*fsync) (struct file *, struct dentry *, int datasync);
1968 +       int (*fasync) (int, struct file *, int);
1969 +       int (*lock) (struct file *, int, struct file_lock *);
1970 +       ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
1971 +       ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
1972 +       ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
1973 +       unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
1974 +};
1975 +
1976 +struct inode_operations {
1977 +       int (*create) (struct inode *,struct dentry *,int);
1978 +       struct dentry * (*lookup) (struct inode *,struct dentry *);
1979 +       int (*link) (struct dentry *,struct inode *,struct dentry *);
1980 +       int (*unlink) (struct inode *,struct dentry *);
1981 +       int (*symlink) (struct inode *,struct dentry *,const char *);
1982 +       int (*mkdir) (struct inode *,struct dentry *,int);
1983 +       int (*rmdir) (struct inode *,struct dentry *);
1984 +       int (*mknod) (struct inode *,struct dentry *,int,int);
1985 +       int (*rename) (struct inode *, struct dentry *,
1986 +                       struct inode *, struct dentry *);
1987 +       int (*readlink) (struct dentry *, char *,int);
1988 +       int (*follow_link) (struct dentry *, struct nameidata *);
1989 +       void (*truncate) (struct inode *);
1990 +       int (*permission) (struct inode *, int);
1991 +       int (*revalidate) (struct dentry *);
1992 +       int (*setattr) (struct dentry *, struct iattr *);
1993 +       int (*getattr) (struct dentry *, struct iattr *);
1994 +       int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1995 +       ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1996 +       ssize_t (*listxattr) (struct dentry *, char *, size_t);
1997 +       int (*removexattr) (struct dentry *, const char *);
1998 +};
1999 +
2000 +struct seq_file;
2001 +
2002 +/*
2003 + * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
2004 + * without the big kernel lock held in all filesystems.
2005 + */
2006 +struct super_operations {
2007 +       struct inode *(*alloc_inode)(struct super_block *sb);
2008 +       void (*destroy_inode)(struct inode *);
2009 +
2010 +       void (*read_inode) (struct inode *);
2011 +  
2012 +       /* reiserfs kludge.  reiserfs needs 64 bits of information to
2013 +       ** find an inode.  We are using the read_inode2 call to get
2014 +       ** that information.  We don't like this, and are waiting on some
2015 +       ** VFS changes for the real solution.
2016 +       ** iget4 calls read_inode2, iff it is defined
2017 +       */
2018 +       void (*read_inode2) (struct inode *, void *) ;
2019 +       void (*dirty_inode) (struct inode *);
2020 +       void (*write_inode) (struct inode *, int);
2021 +       void (*put_inode) (struct inode *);
2022 +       void (*delete_inode) (struct inode *);
2023 +       void (*put_super) (struct super_block *);
2024 +       void (*write_super) (struct super_block *);
2025 +       int (*sync_fs) (struct super_block *);
2026 +       void (*write_super_lockfs) (struct super_block *);
2027 +       void (*unlockfs) (struct super_block *);
2028 +       int (*statfs) (struct super_block *, struct statfs *);
2029 +       int (*remount_fs) (struct super_block *, int *, char *);
2030 +       void (*clear_inode) (struct inode *);
2031 +       void (*umount_begin) (struct super_block *);
2032 +
2033 +       /* Following are for knfsd to interact with "interesting" filesystems
2034 +        * Currently just reiserfs, but possibly FAT and others later
2035 +        *
2036 +        * fh_to_dentry is given a filehandle fragement with length, and a type flag
2037 +        *   and must return a dentry for the referenced object or, if "parent" is
2038 +        *   set, a dentry for the parent of the object.
2039 +        *   If a dentry cannot be found, a "root" dentry should be created and
2040 +        *   flaged as DCACHE_NFSD_DISCONNECTED. nfsd_iget is an example implementation.
2041 +        *
2042 +        * dentry_to_fh is given a dentry and must generate the filesys specific
2043 +        *   part of the file handle.  Available length is passed in *lenp and used
2044 +        *   length should be returned therein.
2045 +        *   If need_parent is set, then dentry_to_fh should encode sufficient information
2046 +        *   to find the (current) parent.
2047 +        *   dentry_to_fh should return a 1byte "type" which will be passed back in
2048 +        *   the fhtype arguement to fh_to_dentry.  Type of 0 is reserved.
2049 +        *   If filesystem was exportable before the introduction of fh_to_dentry,
2050 +        *   types 1 and 2 should be used is that same way as the generic code.
2051 +        *   Type 255 means error.
2052 +        *
2053 +        * Lengths are in units of 4bytes, not bytes.
2054 +        */
2055 +       struct dentry * (*fh_to_dentry)(struct super_block *sb, __u32 *fh, int len, int fhtype, int parent);
2056 +       int (*dentry_to_fh)(struct dentry *, __u32 *fh, int *lenp, int need_parent);
2057 +       int (*show_options)(struct seq_file *, struct vfsmount *);
2058 +};
2059 +
2060 +/* Inode state bits.. */
2061 +#define I_DIRTY_SYNC           1 /* Not dirty enough for O_DATASYNC */
2062 +#define I_DIRTY_DATASYNC       2 /* Data-related inode changes pending */
2063 +#define I_DIRTY_PAGES          4 /* Data-related inode changes pending */
2064 +#define I_LOCK                 8
2065 +#define I_FREEING              16
2066 +#define I_CLEAR                        32
2067 +
2068 +#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
2069 +
2070 +extern void __mark_inode_dirty(struct inode *, int);
2071 +static inline void mark_inode_dirty(struct inode *inode)
2072 +{
2073 +       __mark_inode_dirty(inode, I_DIRTY);
2074 +}
2075 +
2076 +static inline void mark_inode_dirty_sync(struct inode *inode)
2077 +{
2078 +       __mark_inode_dirty(inode, I_DIRTY_SYNC);
2079 +}
2080 +
2081 +static inline void mark_inode_dirty_pages(struct inode *inode)
2082 +{
2083 +       __mark_inode_dirty(inode, I_DIRTY_PAGES);
2084 +}
2085 +
2086 +struct file_system_type {
2087 +       const char *name;
2088 +       int fs_flags;
2089 +       struct super_block *(*read_super) (struct super_block *, void *, int);
2090 +       struct module *owner;
2091 +       struct file_system_type * next;
2092 +       struct list_head fs_supers;
2093 +};
2094 +
2095 +#define DECLARE_FSTYPE(var,type,read,flags) \
2096 +struct file_system_type var = { \
2097 +       name:           type, \
2098 +       read_super:     read, \
2099 +       fs_flags:       flags, \
2100 +       owner:          THIS_MODULE, \
2101 +}
2102 +
2103 +#define DECLARE_FSTYPE_DEV(var,type,read) \
2104 +       DECLARE_FSTYPE(var,type,read,FS_REQUIRES_DEV)
2105 +
2106 +/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
2107 +#define fops_get(fops) \
2108 +       (((fops) && (fops)->owner)      \
2109 +               ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
2110 +               : (fops))
2111 +
2112 +#define fops_put(fops) \
2113 +do {   \
2114 +       if ((fops) && (fops)->owner) \
2115 +               __MOD_DEC_USE_COUNT((fops)->owner);     \
2116 +} while(0)
2117 +
2118 +extern int register_filesystem(struct file_system_type *);
2119 +extern int unregister_filesystem(struct file_system_type *);
2120 +extern struct vfsmount *kern_mount(struct file_system_type *);
2121 +extern int may_umount(struct vfsmount *);
2122 +extern long do_mount(char *, char *, char *, unsigned long, void *);
2123 +
2124 +#define kern_umount mntput
2125 +
2126 +extern int vfs_statfs(struct super_block *, struct statfs *);
2127 +
2128 +/* Return value for VFS lock functions - tells locks.c to lock conventionally
2129 + * REALLY kosha for root NFS and nfs_lock
2130 + */ 
2131 +#define LOCK_USE_CLNT 1
2132 +
2133 +#define FLOCK_VERIFY_READ  1
2134 +#define FLOCK_VERIFY_WRITE 2
2135 +
2136 +extern int locks_mandatory_locked(struct inode *);
2137 +extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
2138 +
2139 +/*
2140 + * Candidates for mandatory locking have the setgid bit set
2141 + * but no group execute bit -  an otherwise meaningless combination.
2142 + */
2143 +#define MANDATORY_LOCK(inode) \
2144 +       (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
2145 +
2146 +static inline int locks_verify_locked(struct inode *inode)
2147 +{
2148 +       if (MANDATORY_LOCK(inode))
2149 +               return locks_mandatory_locked(inode);
2150 +       return 0;
2151 +}
2152 +
2153 +static inline int locks_verify_area(int read_write, struct inode *inode,
2154 +                                   struct file *filp, loff_t offset,
2155 +                                   size_t count)
2156 +{
2157 +       if (inode->i_flock && MANDATORY_LOCK(inode))
2158 +               return locks_mandatory_area(read_write, inode, filp, offset, count);
2159 +       return 0;
2160 +}
2161 +
2162 +static inline int locks_verify_truncate(struct inode *inode,
2163 +                                   struct file *filp,
2164 +                                   loff_t size)
2165 +{
2166 +       if (inode->i_flock && MANDATORY_LOCK(inode))
2167 +               return locks_mandatory_area(
2168 +                       FLOCK_VERIFY_WRITE, inode, filp,
2169 +                       size < inode->i_size ? size : inode->i_size,
2170 +                       (size < inode->i_size ? inode->i_size - size
2171 +                        : size - inode->i_size)
2172 +               );
2173 +       return 0;
2174 +}
2175 +
2176 +static inline int get_lease(struct inode *inode, unsigned int mode)
2177 +{
2178 +       if (inode->i_flock)
2179 +               return __get_lease(inode, mode);
2180 +       return 0;
2181 +}
2182 +
2183 +/* fs/open.c */
2184 +
2185 +asmlinkage long sys_open(const char *, int, int);
2186 +asmlinkage long sys_close(unsigned int);       /* yes, it's really unsigned */
2187 +extern int do_truncate(struct dentry *, loff_t start);
2188 +
2189 +extern struct file *filp_open(const char *, int, int);
2190 +extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
2191 +extern int filp_close(struct file *, fl_owner_t id);
2192 +extern char * getname(const char *);
2193 +
2194 +/* fs/dcache.c */
2195 +extern void vfs_caches_init(unsigned long);
2196 +
2197 +#define __getname()    kmem_cache_alloc(names_cachep, SLAB_KERNEL)
2198 +#define putname(name)  kmem_cache_free(names_cachep, (void *)(name))
2199 +
2200 +enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};
2201 +extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);
2202 +extern int unregister_blkdev(unsigned int, const char *);
2203 +extern struct block_device *bdget(dev_t);
2204 +extern int bd_acquire(struct inode *inode);
2205 +extern void bd_forget(struct inode *inode);
2206 +extern void bdput(struct block_device *);
2207 +extern struct char_device *cdget(dev_t);
2208 +extern void cdput(struct char_device *);
2209 +extern int blkdev_open(struct inode *, struct file *);
2210 +extern int blkdev_close(struct inode *, struct file *);
2211 +extern struct file_operations def_blk_fops;
2212 +extern struct address_space_operations def_blk_aops;
2213 +extern struct file_operations def_fifo_fops;
2214 +extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
2215 +extern int blkdev_get(struct block_device *, mode_t, unsigned, int);
2216 +extern int blkdev_put(struct block_device *, int);
2217 +
2218 +/* fs/devices.c */
2219 +extern const struct block_device_operations *get_blkfops(unsigned int);
2220 +extern int register_chrdev(unsigned int, const char *, struct file_operations *);
2221 +extern int unregister_chrdev(unsigned int, const char *);
2222 +extern int chrdev_open(struct inode *, struct file *);
2223 +extern const char * bdevname(kdev_t);
2224 +extern const char * cdevname(kdev_t);
2225 +extern const char * kdevname(kdev_t);
2226 +extern void init_special_inode(struct inode *, umode_t, int);
2227 +
2228 +/* Invalid inode operations -- fs/bad_inode.c */
2229 +extern void make_bad_inode(struct inode *);
2230 +extern int is_bad_inode(struct inode *);
2231 +
2232 +extern struct file_operations read_fifo_fops;
2233 +extern struct file_operations write_fifo_fops;
2234 +extern struct file_operations rdwr_fifo_fops;
2235 +extern struct file_operations read_pipe_fops;
2236 +extern struct file_operations write_pipe_fops;
2237 +extern struct file_operations rdwr_pipe_fops;
2238 +
2239 +extern int fs_may_remount_ro(struct super_block *);
2240 +
2241 +extern int FASTCALL(try_to_free_buffers(struct page *, unsigned int));
2242 +extern void refile_buffer(struct buffer_head * buf);
2243 +extern void create_empty_buffers(struct page *, kdev_t, unsigned long);
2244 +extern void end_buffer_io_sync(struct buffer_head *bh, int uptodate);
2245 +
2246 +/* reiserfs_writepage needs this */
2247 +extern void set_buffer_async_io(struct buffer_head *bh) ;
2248 +
2249 +#define BUF_CLEAN      0
2250 +#define BUF_LOCKED     1       /* Buffers scheduled for write */
2251 +#define BUF_DIRTY      2       /* Dirty buffers, not yet scheduled for write */
2252 +#define NR_LIST                3
2253 +
2254 +static inline void get_bh(struct buffer_head * bh)
2255 +{
2256 +        atomic_inc(&(bh)->b_count);
2257 +}
2258 +
2259 +static inline void put_bh(struct buffer_head *bh)
2260 +{
2261 +        smp_mb__before_atomic_dec();
2262 +        atomic_dec(&bh->b_count);
2263 +}
2264 +
2265 +/*
2266 + * This is called by bh->b_end_io() handlers when I/O has completed.
2267 + */
2268 +static inline void mark_buffer_uptodate(struct buffer_head * bh, int on)
2269 +{
2270 +       if (on)
2271 +               set_bit(BH_Uptodate, &bh->b_state);
2272 +       else
2273 +               clear_bit(BH_Uptodate, &bh->b_state);
2274 +}
2275 +
2276 +#define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)
2277 +
2278 +static inline void __mark_buffer_clean(struct buffer_head *bh)
2279 +{
2280 +       refile_buffer(bh);
2281 +}
2282 +
2283 +static inline void mark_buffer_clean(struct buffer_head * bh)
2284 +{
2285 +       if (atomic_set_buffer_clean(bh))
2286 +               __mark_buffer_clean(bh);
2287 +}
2288 +
2289 +extern void FASTCALL(__mark_dirty(struct buffer_head *bh));
2290 +extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh));
2291 +extern void FASTCALL(mark_buffer_dirty(struct buffer_head *bh));
2292 +
2293 +extern void FASTCALL(buffer_insert_list(struct buffer_head *, struct list_head *));
2294 +
2295 +static inline void buffer_insert_inode_queue(struct buffer_head *bh, struct inode *inode)
2296 +{
2297 +       buffer_insert_list(bh, &inode->i_dirty_buffers);
2298 +}
2299 +
2300 +static inline void buffer_insert_inode_data_queue(struct buffer_head *bh, struct inode *inode)
2301 +{
2302 +       buffer_insert_list(bh, &inode->i_dirty_data_buffers);
2303 +}
2304 +
2305 +static inline int atomic_set_buffer_dirty(struct buffer_head *bh)
2306 +{
2307 +       return test_and_set_bit(BH_Dirty, &bh->b_state);
2308 +}
2309 +
2310 +static inline void mark_buffer_async(struct buffer_head * bh, int on)
2311 +{
2312 +       if (on)
2313 +               set_bit(BH_Async, &bh->b_state);
2314 +       else
2315 +               clear_bit(BH_Async, &bh->b_state);
2316 +}
2317 +
2318 +static inline void set_buffer_attached(struct buffer_head *bh)
2319 +{
2320 +       set_bit(BH_Attached, &bh->b_state);
2321 +}
2322 +
2323 +static inline void clear_buffer_attached(struct buffer_head *bh)
2324 +{
2325 +       clear_bit(BH_Attached, &bh->b_state);
2326 +}
2327 +
2328 +static inline int buffer_attached(struct buffer_head *bh)
2329 +{
2330 +       return test_bit(BH_Attached, &bh->b_state);
2331 +}
2332 +
2333 +/*
2334 + * If an error happens during the make_request, this function
2335 + * has to be recalled. It marks the buffer as clean and not
2336 + * uptodate, and it notifys the upper layer about the end
2337 + * of the I/O.
2338 + */
2339 +static inline void buffer_IO_error(struct buffer_head * bh)
2340 +{
2341 +       mark_buffer_clean(bh);
2342 +       /*
2343 +        * b_end_io has to clear the BH_Uptodate bitflag in the error case!
2344 +        */
2345 +       bh->b_end_io(bh, 0);
2346 +}
2347 +
2348 +static inline void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
2349 +{
2350 +       mark_buffer_dirty(bh);
2351 +       buffer_insert_inode_queue(bh, inode);
2352 +}
2353 +
2354 +extern void set_buffer_flushtime(struct buffer_head *);
2355 +extern void balance_dirty(void);
2356 +extern int check_disk_change(kdev_t);
2357 +extern int invalidate_inodes(struct super_block *);
2358 +extern int invalidate_device(kdev_t, int);
2359 +extern void invalidate_inode_pages(struct inode *);
2360 +extern void invalidate_inode_pages2(struct address_space *);
2361 +extern void invalidate_inode_buffers(struct inode *);
2362 +#define invalidate_buffers(dev)        __invalidate_buffers((dev), 0)
2363 +#define destroy_buffers(dev)   __invalidate_buffers((dev), 1)
2364 +extern void invalidate_bdev(struct block_device *, int);
2365 +extern void __invalidate_buffers(kdev_t dev, int);
2366 +extern void sync_inodes(kdev_t);
2367 +extern void sync_unlocked_inodes(void);
2368 +extern void write_inode_now(struct inode *, int);
2369 +extern int sync_buffers(kdev_t, int);
2370 +extern void sync_dev(kdev_t);
2371 +extern int fsync_dev(kdev_t);
2372 +extern int fsync_super(struct super_block *);
2373 +extern int fsync_no_super(kdev_t);
2374 +extern void sync_inodes_sb(struct super_block *);
2375 +extern int fsync_buffers_list(struct list_head *);
2376 +static inline int fsync_inode_buffers(struct inode *inode)
2377 +{
2378 +       return fsync_buffers_list(&inode->i_dirty_buffers);
2379 +}
2380 +static inline int fsync_inode_data_buffers(struct inode *inode)
2381 +{
2382 +       return fsync_buffers_list(&inode->i_dirty_data_buffers);
2383 +}
2384 +extern int inode_has_buffers(struct inode *);
2385 +extern int do_fdatasync(struct file *);
2386 +extern int filemap_fdatasync(struct address_space *);
2387 +extern int filemap_fdatawait(struct address_space *);
2388 +extern void sync_supers(kdev_t dev, int wait);
2389 +extern int bmap(struct inode *, int);
2390 +extern int notify_change(struct dentry *, struct iattr *);
2391 +extern int permission(struct inode *, int);
2392 +extern int vfs_permission(struct inode *, int);
2393 +extern int get_write_access(struct inode *);
2394 +extern int deny_write_access(struct file *);
2395 +static inline void put_write_access(struct inode * inode)
2396 +{
2397 +       atomic_dec(&inode->i_writecount);
2398 +}
2399 +static inline void allow_write_access(struct file *file)
2400 +{
2401 +       if (file)
2402 +               atomic_inc(&file->f_dentry->d_inode->i_writecount);
2403 +}
2404 +extern int do_pipe(int *);
2405 +
2406 +extern int open_namei(const char *, int, int, struct nameidata *);
2407 +
2408 +extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
2409 +extern struct file * open_exec(const char *);
2410
2411 +/* fs/dcache.c -- generic fs support functions */
2412 +extern int is_subdir(struct dentry *, struct dentry *);
2413 +extern ino_t find_inode_number(struct dentry *, struct qstr *);
2414 +
2415 +/*
2416 + * Kernel pointers have redundant information, so we can use a
2417 + * scheme where we can return either an error code or a dentry
2418 + * pointer with the same return value.
2419 + *
2420 + * This should be a per-architecture thing, to allow different
2421 + * error and pointer decisions.
2422 + */
2423 +static inline void *ERR_PTR(long error)
2424 +{
2425 +       return (void *) error;
2426 +}
2427 +
2428 +static inline long PTR_ERR(const void *ptr)
2429 +{
2430 +       return (long) ptr;
2431 +}
2432 +
2433 +static inline long IS_ERR(const void *ptr)
2434 +{
2435 +       return (unsigned long)ptr > (unsigned long)-1000L;
2436 +}
2437 +
2438 +/*
2439 + * The bitmask for a lookup event:
2440 + *  - follow links at the end
2441 + *  - require a directory
2442 + *  - ending slashes ok even for nonexistent files
2443 + *  - internal "there are more path compnents" flag
2444 + */
2445 +#define LOOKUP_FOLLOW          (1)
2446 +#define LOOKUP_DIRECTORY       (2)
2447 +#define LOOKUP_CONTINUE                (4)
2448 +#define LOOKUP_POSITIVE                (8)
2449 +#define LOOKUP_PARENT          (16)
2450 +#define LOOKUP_NOALT           (32)
2451 +/*
2452 + * Type of the last component on LOOKUP_PARENT
2453 + */
2454 +enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
2455 +
2456 +/*
2457 + * "descriptor" for what we're up to with a read for sendfile().
2458 + * This allows us to use the same read code yet
2459 + * have multiple different users of the data that
2460 + * we read from a file.
2461 + *
2462 + * The simplest case just copies the data to user
2463 + * mode.
2464 + */
2465 +typedef struct {
2466 +       size_t written;
2467 +       size_t count;
2468 +       char * buf;
2469 +       int error;
2470 +} read_descriptor_t;
2471 +
2472 +typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
2473 +
2474 +/* needed for stackable file system support */
2475 +extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
2476 +
2477 +extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
2478 +extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
2479 +extern int FASTCALL(path_walk(const char *, struct nameidata *));
2480 +extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
2481 +extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
2482 +extern void path_release(struct nameidata *);
2483 +extern int follow_down(struct vfsmount **, struct dentry **);
2484 +extern int follow_up(struct vfsmount **, struct dentry **);
2485 +extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
2486 +extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
2487 +#define user_path_walk(name,nd)         __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
2488 +#define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
2489 +
2490 +extern void inode_init_once(struct inode *);
2491 +extern void iput(struct inode *);
2492 +extern void force_delete(struct inode *);
2493 +extern struct inode * igrab(struct inode *);
2494 +extern ino_t iunique(struct super_block *, ino_t);
2495 +
2496 +typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
2497 +extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
2498 +static inline struct inode *iget(struct super_block *sb, unsigned long ino)
2499 +{
2500 +       return iget4(sb, ino, NULL, NULL);
2501 +}
2502 +
2503 +extern void clear_inode(struct inode *);
2504 +extern struct inode *new_inode(struct super_block *sb);
2505 +extern void remove_suid(struct inode *inode);
2506 +
2507 +extern void insert_inode_hash(struct inode *);
2508 +extern void remove_inode_hash(struct inode *);
2509 +extern struct file * get_empty_filp(void);
2510 +extern void file_move(struct file *f, struct list_head *list);
2511 +extern struct buffer_head * get_hash_table(kdev_t, int, int);
2512 +extern struct buffer_head * getblk(kdev_t, int, int);
2513 +extern void ll_rw_block(int, int, struct buffer_head * bh[]);
2514 +extern void submit_bh(int, struct buffer_head *);
2515 +extern int is_read_only(kdev_t);
2516 +extern void __brelse(struct buffer_head *);
2517 +static inline void brelse(struct buffer_head *buf)
2518 +{
2519 +       if (buf)
2520 +               __brelse(buf);
2521 +}
2522 +extern void __bforget(struct buffer_head *);
2523 +static inline void bforget(struct buffer_head *buf)
2524 +{
2525 +       if (buf)
2526 +               __bforget(buf);
2527 +}
2528 +extern int set_blocksize(kdev_t, int);
2529 +extern int sb_set_blocksize(struct super_block *, int);
2530 +extern int sb_min_blocksize(struct super_block *, int);
2531 +extern struct buffer_head * bread(kdev_t, int, int);
2532 +static inline struct buffer_head * sb_bread(struct super_block *sb, int block)
2533 +{
2534 +       return bread(sb->s_dev, block, sb->s_blocksize);
2535 +}
2536 +static inline struct buffer_head * sb_getblk(struct super_block *sb, int block)
2537 +{
2538 +       return getblk(sb->s_dev, block, sb->s_blocksize);
2539 +}
2540 +static inline struct buffer_head * sb_get_hash_table(struct super_block *sb, int block)
2541 +{
2542 +       return get_hash_table(sb->s_dev, block, sb->s_blocksize);
2543 +}
2544 +extern void wakeup_bdflush(void);
2545 +extern void put_unused_buffer_head(struct buffer_head * bh);
2546 +extern struct buffer_head * get_unused_buffer_head(int async);
2547 +
2548 +extern int brw_page(int, struct page *, kdev_t, int [], int);
2549 +
2550 +typedef int (get_block_t)(struct inode*,long,struct buffer_head*,int);
2551 +
2552 +/* Generic buffer handling for block filesystems.. */
2553 +extern int try_to_release_page(struct page * page, int gfp_mask);
2554 +extern int discard_bh_page(struct page *, unsigned long, int);
2555 +#define block_flushpage(page, offset) discard_bh_page(page, offset, 1)
2556 +#define block_invalidate_page(page) discard_bh_page(page, 0, 0)
2557 +extern int block_symlink(struct inode *, const char *, int);
2558 +extern int block_write_full_page(struct page*, get_block_t*);
2559 +extern int block_read_full_page(struct page*, get_block_t*);
2560 +extern int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
2561 +extern int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
2562 +                               unsigned long *);
2563 +extern int generic_cont_expand(struct inode *inode, loff_t size) ;
2564 +extern int block_commit_write(struct page *page, unsigned from, unsigned to);
2565 +extern int block_sync_page(struct page *);
2566 +
2567 +int generic_block_bmap(struct address_space *, long, get_block_t *);
2568 +int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
2569 +int block_truncate_page(struct address_space *, loff_t, get_block_t *);
2570 +extern int generic_direct_IO(int, struct inode *, struct kiobuf *, unsigned long, int, get_block_t *);
2571 +extern int waitfor_one_page(struct page *);
2572 +extern int writeout_one_page(struct page *);
2573 +
2574 +extern int generic_file_mmap(struct file *, struct vm_area_struct *);
2575 +extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
2576 +extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
2577 +extern int precheck_file_write(struct file *, struct inode *, size_t *, loff_t *);
2578 +extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *);
2579 +extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t);
2580 +extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
2581 +extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
2582 +extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
2583 +extern int generic_file_open(struct inode * inode, struct file * filp);
2584 +
2585 +extern struct file_operations generic_ro_fops;
2586 +
2587 +extern int vfs_readlink(struct dentry *, char *, int, const char *);
2588 +extern int vfs_follow_link(struct nameidata *, const char *);
2589 +extern int page_readlink(struct dentry *, char *, int);
2590 +extern int page_follow_link(struct dentry *, struct nameidata *);
2591 +extern struct inode_operations page_symlink_inode_operations;
2592 +
2593 +extern int vfs_readdir(struct file *, filldir_t, void *);
2594 +extern int dcache_dir_open(struct inode *, struct file *);
2595 +extern int dcache_dir_close(struct inode *, struct file *);
2596 +extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
2597 +extern int dcache_dir_fsync(struct file *, struct dentry *, int);
2598 +extern int dcache_readdir(struct file *, void *, filldir_t);
2599 +extern struct file_operations dcache_dir_ops;
2600 +
2601 +extern struct file_system_type *get_fs_type(const char *name);
2602 +extern struct super_block *get_super(kdev_t);
2603 +extern void drop_super(struct super_block *sb);
2604 +static inline int is_mounted(kdev_t dev)
2605 +{
2606 +       struct super_block *sb = get_super(dev);
2607 +       if (sb) {
2608 +               drop_super(sb);
2609 +               return 1;
2610 +       }
2611 +       return 0;
2612 +}
2613 +unsigned long generate_cluster(kdev_t, int b[], int);
2614 +unsigned long generate_cluster_swab32(kdev_t, int b[], int);
2615 +extern kdev_t ROOT_DEV;
2616 +extern char root_device_name[];
2617 +
2618 +
2619 +extern void show_buffers(void);
2620 +
2621 +#ifdef CONFIG_BLK_DEV_INITRD
2622 +extern unsigned int real_root_dev;
2623 +#endif
2624 +
2625 +extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
2626 +extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
2627 +extern int read_ahead[];
2628 +
2629 +extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
2630 +extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
2631 +
2632 +extern int file_fsync(struct file *, struct dentry *, int);
2633 +extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start_idx, unsigned long end_idx);
2634 +extern int generic_osync_inode(struct inode *, int);
2635 +#define OSYNC_METADATA (1<<0)
2636 +#define OSYNC_DATA (1<<1)
2637 +#define OSYNC_INODE (1<<2)
2638 +
2639 +extern int inode_change_ok(struct inode *, struct iattr *);
2640 +extern int inode_setattr(struct inode *, struct iattr *);
2641 +
2642 +/* kernel/fork.c */
2643 +extern int unshare_files(void);
2644 +
2645 +/*
2646 + * Common dentry functions for inclusion in the VFS
2647 + * or in other stackable file systems.  Some of these
2648 + * functions were in linux/fs/ C (VFS) files.
2649 + *
2650 + */
2651 +
2652 +/*
2653 + * Locking the parent is needed to:
2654 + *  - serialize directory operations
2655 + *  - make sure the parent doesn't change from
2656 + *    under us in the middle of an operation.
2657 + *
2658 + * NOTE! Right now we'd rather use a "struct inode"
2659 + * for this, but as I expect things to move toward
2660 + * using dentries instead for most things it is
2661 + * probably better to start with the conceptually
2662 + * better interface of relying on a path of dentries.
2663 + */
2664 +static inline struct dentry *lock_parent(struct dentry *dentry)
2665 +{
2666 +       struct dentry *dir = dget(dentry->d_parent);
2667 +
2668 +       down(&dir->d_inode->i_sem);
2669 +       return dir;
2670 +}
2671 +
2672 +static inline struct dentry *get_parent(struct dentry *dentry)
2673 +{
2674 +       return dget(dentry->d_parent);
2675 +}
2676 +
2677 +static inline void unlock_dir(struct dentry *dir)
2678 +{
2679 +       up(&dir->d_inode->i_sem);
2680 +       dput(dir);
2681 +}
2682 +
2683 +/*
2684 + * Whee.. Deadlock country. Happily there are only two VFS
2685 + * operations that does this..
2686 + */
2687 +static inline void double_down(struct semaphore *s1, struct semaphore *s2)
2688 +{
2689 +       if (s1 != s2) {
2690 +               if ((unsigned long) s1 < (unsigned long) s2) {
2691 +                       struct semaphore *tmp = s2;
2692 +                       s2 = s1; s1 = tmp;
2693 +               }
2694 +               down(s1);
2695 +       }
2696 +       down(s2);
2697 +}
2698 +
2699 +/*
2700 + * Ewwwwwwww... _triple_ lock. We are guaranteed that the 3rd argument is
2701 + * not equal to 1st and not equal to 2nd - the first case (target is parent of
2702 + * source) would be already caught, the second is plain impossible (target is
2703 + * its own parent and that case would be caught even earlier). Very messy.
2704 + * I _think_ that it works, but no warranties - please, look it through.
2705 + * Pox on bloody lusers who mandated overwriting rename() for directories...
2706 + */
2707 +
2708 +static inline void triple_down(struct semaphore *s1,
2709 +                              struct semaphore *s2,
2710 +                              struct semaphore *s3)
2711 +{
2712 +       if (s1 != s2) {
2713 +               if ((unsigned long) s1 < (unsigned long) s2) {
2714 +                       if ((unsigned long) s1 < (unsigned long) s3) {
2715 +                               struct semaphore *tmp = s3;
2716 +                               s3 = s1; s1 = tmp;
2717 +                       }
2718 +                       if ((unsigned long) s1 < (unsigned long) s2) {
2719 +                               struct semaphore *tmp = s2;
2720 +                               s2 = s1; s1 = tmp;
2721 +                       }
2722 +               } else {
2723 +                       if ((unsigned long) s1 < (unsigned long) s3) {
2724 +                               struct semaphore *tmp = s3;
2725 +                               s3 = s1; s1 = tmp;
2726 +                       }
2727 +                       if ((unsigned long) s2 < (unsigned long) s3) {
2728 +                               struct semaphore *tmp = s3;
2729 +                               s3 = s2; s2 = tmp;
2730 +                       }
2731 +               }
2732 +               down(s1);
2733 +       } else if ((unsigned long) s2 < (unsigned long) s3) {
2734 +               struct semaphore *tmp = s3;
2735 +               s3 = s2; s2 = tmp;
2736 +       }
2737 +       down(s2);
2738 +       down(s3);
2739 +}
2740 +
2741 +static inline void double_up(struct semaphore *s1, struct semaphore *s2)
2742 +{
2743 +       up(s1);
2744 +       if (s1 != s2)
2745 +               up(s2);
2746 +}
2747 +
2748 +static inline void triple_up(struct semaphore *s1,
2749 +                            struct semaphore *s2,
2750 +                            struct semaphore *s3)
2751 +{
2752 +       up(s1);
2753 +       if (s1 != s2)
2754 +               up(s2);
2755 +       up(s3);
2756 +}
2757 +
2758 +static inline void double_lock(struct dentry *d1, struct dentry *d2)
2759 +{
2760 +       double_down(&d1->d_inode->i_sem, &d2->d_inode->i_sem);
2761 +}
2762 +
2763 +static inline void double_unlock(struct dentry *d1, struct dentry *d2)
2764 +{
2765 +       double_up(&d1->d_inode->i_sem,&d2->d_inode->i_sem);
2766 +       dput(d1);
2767 +       dput(d2);
2768 +}
2769 +
2770 +#endif /* __KERNEL__ */
2771 +
2772 +#endif /* _LINUX_FS_H */
2773 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/genhd.h lilo-22.5.9/kernel-headers/linux/genhd.h
2774 --- lilo-22.5.9-orig/kernel-headers/linux/genhd.h       1970-01-01 01:00:00.000000000 +0100
2775 +++ lilo-22.5.9/kernel-headers/linux/genhd.h    2004-07-10 02:59:15.000000000 +0200
2776 @@ -0,0 +1,318 @@
2777 +#ifndef _LINUX_GENHD_H
2778 +#define _LINUX_GENHD_H
2779 +
2780 +/*
2781 + *     genhd.h Copyright (C) 1992 Drew Eckhardt
2782 + *     Generic hard disk header file by  
2783 + *             Drew Eckhardt
2784 + *
2785 + *             <drew@colorado.edu>
2786 + */
2787 +
2788 +#include <linux/config.h>
2789 +#include <linux/types.h>
2790 +#include <linux/major.h>
2791 +
2792 +enum {
2793 +/* These three have identical behaviour; use the second one if DOS fdisk gets
2794 +   confused about extended/logical partitions starting past cylinder 1023. */
2795 +       DOS_EXTENDED_PARTITION = 5,
2796 +       LINUX_EXTENDED_PARTITION = 0x85,
2797 +       WIN98_EXTENDED_PARTITION = 0x0f,
2798 +
2799 +       LINUX_SWAP_PARTITION = 0x82,
2800 +       LINUX_RAID_PARTITION = 0xfd,    /* autodetect RAID partition */
2801 +
2802 +       SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
2803 +
2804 +       DM6_PARTITION = 0x54,   /* has DDO: use xlated geom & offset */
2805 +       EZD_PARTITION = 0x55,   /* EZ-DRIVE */
2806 +       DM6_AUX1PARTITION = 0x51,       /* no DDO:  use xlated geom */
2807 +       DM6_AUX3PARTITION = 0x53,       /* no DDO:  use xlated geom */
2808 +
2809 +       FREEBSD_PARTITION = 0xa5,    /* FreeBSD Partition ID */
2810 +       OPENBSD_PARTITION = 0xa6,    /* OpenBSD Partition ID */
2811 +       NETBSD_PARTITION = 0xa9,   /* NetBSD Partition ID */
2812 +       BSDI_PARTITION = 0xb7,    /* BSDI Partition ID */
2813 +/* Ours is not to wonder why.. */
2814 +       BSD_PARTITION = FREEBSD_PARTITION,
2815 +       MINIX_PARTITION = 0x81,  /* Minix Partition ID */
2816 +       PLAN9_PARTITION = 0x39,  /* Plan 9 Partition ID */
2817 +       UNIXWARE_PARTITION = 0x63,              /* Partition ID, same as */
2818 +                                               /* GNU_HURD and SCO Unix */
2819 +};
2820 +
2821 +struct partition {
2822 +       unsigned char boot_ind;         /* 0x80 - active */
2823 +       unsigned char head;             /* starting head */
2824 +       unsigned char sector;           /* starting sector */
2825 +       unsigned char cyl;              /* starting cylinder */
2826 +       unsigned char sys_ind;          /* What partition type */
2827 +       unsigned char end_head;         /* end head */
2828 +       unsigned char end_sector;       /* end sector */
2829 +       unsigned char end_cyl;          /* end cylinder */
2830 +       unsigned int start_sect;        /* starting sector counting from 0 */
2831 +       unsigned int nr_sects;          /* nr of sectors in partition */
2832 +} __attribute__((packed));
2833 +
2834 +#ifdef __KERNEL__
2835 +#  include <linux/devfs_fs_kernel.h>
2836 +
2837 +struct hd_struct {
2838 +       unsigned long start_sect;
2839 +       unsigned long nr_sects;
2840 +       devfs_handle_t de;              /* primary (master) devfs entry  */
2841 +#ifdef CONFIG_DEVFS_FS
2842 +       int number;
2843 +#endif /* CONFIG_DEVFS_FS */
2844 +#ifdef CONFIG_BLK_STATS
2845 +       /* Performance stats: */
2846 +       unsigned int ios_in_flight;
2847 +       unsigned int io_ticks;
2848 +       unsigned int last_idle_time;
2849 +       unsigned int last_queue_change;
2850 +       unsigned int aveq;
2851 +       
2852 +       unsigned int rd_ios;
2853 +       unsigned int rd_merges;
2854 +       unsigned int rd_ticks;
2855 +       unsigned int rd_sectors;
2856 +       unsigned int wr_ios;
2857 +       unsigned int wr_merges;
2858 +       unsigned int wr_ticks;
2859 +       unsigned int wr_sectors;        
2860 +#endif /* CONFIG_BLK_STATS */
2861 +};
2862 +
2863 +#define GENHD_FL_REMOVABLE  1
2864 +
2865 +struct gendisk {
2866 +       int major;                      /* major number of driver */
2867 +       const char *major_name;         /* name of major driver */
2868 +       int minor_shift;                /* number of times minor is shifted to
2869 +                                          get real minor */
2870 +       int max_p;                      /* maximum partitions per device */
2871 +
2872 +       struct hd_struct *part;         /* [indexed by minor] */
2873 +       int *sizes;                     /* [idem], device size in blocks */
2874 +       int nr_real;                    /* number of real devices */
2875 +
2876 +       void *real_devices;             /* internal use */
2877 +       struct gendisk *next;
2878 +       struct block_device_operations *fops;
2879 +
2880 +       devfs_handle_t *de_arr;         /* one per physical disc */
2881 +       char *flags;                    /* one per physical disc */
2882 +};
2883 +
2884 +/* drivers/block/genhd.c */
2885 +extern struct gendisk *gendisk_head;
2886 +
2887 +extern void add_gendisk(struct gendisk *gp);
2888 +extern void del_gendisk(struct gendisk *gp);
2889 +extern struct gendisk *get_gendisk(kdev_t dev);
2890 +extern int walk_gendisk(int (*walk)(struct gendisk *, void *), void *);
2891 +
2892 +#endif  /*  __KERNEL__  */
2893 +
2894 +#ifdef CONFIG_SOLARIS_X86_PARTITION
2895 +
2896 +#define SOLARIS_X86_NUMSLICE   8
2897 +#define SOLARIS_X86_VTOC_SANE  (0x600DDEEEUL)
2898 +
2899 +struct solaris_x86_slice {
2900 +       ushort  s_tag;                  /* ID tag of partition */
2901 +       ushort  s_flag;                 /* permission flags */
2902 +       unsigned int s_start;           /* start sector no of partition */
2903 +       unsigned int s_size;            /* # of blocks in partition */
2904 +};
2905 +
2906 +struct solaris_x86_vtoc {
2907 +       unsigned int v_bootinfo[3];     /* info needed by mboot (unsupported) */
2908 +       unsigned int v_sanity;          /* to verify vtoc sanity */
2909 +       unsigned int v_version;         /* layout version */
2910 +       char    v_volume[8];            /* volume name */
2911 +       ushort  v_sectorsz;             /* sector size in bytes */
2912 +       ushort  v_nparts;               /* number of partitions */
2913 +       unsigned int v_reserved[10];    /* free space */
2914 +       struct solaris_x86_slice
2915 +               v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
2916 +       unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
2917 +       char    v_asciilabel[128];      /* for compatibility */
2918 +};
2919 +
2920 +#endif /* CONFIG_SOLARIS_X86_PARTITION */
2921 +
2922 +#ifdef CONFIG_BSD_DISKLABEL
2923 +/*
2924 + * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il>
2925 + * updated by Marc Espie <Marc.Espie@openbsd.org>
2926 + */
2927 +
2928 +/* check against BSD src/sys/sys/disklabel.h for consistency */
2929 +
2930 +#define BSD_DISKMAGIC  (0x82564557UL)  /* The disk magic number */
2931 +#define BSD_MAXPARTITIONS      8
2932 +#define OPENBSD_MAXPARTITIONS  16
2933 +#define BSD_FS_UNUSED          0       /* disklabel unused partition entry ID */
2934 +struct bsd_disklabel {
2935 +       __u32   d_magic;                /* the magic number */
2936 +       __s16   d_type;                 /* drive type */
2937 +       __s16   d_subtype;              /* controller/d_type specific */
2938 +       char    d_typename[16];         /* type name, e.g. "eagle" */
2939 +       char    d_packname[16];                 /* pack identifier */ 
2940 +       __u32   d_secsize;              /* # of bytes per sector */
2941 +       __u32   d_nsectors;             /* # of data sectors per track */
2942 +       __u32   d_ntracks;              /* # of tracks per cylinder */
2943 +       __u32   d_ncylinders;           /* # of data cylinders per unit */
2944 +       __u32   d_secpercyl;            /* # of data sectors per cylinder */
2945 +       __u32   d_secperunit;           /* # of data sectors per unit */
2946 +       __u16   d_sparespertrack;       /* # of spare sectors per track */
2947 +       __u16   d_sparespercyl;         /* # of spare sectors per cylinder */
2948 +       __u32   d_acylinders;           /* # of alt. cylinders per unit */
2949 +       __u16   d_rpm;                  /* rotational speed */
2950 +       __u16   d_interleave;           /* hardware sector interleave */
2951 +       __u16   d_trackskew;            /* sector 0 skew, per track */
2952 +       __u16   d_cylskew;              /* sector 0 skew, per cylinder */
2953 +       __u32   d_headswitch;           /* head switch time, usec */
2954 +       __u32   d_trkseek;              /* track-to-track seek, usec */
2955 +       __u32   d_flags;                /* generic flags */
2956 +#define NDDATA 5
2957 +       __u32   d_drivedata[NDDATA];    /* drive-type specific information */
2958 +#define NSPARE 5
2959 +       __u32   d_spare[NSPARE];        /* reserved for future use */
2960 +       __u32   d_magic2;               /* the magic number (again) */
2961 +       __u16   d_checksum;             /* xor of data incl. partitions */
2962 +
2963 +                       /* filesystem and partition information: */
2964 +       __u16   d_npartitions;          /* number of partitions in following */
2965 +       __u32   d_bbsize;               /* size of boot area at sn0, bytes */
2966 +       __u32   d_sbsize;               /* max size of fs superblock, bytes */
2967 +       struct  bsd_partition {         /* the partition table */
2968 +               __u32   p_size;         /* number of sectors in partition */
2969 +               __u32   p_offset;       /* starting sector */
2970 +               __u32   p_fsize;        /* filesystem basic fragment size */
2971 +               __u8    p_fstype;       /* filesystem type, see below */
2972 +               __u8    p_frag;         /* filesystem fragments per block */
2973 +               __u16   p_cpg;          /* filesystem cylinders per group */
2974 +       } d_partitions[BSD_MAXPARTITIONS];      /* actually may be more */
2975 +};
2976 +
2977 +#endif /* CONFIG_BSD_DISKLABEL */
2978 +
2979 +#ifdef CONFIG_UNIXWARE_DISKLABEL
2980 +/*
2981 + * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
2982 + * and Krzysztof G. Baranowski <kgb@knm.org.pl>
2983 + */
2984 +
2985 +#define UNIXWARE_DISKMAGIC     (0xCA5E600DUL)  /* The disk magic number */
2986 +#define UNIXWARE_DISKMAGIC2    (0x600DDEEEUL)  /* The slice table magic nr */
2987 +#define UNIXWARE_NUMSLICE      16
2988 +#define UNIXWARE_FS_UNUSED     0               /* Unused slice entry ID */
2989 +
2990 +struct unixware_slice {
2991 +       __u16   s_label;        /* label */
2992 +       __u16   s_flags;        /* permission flags */
2993 +       __u32   start_sect;     /* starting sector */
2994 +       __u32   nr_sects;       /* number of sectors in slice */
2995 +};
2996 +
2997 +struct unixware_disklabel {
2998 +       __u32   d_type;                 /* drive type */
2999 +       __u32   d_magic;                /* the magic number */
3000 +       __u32   d_version;              /* version number */
3001 +       char    d_serial[12];           /* serial number of the device */
3002 +       __u32   d_ncylinders;           /* # of data cylinders per device */
3003 +       __u32   d_ntracks;              /* # of tracks per cylinder */
3004 +       __u32   d_nsectors;             /* # of data sectors per track */
3005 +       __u32   d_secsize;              /* # of bytes per sector */
3006 +       __u32   d_part_start;           /* # of first sector of this partition */
3007 +       __u32   d_unknown1[12];         /* ? */
3008 +       __u32   d_alt_tbl;              /* byte offset of alternate table */
3009 +       __u32   d_alt_len;              /* byte length of alternate table */
3010 +       __u32   d_phys_cyl;             /* # of physical cylinders per device */
3011 +       __u32   d_phys_trk;             /* # of physical tracks per cylinder */
3012 +       __u32   d_phys_sec;             /* # of physical sectors per track */
3013 +       __u32   d_phys_bytes;           /* # of physical bytes per sector */
3014 +       __u32   d_unknown2;             /* ? */
3015 +       __u32   d_unknown3;             /* ? */
3016 +       __u32   d_pad[8];               /* pad */
3017 +
3018 +       struct unixware_vtoc {
3019 +               __u32   v_magic;                /* the magic number */
3020 +               __u32   v_version;              /* version number */
3021 +               char    v_name[8];              /* volume name */
3022 +               __u16   v_nslices;              /* # of slices */
3023 +               __u16   v_unknown1;             /* ? */
3024 +               __u32   v_reserved[10];         /* reserved */
3025 +               struct unixware_slice
3026 +                       v_slice[UNIXWARE_NUMSLICE];     /* slice headers */
3027 +       } vtoc;
3028 +
3029 +};  /* 408 */
3030 +
3031 +#endif /* CONFIG_UNIXWARE_DISKLABEL */
3032 +
3033 +#ifdef CONFIG_MINIX_SUBPARTITION
3034 +#   define MINIX_NR_SUBPARTITIONS  4
3035 +#endif /* CONFIG_MINIX_SUBPARTITION */
3036 +
3037 +#ifdef __KERNEL__
3038 +
3039 +char *disk_name (struct gendisk *hd, int minor, char *buf);
3040 +
3041 +/* 
3042 + * Account for the completion of an IO request (used by drivers which 
3043 + * bypass the normal end_request processing) 
3044 + */
3045 +struct request;
3046 +
3047 +#ifdef CONFIG_BLK_STATS
3048 +extern void disk_round_stats(struct hd_struct *hd);
3049 +extern void req_new_io(struct request *req, int merge, int sectors);
3050 +extern void req_merged_io(struct request *req);
3051 +extern void req_finished_io(struct request *req);
3052 +#else
3053 +static inline void req_new_io(struct request *req, int merge, int sectors) { }
3054 +static inline void req_merged_io(struct request *req) { }
3055 +static inline void req_finished_io(struct request *req) { }
3056 +#endif /* CONFIG_BLK_STATS */
3057 +
3058 +extern void devfs_register_partitions (struct gendisk *dev, int minor,
3059 +                                      int unregister);
3060 +
3061 +
3062 +
3063 +/*
3064 + * FIXME: this should use genhd->minor_shift, but that is slow to look up.
3065 + */
3066 +static inline unsigned int disk_index (kdev_t dev)
3067 +{
3068 +       int major = MAJOR(dev);
3069 +       int minor = MINOR(dev);
3070 +       unsigned int index;
3071 +
3072 +       switch (major) {
3073 +               case DAC960_MAJOR+0:
3074 +                       index = (minor & 0x00f8) >> 3;
3075 +                       break;
3076 +               case SCSI_DISK0_MAJOR:
3077 +                       index = (minor & 0x00f0) >> 4;
3078 +                       break;
3079 +               case IDE0_MAJOR:        /* same as HD_MAJOR */
3080 +               case XT_DISK_MAJOR:
3081 +                       index = (minor & 0x0040) >> 6;
3082 +                       break;
3083 +               case IDE1_MAJOR:
3084 +                       index = ((minor & 0x0040) >> 6) + 2;
3085 +                       break;
3086 +               default:
3087 +                       return 0;
3088 +       }
3089 +       return index;
3090 +}
3091 +
3092 +#endif
3093 +
3094 +#endif
3095 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/hdreg.h lilo-22.5.9/kernel-headers/linux/hdreg.h
3096 --- lilo-22.5.9-orig/kernel-headers/linux/hdreg.h       1970-01-01 01:00:00.000000000 +0100
3097 +++ lilo-22.5.9/kernel-headers/linux/hdreg.h    2004-07-10 02:59:15.000000000 +0200
3098 @@ -0,0 +1,746 @@
3099 +#ifndef _LINUX_HDREG_H
3100 +#define _LINUX_HDREG_H
3101 +
3102 +/*
3103 + * This file contains some defines for the AT-hd-controller.
3104 + * Various sources.  
3105 + */
3106 +
3107 +#define HD_IRQ 14                      /* the standard disk interrupt */
3108 +
3109 +/* ide.c has its own port definitions in "ide.h" */
3110 +
3111 +/* Hd controller regs. Ref: IBM AT Bios-listing */
3112 +#define HD_DATA                0x1f0           /* _CTL when writing */
3113 +#define HD_ERROR       0x1f1           /* see err-bits */
3114 +#define HD_NSECTOR     0x1f2           /* nr of sectors to read/write */
3115 +#define HD_SECTOR      0x1f3           /* starting sector */
3116 +#define HD_LCYL                0x1f4           /* starting cylinder */
3117 +#define HD_HCYL                0x1f5           /* high byte of starting cyl */
3118 +#define HD_CURRENT     0x1f6           /* 101dhhhh , d=drive, hhhh=head */
3119 +#define HD_STATUS      0x1f7           /* see status-bits */
3120 +#define HD_FEATURE     HD_ERROR        /* same io address, read=error, write=feature */
3121 +#define HD_PRECOMP     HD_FEATURE      /* obsolete use of this port - predates IDE */
3122 +#define HD_COMMAND     HD_STATUS       /* same io address, read=status, write=cmd */
3123 +
3124 +#define HD_CMD         0x3f6           /* used for resets */
3125 +#define HD_ALTSTATUS   0x3f6           /* same as HD_STATUS but doesn't clear irq */
3126 +
3127 +/* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */
3128 +
3129 +/* Bits of HD_STATUS */
3130 +#define ERR_STAT               0x01
3131 +#define INDEX_STAT             0x02
3132 +#define ECC_STAT               0x04    /* Corrected error */
3133 +#define DRQ_STAT               0x08
3134 +#define SEEK_STAT              0x10
3135 +#define SRV_STAT               0x10
3136 +#define WRERR_STAT             0x20
3137 +#define READY_STAT             0x40
3138 +#define BUSY_STAT              0x80
3139 +
3140 +/* Bits for HD_ERROR */
3141 +#define MARK_ERR               0x01    /* Bad address mark */
3142 +#define TRK0_ERR               0x02    /* couldn't find track 0 */
3143 +#define ABRT_ERR               0x04    /* Command aborted */
3144 +#define MCR_ERR                        0x08    /* media change request */
3145 +#define ID_ERR                 0x10    /* ID field not found */
3146 +#define MC_ERR                 0x20    /* media changed */
3147 +#define ECC_ERR                        0x40    /* Uncorrectable ECC error */
3148 +#define BBD_ERR                        0x80    /* pre-EIDE meaning:  block marked bad */
3149 +#define ICRC_ERR               0x80    /* new meaning:  CRC error during transfer */
3150 +
3151 +/* Bits of HD_NSECTOR */
3152 +#define CD                     0x01
3153 +#define IO                     0x02
3154 +#define REL                    0x04
3155 +#define TAG_MASK               0xf8
3156 +
3157 +
3158 +/*
3159 + * Command Header sizes for IOCTL commands
3160 + *     HDIO_DRIVE_CMD, HDIO_DRIVE_TASK, and HDIO_DRIVE_TASKFILE
3161 + */
3162 +
3163 +#if 0
3164 +#include <asm/hdreg.h>
3165 +typedef ide_ioreg_t task_ioreg_t;
3166 +#else
3167 +typedef unsigned char task_ioreg_t;
3168 +#endif
3169 +
3170 +typedef unsigned long sata_ioreg_t;
3171 +
3172 +#define HDIO_DRIVE_CMD_HDR_SIZE                4*sizeof(task_ioreg_t)
3173 +#define HDIO_DRIVE_TASK_HDR_SIZE       8*sizeof(task_ioreg_t)
3174 +#define HDIO_DRIVE_HOB_HDR_SIZE                8*sizeof(task_ioreg_t)
3175 +
3176 +#define IDE_DRIVE_TASK_INVALID         -1
3177 +#define IDE_DRIVE_TASK_NO_DATA         0
3178 +#define IDE_DRIVE_TASK_SET_XFER                1
3179 +
3180 +#define IDE_DRIVE_TASK_IN              2
3181 +
3182 +#define IDE_DRIVE_TASK_OUT             3
3183 +#define IDE_DRIVE_TASK_RAW_WRITE       4
3184 +
3185 +struct hd_drive_cmd_hdr {
3186 +       task_ioreg_t command;
3187 +       task_ioreg_t sector_number;
3188 +       task_ioreg_t feature;
3189 +       task_ioreg_t sector_count;
3190 +};
3191 +
3192 +typedef struct hd_drive_task_hdr {
3193 +       task_ioreg_t data;
3194 +       task_ioreg_t feature;
3195 +       task_ioreg_t sector_count;
3196 +       task_ioreg_t sector_number;
3197 +       task_ioreg_t low_cylinder;
3198 +       task_ioreg_t high_cylinder;
3199 +       task_ioreg_t device_head;
3200 +       task_ioreg_t command;
3201 +} task_struct_t;
3202 +
3203 +typedef struct hd_drive_hob_hdr {
3204 +       task_ioreg_t data;
3205 +       task_ioreg_t feature;
3206 +       task_ioreg_t sector_count;
3207 +       task_ioreg_t sector_number;
3208 +       task_ioreg_t low_cylinder;
3209 +       task_ioreg_t high_cylinder;
3210 +       task_ioreg_t device_head;
3211 +       task_ioreg_t control;
3212 +} hob_struct_t;
3213 +
3214 +typedef union ide_reg_valid_s {
3215 +       unsigned all                            : 16;
3216 +       struct {
3217 +               unsigned data                   : 1;
3218 +               unsigned error_feature          : 1;
3219 +               unsigned sector                 : 1;
3220 +               unsigned nsector                : 1;
3221 +               unsigned lcyl                   : 1;
3222 +               unsigned hcyl                   : 1;
3223 +               unsigned select                 : 1;
3224 +               unsigned status_command         : 1;
3225 +
3226 +               unsigned data_hob               : 1;
3227 +               unsigned error_feature_hob      : 1;
3228 +               unsigned sector_hob             : 1;
3229 +               unsigned nsector_hob            : 1;
3230 +               unsigned lcyl_hob               : 1;
3231 +               unsigned hcyl_hob               : 1;
3232 +               unsigned select_hob             : 1;
3233 +               unsigned control_hob            : 1;
3234 +       } b;
3235 +} ide_reg_valid_t;
3236 +
3237 +/*
3238 + * Define standard taskfile in/out register
3239 + */
3240 +#define IDE_TASKFILE_STD_OUT_FLAGS     0xFE
3241 +#define IDE_TASKFILE_STD_IN_FLAGS      0xFE
3242 +#define IDE_HOB_STD_OUT_FLAGS          0x3C
3243 +#define IDE_HOB_STD_IN_FLAGS           0x3C
3244 +
3245 +typedef struct ide_task_request_s {
3246 +       task_ioreg_t    io_ports[8];
3247 +       task_ioreg_t    hob_ports[8];
3248 +       ide_reg_valid_t out_flags;
3249 +       ide_reg_valid_t in_flags;
3250 +       int             data_phase;
3251 +       int             req_cmd;
3252 +       unsigned long   out_size;
3253 +       unsigned long   in_size;
3254 +} ide_task_request_t;
3255 +
3256 +typedef struct ide_ioctl_request_s {
3257 +       ide_task_request_t      *task_request;
3258 +       unsigned char           *out_buffer;
3259 +       unsigned char           *in_buffer;
3260 +} ide_ioctl_request_t;
3261 +
3262 +#define TASKFILE_INVALID               0x7fff
3263 +#define TASKFILE_48                    0x8000
3264 +
3265 +#define TASKFILE_NO_DATA               0x0000
3266 +
3267 +#define TASKFILE_IN                    0x0001
3268 +#define TASKFILE_MULTI_IN              0x0002
3269 +
3270 +#define TASKFILE_OUT                   0x0004
3271 +#define TASKFILE_MULTI_OUT             0x0008
3272 +#define TASKFILE_IN_OUT                        0x0010
3273 +
3274 +#define TASKFILE_IN_DMA                        0x0020
3275 +#define TASKFILE_OUT_DMA               0x0040
3276 +#define TASKFILE_IN_DMAQ               0x0080
3277 +#define TASKFILE_OUT_DMAQ              0x0100
3278 +
3279 +#define TASKFILE_P_IN                  0x0200
3280 +#define TASKFILE_P_OUT                 0x0400
3281 +#define TASKFILE_P_IN_DMA              0x0800
3282 +#define TASKFILE_P_OUT_DMA             0x1000
3283 +#define TASKFILE_P_IN_DMAQ             0x2000
3284 +#define TASKFILE_P_OUT_DMAQ            0x4000
3285 +
3286 +/* ATA/ATAPI Commands pre T13 Spec */
3287 +#define WIN_NOP                                0x00
3288 +/*
3289 + *     0x01->0x02 Reserved
3290 + */
3291 +#define CFA_REQ_EXT_ERROR_CODE         0x03 /* CFA Request Extended Error Code */
3292 +/*
3293 + *     0x04->0x07 Reserved
3294 + */
3295 +#define WIN_SRST                       0x08 /* ATAPI soft reset command */
3296 +#define WIN_DEVICE_RESET               0x08
3297 +/*
3298 + *     0x09->0x0F Reserved
3299 + */
3300 +#define WIN_RECAL                      0x10
3301 +#define WIN_RESTORE                    WIN_RECAL
3302 +/*
3303 + *     0x10->0x1F Reserved
3304 + */
3305 +#define WIN_READ                       0x20 /* 28-Bit */
3306 +#define WIN_READ_ONCE                  0x21 /* 28-Bit without retries */
3307 +#define WIN_READ_LONG                  0x22 /* 28-Bit */
3308 +#define WIN_READ_LONG_ONCE             0x23 /* 28-Bit without retries */
3309 +#define WIN_READ_EXT                   0x24 /* 48-Bit */
3310 +#define WIN_READDMA_EXT                        0x25 /* 48-Bit */
3311 +#define WIN_READDMA_QUEUED_EXT         0x26 /* 48-Bit */
3312 +#define WIN_READ_NATIVE_MAX_EXT                0x27 /* 48-Bit */
3313 +/*
3314 + *     0x28
3315 + */
3316 +#define WIN_MULTREAD_EXT               0x29 /* 48-Bit */
3317 +/*
3318 + *     0x2A->0x2F Reserved
3319 + */
3320 +#define WIN_WRITE                      0x30 /* 28-Bit */
3321 +#define WIN_WRITE_ONCE                 0x31 /* 28-Bit without retries */
3322 +#define WIN_WRITE_LONG                 0x32 /* 28-Bit */
3323 +#define WIN_WRITE_LONG_ONCE            0x33 /* 28-Bit without retries */
3324 +#define WIN_WRITE_EXT                  0x34 /* 48-Bit */
3325 +#define WIN_WRITEDMA_EXT               0x35 /* 48-Bit */
3326 +#define WIN_WRITEDMA_QUEUED_EXT                0x36 /* 48-Bit */
3327 +#define WIN_SET_MAX_EXT                        0x37 /* 48-Bit */
3328 +#define CFA_WRITE_SECT_WO_ERASE                0x38 /* CFA Write Sectors without erase */
3329 +#define WIN_MULTWRITE_EXT              0x39 /* 48-Bit */
3330 +/*
3331 + *     0x3A->0x3B Reserved
3332 + */
3333 +#define WIN_WRITE_VERIFY               0x3C /* 28-Bit */
3334 +/*
3335 + *     0x3D->0x3F Reserved
3336 + */
3337 +#define WIN_VERIFY                     0x40 /* 28-Bit - Read Verify Sectors */
3338 +#define WIN_VERIFY_ONCE                        0x41 /* 28-Bit - without retries */
3339 +#define WIN_VERIFY_EXT                 0x42 /* 48-Bit */
3340 +/*
3341 + *     0x43->0x4F Reserved
3342 + */
3343 +#define WIN_FORMAT                     0x50
3344 +/*
3345 + *     0x51->0x5F Reserved
3346 + */
3347 +#define WIN_INIT                       0x60
3348 +/*
3349 + *     0x61->0x5F Reserved
3350 + */
3351 +#define WIN_SEEK                       0x70 /* 0x70-0x7F Reserved */
3352 +#define CFA_TRANSLATE_SECTOR           0x87 /* CFA Translate Sector */
3353 +#define WIN_DIAGNOSE                   0x90
3354 +#define WIN_SPECIFY                    0x91 /* set drive geometry translation */
3355 +#define WIN_DOWNLOAD_MICROCODE         0x92
3356 +#define WIN_STANDBYNOW2                        0x94
3357 +#define WIN_STANDBY2                   0x96
3358 +#define WIN_SETIDLE2                   0x97
3359 +#define WIN_CHECKPOWERMODE2            0x98
3360 +#define WIN_SLEEPNOW2                  0x99
3361 +/*
3362 + *     0x9A VENDOR
3363 + */
3364 +#define WIN_PACKETCMD                  0xA0 /* Send a packet command. */
3365 +#define WIN_PIDENTIFY                  0xA1 /* identify ATAPI device   */
3366 +#define WIN_QUEUED_SERVICE             0xA2
3367 +#define WIN_SMART                      0xB0 /* self-monitoring and reporting */
3368 +#define CFA_ERASE_SECTORS              0xC0
3369 +#define WIN_MULTREAD                   0xC4 /* read sectors using multiple mode*/
3370 +#define WIN_MULTWRITE                  0xC5 /* write sectors using multiple mode */
3371 +#define WIN_SETMULT                    0xC6 /* enable/disable multiple mode */
3372 +#define WIN_READDMA_QUEUED             0xC7 /* read sectors using Queued DMA transfers */
3373 +#define WIN_READDMA                    0xC8 /* read sectors using DMA transfers */
3374 +#define WIN_READDMA_ONCE               0xC9 /* 28-Bit - without retries */
3375 +#define WIN_WRITEDMA                   0xCA /* write sectors using DMA transfers */
3376 +#define WIN_WRITEDMA_ONCE              0xCB /* 28-Bit - without retries */
3377 +#define WIN_WRITEDMA_QUEUED            0xCC /* write sectors using Queued DMA transfers */
3378 +#define CFA_WRITE_MULTI_WO_ERASE       0xCD /* CFA Write multiple without erase */
3379 +#define WIN_GETMEDIASTATUS             0xDA    
3380 +#define WIN_ACKMEDIACHANGE             0xDB /* ATA-1, ATA-2 vendor */
3381 +#define WIN_POSTBOOT                   0xDC
3382 +#define WIN_PREBOOT                    0xDD
3383 +#define WIN_DOORLOCK                   0xDE /* lock door on removable drives */
3384 +#define WIN_DOORUNLOCK                 0xDF /* unlock door on removable drives */
3385 +#define WIN_STANDBYNOW1                        0xE0
3386 +#define WIN_IDLEIMMEDIATE              0xE1 /* force drive to become "ready" */
3387 +#define WIN_STANDBY                    0xE2 /* Set device in Standby Mode */
3388 +#define WIN_SETIDLE1                   0xE3
3389 +#define WIN_READ_BUFFER                        0xE4 /* force read only 1 sector */
3390 +#define WIN_CHECKPOWERMODE1            0xE5
3391 +#define WIN_SLEEPNOW1                  0xE6
3392 +#define WIN_FLUSH_CACHE                        0xE7
3393 +#define WIN_WRITE_BUFFER               0xE8 /* force write only 1 sector */
3394 +#define WIN_WRITE_SAME                 0xE9 /* read ata-2 to use */
3395 +       /* SET_FEATURES 0x22 or 0xDD */
3396 +#define WIN_FLUSH_CACHE_EXT            0xEA /* 48-Bit */
3397 +#define WIN_IDENTIFY                   0xEC /* ask drive to identify itself    */
3398 +#define WIN_MEDIAEJECT                 0xED
3399 +#define WIN_IDENTIFY_DMA               0xEE /* same as WIN_IDENTIFY, but DMA */
3400 +#define WIN_SETFEATURES                        0xEF /* set special drive features */
3401 +#define EXABYTE_ENABLE_NEST            0xF0
3402 +#define WIN_SECURITY_SET_PASS          0xF1
3403 +#define WIN_SECURITY_UNLOCK            0xF2
3404 +#define WIN_SECURITY_ERASE_PREPARE     0xF3
3405 +#define WIN_SECURITY_ERASE_UNIT                0xF4
3406 +#define WIN_SECURITY_FREEZE_LOCK       0xF5
3407 +#define WIN_SECURITY_DISABLE           0xF6
3408 +#define WIN_READ_NATIVE_MAX            0xF8 /* return the native maximum address */
3409 +#define WIN_SET_MAX                    0xF9
3410 +#define DISABLE_SEAGATE                        0xFB
3411 +
3412 +/* WIN_SMART sub-commands */
3413 +
3414 +#define SMART_READ_VALUES              0xD0
3415 +#define SMART_READ_THRESHOLDS          0xD1
3416 +#define SMART_AUTOSAVE                 0xD2
3417 +#define SMART_SAVE                     0xD3
3418 +#define SMART_IMMEDIATE_OFFLINE                0xD4
3419 +#define SMART_READ_LOG_SECTOR          0xD5
3420 +#define SMART_WRITE_LOG_SECTOR         0xD6
3421 +#define SMART_WRITE_THRESHOLDS         0xD7
3422 +#define SMART_ENABLE                   0xD8
3423 +#define SMART_DISABLE                  0xD9
3424 +#define SMART_STATUS                   0xDA
3425 +#define SMART_AUTO_OFFLINE             0xDB
3426 +
3427 +/* Password used in TF4 & TF5 executing SMART commands */
3428 +
3429 +#define SMART_LCYL_PASS                        0x4F
3430 +#define SMART_HCYL_PASS                        0xC2
3431 +               
3432 +/* WIN_SETFEATURES sub-commands */
3433 +#define SETFEATURES_EN_8BIT    0x01    /* Enable 8-Bit Transfers */
3434 +#define SETFEATURES_EN_WCACHE  0x02    /* Enable write cache */
3435 +#define SETFEATURES_XFER       0x03    /* Set transfer mode */
3436 +#      define XFER_UDMA_7      0x47    /* 0100|0111 */
3437 +#      define XFER_UDMA_6      0x46    /* 0100|0110 */
3438 +#      define XFER_UDMA_5      0x45    /* 0100|0101 */
3439 +#      define XFER_UDMA_4      0x44    /* 0100|0100 */
3440 +#      define XFER_UDMA_3      0x43    /* 0100|0011 */
3441 +#      define XFER_UDMA_2      0x42    /* 0100|0010 */
3442 +#      define XFER_UDMA_1      0x41    /* 0100|0001 */
3443 +#      define XFER_UDMA_0      0x40    /* 0100|0000 */
3444 +#      define XFER_MW_DMA_2    0x22    /* 0010|0010 */
3445 +#      define XFER_MW_DMA_1    0x21    /* 0010|0001 */
3446 +#      define XFER_MW_DMA_0    0x20    /* 0010|0000 */
3447 +#      define XFER_SW_DMA_2    0x12    /* 0001|0010 */
3448 +#      define XFER_SW_DMA_1    0x11    /* 0001|0001 */
3449 +#      define XFER_SW_DMA_0    0x10    /* 0001|0000 */
3450 +#      define XFER_PIO_4       0x0C    /* 0000|1100 */
3451 +#      define XFER_PIO_3       0x0B    /* 0000|1011 */
3452 +#      define XFER_PIO_2       0x0A    /* 0000|1010 */
3453 +#      define XFER_PIO_1       0x09    /* 0000|1001 */
3454 +#      define XFER_PIO_0       0x08    /* 0000|1000 */
3455 +#      define XFER_PIO_SLOW    0x00    /* 0000|0000 */
3456 +#define SETFEATURES_DIS_DEFECT 0x04    /* Disable Defect Management */
3457 +#define SETFEATURES_EN_APM     0x05    /* Enable advanced power management */
3458 +#define SETFEATURES_EN_SAME_R  0x22    /* for a region ATA-1 */
3459 +#define SETFEATURES_DIS_MSN    0x31    /* Disable Media Status Notification */
3460 +#define SETFEATURES_DIS_RETRY  0x33    /* Disable Retry */
3461 +#define SETFEATURES_EN_AAM     0x42    /* Enable Automatic Acoustic Management */
3462 +#define SETFEATURES_RW_LONG    0x44    /* Set Lenght of VS bytes */
3463 +#define SETFEATURES_SET_CACHE  0x54    /* Set Cache segments to SC Reg. Val */
3464 +#define SETFEATURES_DIS_RLA    0x55    /* Disable read look-ahead feature */
3465 +#define SETFEATURES_EN_RI      0x5D    /* Enable release interrupt */
3466 +#define SETFEATURES_EN_SI      0x5E    /* Enable SERVICE interrupt */
3467 +#define SETFEATURES_DIS_RPOD   0x66    /* Disable reverting to power on defaults */
3468 +#define SETFEATURES_DIS_ECC    0x77    /* Disable ECC byte count */
3469 +#define SETFEATURES_DIS_8BIT   0x81    /* Disable 8-Bit Transfers */
3470 +#define SETFEATURES_DIS_WCACHE 0x82    /* Disable write cache */
3471 +#define SETFEATURES_EN_DEFECT  0x84    /* Enable Defect Management */
3472 +#define SETFEATURES_DIS_APM    0x85    /* Disable advanced power management */
3473 +#define SETFEATURES_EN_ECC     0x88    /* Enable ECC byte count */
3474 +#define SETFEATURES_EN_MSN     0x95    /* Enable Media Status Notification */
3475 +#define SETFEATURES_EN_RETRY   0x99    /* Enable Retry */
3476 +#define SETFEATURES_EN_RLA     0xAA    /* Enable read look-ahead feature */
3477 +#define SETFEATURES_PREFETCH   0xAB    /* Sets drive prefetch value */
3478 +#define SETFEATURES_EN_REST    0xAC    /* ATA-1 */
3479 +#define SETFEATURES_4B_RW_LONG 0xBB    /* Set Lenght of 4 bytes */
3480 +#define SETFEATURES_DIS_AAM    0xC2    /* Disable Automatic Acoustic Management */
3481 +#define SETFEATURES_EN_RPOD    0xCC    /* Enable reverting to power on defaults */
3482 +#define SETFEATURES_DIS_RI     0xDD    /* Disable release interrupt ATAPI */
3483 +#define SETFEATURES_EN_SAME_M  0xDD    /* for a entire device ATA-1 */
3484 +#define SETFEATURES_DIS_SI     0xDE    /* Disable SERVICE interrupt ATAPI */
3485 +
3486 +/* WIN_SECURITY sub-commands */
3487 +
3488 +#define SECURITY_SET_PASSWORD          0xBA
3489 +#define SECURITY_UNLOCK                        0xBB
3490 +#define SECURITY_ERASE_PREPARE         0xBC
3491 +#define SECURITY_ERASE_UNIT            0xBD
3492 +#define SECURITY_FREEZE_LOCK           0xBE
3493 +#define SECURITY_DISABLE_PASSWORD      0xBF
3494 +
3495 +struct hd_geometry {
3496 +      unsigned char heads;
3497 +      unsigned char sectors;
3498 +      unsigned short cylinders;
3499 +      unsigned long start;
3500 +};
3501 +
3502 +/* BIG GEOMETRY */
3503 +struct hd_big_geometry {
3504 +       unsigned char heads;
3505 +       unsigned char sectors;
3506 +       unsigned int cylinders;
3507 +       unsigned long start;
3508 +};
3509 +
3510 +/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
3511 +#define HDIO_GETGEO            0x0301  /* get device geometry */
3512 +#define HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
3513 +#define HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
3514 +#define HDIO_GET_QDMA          0x0305  /* get use-qdma flag */
3515 +
3516 +#define HDIO_SET_XFER          0x0306  /* set transfer rate via proc */
3517 +
3518 +#define HDIO_OBSOLETE_IDENTITY 0x0307  /* OBSOLETE, DO NOT USE: returns 142 bytes */
3519 +#define HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
3520 +#define HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
3521 +#define HDIO_GET_NOWERR                0x030a  /* get ignore-write-error flag */
3522 +#define HDIO_GET_DMA           0x030b  /* get use-dma flag */
3523 +#define HDIO_GET_NICE          0x030c  /* get nice flags */
3524 +#define HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
3525 +#define HDIO_GET_WCACHE                0x030e  /* get write cache mode on|off */
3526 +#define HDIO_GET_ACOUSTIC      0x030f  /* get acoustic value */
3527 +#define        HDIO_GET_ADDRESS        0x0310  /* */
3528 +
3529 +#define HDIO_GET_BUSSTATE      0x031a  /* get the bus state of the hwif */
3530 +#define HDIO_TRISTATE_HWIF     0x031b  /* execute a channel tristate */
3531 +#define HDIO_DRIVE_RESET       0x031c  /* execute a device reset */
3532 +#define HDIO_DRIVE_TASKFILE    0x031d  /* execute raw taskfile */
3533 +#define HDIO_DRIVE_TASK                0x031e  /* execute task and special drive command */
3534 +#define HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
3535 +
3536 +#define HDIO_DRIVE_CMD_AEB     HDIO_DRIVE_TASK
3537 +
3538 +/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
3539 +#define HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
3540 +#define HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
3541 +#define HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
3542 +#define HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
3543 +#define HDIO_SET_NOWERR                0x0325  /* change ignore-write-error flag */
3544 +#define HDIO_SET_DMA           0x0326  /* change use-dma flag */
3545 +#define HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
3546 +#define HDIO_SCAN_HWIF         0x0328  /* register and (re)scan interface */
3547 +#define HDIO_SET_NICE          0x0329  /* set nice flags */
3548 +#define HDIO_UNREGISTER_HWIF   0x032a  /* unregister interface */
3549 +#define HDIO_SET_WCACHE                0x032b  /* change write cache enable-disable */
3550 +#define HDIO_SET_ACOUSTIC      0x032c  /* change acoustic behavior */
3551 +#define HDIO_SET_BUSSTATE      0x032d  /* set the bus state of the hwif */
3552 +#define HDIO_SET_QDMA          0x032e  /* change use-qdma flag */
3553 +#define HDIO_SET_ADDRESS       0x032f  /* change lba addressing modes */
3554 +
3555 +/* bus states */
3556 +enum {
3557 +       BUSSTATE_OFF = 0,
3558 +       BUSSTATE_ON,
3559 +       BUSSTATE_TRISTATE
3560 +};
3561 +
3562 +/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x033n/0x033n */
3563 +#define HDIO_GETGEO_BIG                0x0330  /* */
3564 +#define HDIO_GETGEO_BIG_RAW    0x0331  /* */
3565 +
3566 +#define HDIO_SET_IDE_SCSI      0x0338
3567 +#define HDIO_SET_SCSI_IDE      0x0339
3568 +
3569 +#define __NEW_HD_DRIVE_ID
3570 +/* structure returned by HDIO_GET_IDENTITY,
3571 + * as per ANSI NCITS ATA6 rev.1b spec
3572 + */
3573 +struct hd_driveid {
3574 +       unsigned short  config;         /* lots of obsolete bit flags */
3575 +       unsigned short  cyls;           /* Obsolete, "physical" cyls */
3576 +       unsigned short  reserved2;      /* reserved (word 2) */
3577 +       unsigned short  heads;          /* Obsolete, "physical" heads */
3578 +       unsigned short  track_bytes;    /* unformatted bytes per track */
3579 +       unsigned short  sector_bytes;   /* unformatted bytes per sector */
3580 +       unsigned short  sectors;        /* Obsolete, "physical" sectors per track */
3581 +       unsigned short  vendor0;        /* vendor unique */
3582 +       unsigned short  vendor1;        /* vendor unique */
3583 +       unsigned short  vendor2;        /* Retired vendor unique */
3584 +       unsigned char   serial_no[20];  /* 0 = not_specified */
3585 +       unsigned short  buf_type;       /* Retired */
3586 +       unsigned short  buf_size;       /* Retired, 512 byte increments
3587 +                                        * 0 = not_specified
3588 +                                        */
3589 +       unsigned short  ecc_bytes;      /* for r/w long cmds; 0 = not_specified */
3590 +       unsigned char   fw_rev[8];      /* 0 = not_specified */
3591 +       unsigned char   model[40];      /* 0 = not_specified */
3592 +       unsigned char   max_multsect;   /* 0=not_implemented */
3593 +       unsigned char   vendor3;        /* vendor unique */
3594 +       unsigned short  dword_io;       /* 0=not_implemented; 1=implemented */
3595 +       unsigned char   vendor4;        /* vendor unique */
3596 +       unsigned char   capability;     /* (upper byte of word 49)
3597 +                                        *  3:  IORDYsup
3598 +                                        *  2:  IORDYsw
3599 +                                        *  1:  LBA
3600 +                                        *  0:  DMA
3601 +                                        */
3602 +       unsigned short  reserved50;     /* reserved (word 50) */
3603 +       unsigned char   vendor5;        /* Obsolete, vendor unique */
3604 +       unsigned char   tPIO;           /* Obsolete, 0=slow, 1=medium, 2=fast */
3605 +       unsigned char   vendor6;        /* Obsolete, vendor unique */
3606 +       unsigned char   tDMA;           /* Obsolete, 0=slow, 1=medium, 2=fast */
3607 +       unsigned short  field_valid;    /* (word 53)
3608 +                                        *  2:  ultra_ok        word  88
3609 +                                        *  1:  eide_ok         words 64-70
3610 +                                        *  0:  cur_ok          words 54-58
3611 +                                        */
3612 +       unsigned short  cur_cyls;       /* Obsolete, logical cylinders */
3613 +       unsigned short  cur_heads;      /* Obsolete, l heads */
3614 +       unsigned short  cur_sectors;    /* Obsolete, l sectors per track */
3615 +       unsigned short  cur_capacity0;  /* Obsolete, l total sectors on drive */
3616 +       unsigned short  cur_capacity1;  /* Obsolete, (2 words, misaligned int)     */
3617 +       unsigned char   multsect;       /* current multiple sector count */
3618 +       unsigned char   multsect_valid; /* when (bit0==1) multsect is ok */
3619 +       unsigned int    lba_capacity;   /* Obsolete, total number of sectors */
3620 +       unsigned short  dma_1word;      /* Obsolete, single-word dma info */
3621 +       unsigned short  dma_mword;      /* multiple-word dma info */
3622 +       unsigned short  eide_pio_modes; /* bits 0:mode3 1:mode4 */
3623 +       unsigned short  eide_dma_min;   /* min mword dma cycle time (ns) */
3624 +       unsigned short  eide_dma_time;  /* recommended mword dma cycle time (ns) */
3625 +       unsigned short  eide_pio;       /* min cycle time (ns), no IORDY  */
3626 +       unsigned short  eide_pio_iordy; /* min cycle time (ns), with IORDY */
3627 +       unsigned short  words69_70[2];  /* reserved words 69-70
3628 +                                        * future command overlap and queuing
3629 +                                        */
3630 +       /* HDIO_GET_IDENTITY currently returns only words 0 through 70 */
3631 +       unsigned short  words71_74[4];  /* reserved words 71-74
3632 +                                        * for IDENTIFY PACKET DEVICE command
3633 +                                        */
3634 +       unsigned short  queue_depth;    /* (word 75)
3635 +                                        * 15:5 reserved
3636 +                                        *  4:0 Maximum queue depth -1
3637 +                                        */
3638 +       unsigned short  words76_79[4];  /* reserved words 76-79 */
3639 +       unsigned short  major_rev_num;  /* (word 80) */
3640 +       unsigned short  minor_rev_num;  /* (word 81) */
3641 +       unsigned short  command_set_1;  /* (word 82) supported
3642 +                                        * 15:  Obsolete
3643 +                                        * 14:  NOP command
3644 +                                        * 13:  READ_BUFFER
3645 +                                        * 12:  WRITE_BUFFER
3646 +                                        * 11:  Obsolete
3647 +                                        * 10:  Host Protected Area
3648 +                                        *  9:  DEVICE Reset
3649 +                                        *  8:  SERVICE Interrupt
3650 +                                        *  7:  Release Interrupt
3651 +                                        *  6:  look-ahead
3652 +                                        *  5:  write cache
3653 +                                        *  4:  PACKET Command
3654 +                                        *  3:  Power Management Feature Set
3655 +                                        *  2:  Removable Feature Set
3656 +                                        *  1:  Security Feature Set
3657 +                                        *  0:  SMART Feature Set
3658 +                                        */
3659 +       unsigned short  command_set_2;  /* (word 83)
3660 +                                        * 15:  Shall be ZERO
3661 +                                        * 14:  Shall be ONE
3662 +                                        * 13:  FLUSH CACHE EXT
3663 +                                        * 12:  FLUSH CACHE
3664 +                                        * 11:  Device Configuration Overlay
3665 +                                        * 10:  48-bit Address Feature Set
3666 +                                        *  9:  Automatic Acoustic Management
3667 +                                        *  8:  SET MAX security
3668 +                                        *  7:  reserved 1407DT PARTIES
3669 +                                        *  6:  SetF sub-command Power-Up
3670 +                                        *  5:  Power-Up in Standby Feature Set
3671 +                                        *  4:  Removable Media Notification
3672 +                                        *  3:  APM Feature Set
3673 +                                        *  2:  CFA Feature Set
3674 +                                        *  1:  READ/WRITE DMA QUEUED
3675 +                                        *  0:  Download MicroCode
3676 +                                        */
3677 +       unsigned short  cfsse;          /* (word 84)
3678 +                                        * cmd set-feature supported extensions
3679 +                                        * 15:  Shall be ZERO
3680 +                                        * 14:  Shall be ONE
3681 +                                        * 13:6 reserved
3682 +                                        *  5:  General Purpose Logging
3683 +                                        *  4:  Streaming Feature Set
3684 +                                        *  3:  Media Card Pass Through
3685 +                                        *  2:  Media Serial Number Valid
3686 +                                        *  1:  SMART selt-test supported
3687 +                                        *  0:  SMART error logging
3688 +                                        */
3689 +       unsigned short  cfs_enable_1;   /* (word 85)
3690 +                                        * command set-feature enabled
3691 +                                        * 15:  Obsolete
3692 +                                        * 14:  NOP command
3693 +                                        * 13:  READ_BUFFER
3694 +                                        * 12:  WRITE_BUFFER
3695 +                                        * 11:  Obsolete
3696 +                                        * 10:  Host Protected Area
3697 +                                        *  9:  DEVICE Reset
3698 +                                        *  8:  SERVICE Interrupt
3699 +                                        *  7:  Release Interrupt
3700 +                                        *  6:  look-ahead
3701 +                                        *  5:  write cache
3702 +                                        *  4:  PACKET Command
3703 +                                        *  3:  Power Management Feature Set
3704 +                                        *  2:  Removable Feature Set
3705 +                                        *  1:  Security Feature Set
3706 +                                        *  0:  SMART Feature Set
3707 +                                        */
3708 +       unsigned short  cfs_enable_2;   /* (word 86)
3709 +                                        * command set-feature enabled
3710 +                                        * 15:  Shall be ZERO
3711 +                                        * 14:  Shall be ONE
3712 +                                        * 13:  FLUSH CACHE EXT
3713 +                                        * 12:  FLUSH CACHE
3714 +                                        * 11:  Device Configuration Overlay
3715 +                                        * 10:  48-bit Address Feature Set
3716 +                                        *  9:  Automatic Acoustic Management
3717 +                                        *  8:  SET MAX security
3718 +                                        *  7:  reserved 1407DT PARTIES
3719 +                                        *  6:  SetF sub-command Power-Up
3720 +                                        *  5:  Power-Up in Standby Feature Set
3721 +                                        *  4:  Removable Media Notification
3722 +                                        *  3:  APM Feature Set
3723 +                                        *  2:  CFA Feature Set
3724 +                                        *  1:  READ/WRITE DMA QUEUED
3725 +                                        *  0:  Download MicroCode
3726 +                                        */
3727 +       unsigned short  csf_default;    /* (word 87)
3728 +                                        * command set-feature default
3729 +                                        * 15:  Shall be ZERO
3730 +                                        * 14:  Shall be ONE
3731 +                                        * 13:6 reserved
3732 +                                        *  5:  General Purpose Logging enabled
3733 +                                        *  4:  Valid CONFIGURE STREAM executed
3734 +                                        *  3:  Media Card Pass Through enabled
3735 +                                        *  2:  Media Serial Number Valid
3736 +                                        *  1:  SMART selt-test supported
3737 +                                        *  0:  SMART error logging
3738 +                                        */
3739 +       unsigned short  dma_ultra;      /* (word 88) */
3740 +       unsigned short  trseuc;         /* time required for security erase */
3741 +       unsigned short  trsEuc;         /* time required for enhanced erase */
3742 +       unsigned short  CurAPMvalues;   /* current APM values */
3743 +       unsigned short  mprc;           /* master password revision code */
3744 +       unsigned short  hw_config;      /* hardware config (word 93)
3745 +                                        * 15:  Shall be ZERO
3746 +                                        * 14:  Shall be ONE
3747 +                                        * 13:
3748 +                                        * 12:
3749 +                                        * 11:
3750 +                                        * 10:
3751 +                                        *  9:
3752 +                                        *  8:
3753 +                                        *  7:
3754 +                                        *  6:
3755 +                                        *  5:
3756 +                                        *  4:
3757 +                                        *  3:
3758 +                                        *  2:
3759 +                                        *  1:
3760 +                                        *  0:  Shall be ONE
3761 +                                        */
3762 +       unsigned short  acoustic;       /* (word 94)
3763 +                                        * 15:8 Vendor's recommended value
3764 +                                        *  7:0 current value
3765 +                                        */
3766 +       unsigned short  msrqs;          /* min stream request size */
3767 +       unsigned short  sxfert;         /* stream transfer time */
3768 +       unsigned short  sal;            /* stream access latency */
3769 +       unsigned int    spg;            /* stream performance granularity */
3770 +       unsigned long long lba_capacity_2;/* 48-bit total number of sectors */
3771 +       unsigned short  words104_125[22];/* reserved words 104-125 */
3772 +       unsigned short  last_lun;       /* (word 126) */
3773 +       unsigned short  word127;        /* (word 127) Feature Set
3774 +                                        * Removable Media Notification
3775 +                                        * 15:2 reserved
3776 +                                        *  1:0 00 = not supported
3777 +                                        *      01 = supported
3778 +                                        *      10 = reserved
3779 +                                        *      11 = reserved
3780 +                                        */
3781 +       unsigned short  dlf;            /* (word 128)
3782 +                                        * device lock function
3783 +                                        * 15:9 reserved
3784 +                                        *  8   security level 1:max 0:high
3785 +                                        *  7:6 reserved
3786 +                                        *  5   enhanced erase
3787 +                                        *  4   expire
3788 +                                        *  3   frozen
3789 +                                        *  2   locked
3790 +                                        *  1   en/disabled
3791 +                                        *  0   capability
3792 +                                        */
3793 +       unsigned short  csfo;           /*  (word 129)
3794 +                                        * current set features options
3795 +                                        * 15:4 reserved
3796 +                                        *  3:  auto reassign
3797 +                                        *  2:  reverting
3798 +                                        *  1:  read-look-ahead
3799 +                                        *  0:  write cache
3800 +                                        */
3801 +       unsigned short  words130_155[26];/* reserved vendor words 130-155 */
3802 +       unsigned short  word156;        /* reserved vendor word 156 */
3803 +       unsigned short  words157_159[3];/* reserved vendor words 157-159 */
3804 +       unsigned short  cfa_power;      /* (word 160) CFA Power Mode
3805 +                                        * 15 word 160 supported
3806 +                                        * 14 reserved
3807 +                                        * 13
3808 +                                        * 12
3809 +                                        * 11:0
3810 +                                        */
3811 +       unsigned short  words161_175[15];/* Reserved for CFA */
3812 +       unsigned short  words176_205[30];/* Current Media Serial Number */
3813 +       unsigned short  words206_254[49];/* reserved words 206-254 */
3814 +       unsigned short  integrity_word; /* (word 255)
3815 +                                        * 15:8 Checksum
3816 +                                        *  7:0 Signature
3817 +                                        */
3818 +};
3819 +
3820 +/*
3821 + * IDE "nice" flags. These are used on a per drive basis to determine
3822 + * when to be nice and give more bandwidth to the other devices which
3823 + * share the same IDE bus.
3824 + */
3825 +#define IDE_NICE_DSC_OVERLAP   (0)     /* per the DSC overlap protocol */
3826 +#define IDE_NICE_ATAPI_OVERLAP (1)     /* not supported yet */
3827 +#define IDE_NICE_0             (2)     /* when sure that it won't affect us */
3828 +#define IDE_NICE_1             (3)     /* when probably won't affect us much */
3829 +#define IDE_NICE_2             (4)     /* when we know it's on our expense */
3830 +
3831 +#ifdef __KERNEL__
3832 +/*
3833 + * These routines are used for kernel command line parameters from main.c:
3834 + */
3835 +#include <linux/config.h>
3836 +
3837 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
3838 +int ide_register(int io_port, int ctl_port, int irq);
3839 +int ide_unregister(unsigned int);
3840 +#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
3841 +
3842 +#endif  /* __KERNEL__ */
3843 +
3844 +#endif /* _LINUX_HDREG_H */
3845 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/ioctl.h lilo-22.5.9/kernel-headers/linux/ioctl.h
3846 --- lilo-22.5.9-orig/kernel-headers/linux/ioctl.h       1970-01-01 01:00:00.000000000 +0100
3847 +++ lilo-22.5.9/kernel-headers/linux/ioctl.h    2004-07-10 02:59:15.000000000 +0200
3848 @@ -0,0 +1,7 @@
3849 +#ifndef _LINUX_IOCTL_H
3850 +#define _LINUX_IOCTL_H
3851 +
3852 +#include <asm/ioctl.h>
3853 +
3854 +#endif /* _LINUX_IOCTL_H */
3855 +
3856 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/lvm.h lilo-22.5.9/kernel-headers/linux/lvm.h
3857 --- lilo-22.5.9-orig/kernel-headers/linux/lvm.h 1970-01-01 01:00:00.000000000 +0100
3858 +++ lilo-22.5.9/kernel-headers/linux/lvm.h      2004-07-10 02:59:15.000000000 +0200
3859 @@ -0,0 +1,756 @@
3860 +/*
3861 + * include/linux/lvm.h
3862 + * kernel/lvm.h
3863 + * tools/lib/lvm.h
3864 + *
3865 + * Copyright (C) 1997 - 2002  Heinz Mauelshagen, Sistina Software
3866 + *
3867 + * February-November 1997
3868 + * May-July 1998
3869 + * January-March,July,September,October,Dezember 1999
3870 + * January,February,July,November 2000
3871 + * January-March,June,July 2001
3872 + * May 2002
3873 + *
3874 + * lvm is free software; you can redistribute it and/or modify
3875 + * it under the terms of the GNU General Public License as published by
3876 + * the Free Software Foundation; either version 2, or (at your option)
3877 + * any later version.
3878 + *
3879 + * lvm is distributed in the hope that it will be useful,
3880 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3881 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3882 + * GNU General Public License for more details.
3883 + *
3884 + * You should have received a copy of the GNU General Public License
3885 + * along with GNU CC; see the file COPYING.  If not, write to
3886 + * the Free Software Foundation, 59 Temple Place - Suite 330,
3887 + * Boston, MA 02111-1307, USA.
3888 + *
3889 + */
3890 +
3891 +/*
3892 + * Changelog
3893 + *
3894 + *    10/10/1997 - beginning of new structure creation
3895 + *    12/05/1998 - incorporated structures from lvm_v1.h and deleted lvm_v1.h
3896 + *    07/06/1998 - avoided LVM_KMALLOC_MAX define by using vmalloc/vfree
3897 + *                 instead of kmalloc/kfree
3898 + *    01/07/1998 - fixed wrong LVM_MAX_SIZE
3899 + *    07/07/1998 - extended pe_t structure by ios member (for statistic)
3900 + *    02/08/1998 - changes for official char/block major numbers
3901 + *    07/08/1998 - avoided init_module() and cleanup_module() to be static
3902 + *    29/08/1998 - seprated core and disk structure type definitions
3903 + *    01/09/1998 - merged kernel integration version (mike)
3904 + *    20/01/1999 - added LVM_PE_DISK_OFFSET macro for use in
3905 + *                 vg_read_with_pv_and_lv(), pv_move_pe(), pv_show_pe_text()...
3906 + *    18/02/1999 - added definition of time_disk_t structure for;
3907 + *                 keeps time stamps on disk for nonatomic writes (future)
3908 + *    15/03/1999 - corrected LV() and VG() macro definition to use argument
3909 + *                 instead of minor
3910 + *    03/07/1999 - define for genhd.c name handling
3911 + *    23/07/1999 - implemented snapshot part
3912 + *    08/12/1999 - changed LVM_LV_SIZE_MAX macro to reflect current 1TB limit
3913 + *    01/01/2000 - extended lv_v2 core structure by wait_queue member
3914 + *    12/02/2000 - integrated Andrea Arcagnelli's snapshot work
3915 + *    18/02/2000 - seperated user and kernel space parts by
3916 + *                 #ifdef them with __KERNEL__
3917 + *    08/03/2000 - implemented cluster/shared bits for vg_access
3918 + *    26/06/2000 - implemented snapshot persistency and resizing support
3919 + *    02/11/2000 - added hash table size member to lv structure
3920 + *    12/11/2000 - removed unneeded timestamp definitions
3921 + *    24/12/2000 - removed LVM_TO_{CORE,DISK}*, use cpu_{from, to}_le*
3922 + *                 instead - Christoph Hellwig
3923 + *    22/01/2001 - Change ulong to uint32_t
3924 + *    14/02/2001 - changed LVM_SNAPSHOT_MIN_CHUNK to 1 page
3925 + *    20/02/2001 - incremented IOP version to 11 because of incompatible
3926 + *                 change in VG activation (in order to support devfs better)
3927 + *    01/03/2001 - Revert to IOP10 and add VG_CREATE_OLD call for compatibility
3928 + *    08/03/2001 - new lv_t (in core) version number 5: changed page member
3929 + *                 to (struct kiobuf *) to use for COW exception table io
3930 + *    26/03/2001 - changed lv_v4 to lv_v5 in structure definition (HM)
3931 + *    21/06/2001 - changed BLOCK_SIZE back to 1024 for non S/390
3932 + *    22/06/2001 - added Andreas Dilger's PE on 4k boundary alignment enhancements
3933 + *    19/07/2001 - added rwsem compatibility macros for 2.2 kernels
3934 + *    13/11/2001 - reduced userspace inclusion of kernel headers to a minimum
3935 + *
3936 + */
3937 +
3938 +
3939 +#ifndef _LVM_H_INCLUDE
3940 +#define _LVM_H_INCLUDE
3941 +
3942 +#define LVM_RELEASE_NAME "1.0.5+"
3943 +#define LVM_RELEASE_DATE "22/07/2002"
3944 +
3945 +#define        _LVM_KERNEL_H_VERSION   "LVM "LVM_RELEASE_NAME" ("LVM_RELEASE_DATE")"
3946 +
3947 +#include <linux/version.h>
3948 +
3949 +/*
3950 + * preprocessor definitions
3951 + */
3952 +/* if you like emergency reset code in the driver */
3953 +#define        LVM_TOTAL_RESET
3954 +
3955 +#ifdef __KERNEL__
3956 +#undef LVM_HD_NAME /* display nice names in /proc/partitions */
3957 +
3958 +/* lots of debugging output (see driver source)
3959 +   #define DEBUG_LVM_GET_INFO
3960 +   #define DEBUG
3961 +   #define DEBUG_MAP
3962 +   #define DEBUG_MAP_SIZE
3963 +   #define DEBUG_IOCTL
3964 +   #define DEBUG_READ
3965 +   #define DEBUG_GENDISK
3966 +   #define DEBUG_VG_CREATE
3967 +   #define DEBUG_DEVICE
3968 +   #define DEBUG_KFREE
3969 + */
3970 +
3971 +#include <linux/kdev_t.h>
3972 +#include <linux/list.h>
3973 +#include <asm/types.h>
3974 +#include <linux/major.h>
3975 +#else
3976 +/* This prevents the need to include <linux/list.h> which
3977 +   causes problems on some platforms. It's not nice but then
3978 +   neither is the alternative. */
3979 +struct list_head {
3980 +        struct list_head *next, *prev;
3981 +};
3982 +#define __KERNEL__
3983 +#include <linux/kdev_t.h>
3984 +#undef __KERNEL__
3985 +#endif                         /* #ifndef __KERNEL__ */
3986 +
3987 +
3988 +#ifdef __KERNEL__
3989 +#include <linux/spinlock.h>
3990 +
3991 +#include <asm/semaphore.h>
3992 +#endif                         /* #ifdef __KERNEL__ */
3993 +
3994 +
3995 +#include <asm/page.h>
3996 +
3997 +#if !defined ( LVM_BLK_MAJOR) || !defined ( LVM_CHAR_MAJOR)
3998 +#error Bad include/linux/major.h - LVM MAJOR undefined
3999 +#endif
4000 +
4001 +#ifdef BLOCK_SIZE
4002 +#undef BLOCK_SIZE
4003 +#endif
4004 +
4005 +#ifdef CONFIG_ARCH_S390
4006 +#define BLOCK_SIZE     4096
4007 +#else
4008 +#define BLOCK_SIZE     1024
4009 +#endif
4010 +
4011 +#ifndef        SECTOR_SIZE
4012 +#define SECTOR_SIZE    512
4013 +#endif
4014 +
4015 +/* structure version */
4016 +#define LVM_STRUCT_VERSION 1
4017 +
4018 +#define        LVM_DIR_PREFIX  "/dev/"
4019 +
4020 +/*
4021 + * i/o protocol version
4022 + *
4023 + * defined here for the driver and defined seperate in the
4024 + * user land tools/lib/liblvm.h
4025 + *
4026 + */
4027 +#define        LVM_DRIVER_IOP_VERSION          10
4028 +
4029 +#define LVM_NAME        "lvm"
4030 +#define LVM_GLOBAL     "global"
4031 +#define LVM_DIR                "lvm"
4032 +#define LVM_VG_SUBDIR  "VGs"
4033 +#define LVM_LV_SUBDIR  "LVs"
4034 +#define LVM_PV_SUBDIR  "PVs"
4035 +
4036 +/*
4037 + * VG/LV indexing macros
4038 + */
4039 +/* character minor maps directly to volume group */
4040 +#define        VG_CHR(a) ( a)
4041 +
4042 +/* block minor indexes into a volume group/logical volume indirection table */
4043 +#define        VG_BLK(a)       ( vg_lv_map[a].vg_number)
4044 +#define LV_BLK(a)      ( vg_lv_map[a].lv_number)
4045 +
4046 +/*
4047 + * absolute limits for VGs, PVs per VG and LVs per VG
4048 + */
4049 +#define ABS_MAX_VG     99
4050 +#define ABS_MAX_PV     256
4051 +#define ABS_MAX_LV     256     /* caused by 8 bit minor */
4052 +
4053 +#define MAX_VG  ABS_MAX_VG
4054 +#define MAX_LV ABS_MAX_LV
4055 +#define        MAX_PV  ABS_MAX_PV
4056 +
4057 +#if ( MAX_VG > ABS_MAX_VG)
4058 +#undef MAX_VG
4059 +#define MAX_VG ABS_MAX_VG
4060 +#endif
4061 +
4062 +#if ( MAX_LV > ABS_MAX_LV)
4063 +#undef MAX_LV
4064 +#define MAX_LV ABS_MAX_LV
4065 +#endif
4066 +
4067 +
4068 +/*
4069 + * VGDA: default disk spaces and offsets
4070 + *
4071 + *   there's space after the structures for later extensions.
4072 + *
4073 + *   offset            what                                size
4074 + *   ---------------   ----------------------------------  ------------
4075 + *   0                 physical volume structure           ~500 byte
4076 + *
4077 + *   1K                volume group structure              ~200 byte
4078 + *
4079 + *   6K                namelist of physical volumes        128 byte each
4080 + *
4081 + *   6k + n * ~300byte n logical volume structures         ~300 byte each
4082 + *
4083 + *   + m * 4byte       m physical extent alloc. structs    4 byte each
4084 + *
4085 + *   End of disk -     first physical extent               typically 4 megabyte
4086 + *   PE total *
4087 + *   PE size
4088 + *
4089 + *
4090 + */
4091 +
4092 +/* DONT TOUCH THESE !!! */
4093 +
4094 +
4095 +
4096 +
4097 +
4098 +
4099 +
4100 +/*
4101 + * LVM_PE_T_MAX corresponds to:
4102 + *
4103 + * 8KB PE size can map a ~512 MB logical volume at the cost of 1MB memory,
4104 + *
4105 + * 128MB PE size can map a 8TB logical volume at the same cost of memory.
4106 + *
4107 + * Default PE size of 4 MB gives a maximum logical volume size of 256 GB.
4108 + *
4109 + * Maximum PE size of 16GB gives a maximum logical volume size of 1024 TB.
4110 + *
4111 + * AFAIK, the actual kernels limit this to 1 TB.
4112 + *
4113 + * Should be a sufficient spectrum ;*)
4114 + */
4115 +
4116 +/* This is the usable size of pe_disk_t.le_num !!!        v     v */
4117 +#define        LVM_PE_T_MAX            ( ( 1 << ( sizeof ( uint16_t) * 8)) - 2)
4118 +
4119 +#define        LVM_LV_SIZE_MAX(a)      ( ( long long) LVM_PE_T_MAX * (a)->pe_size > ( long long) 1024*1024/SECTOR_SIZE*1024*1024 ? ( long long) 1024*1024/SECTOR_SIZE*1024*1024 : ( long long) LVM_PE_T_MAX * (a)->pe_size)
4120 +#define        LVM_MIN_PE_SIZE         ( 8192L / SECTOR_SIZE) /* 8 KB in sectors */
4121 +#define        LVM_MAX_PE_SIZE         ( 16L * 1024L * 1024L / SECTOR_SIZE * 1024)     /* 16GB in sectors */
4122 +#define        LVM_DEFAULT_PE_SIZE     ( 4096L * 1024 / SECTOR_SIZE)   /* 4 MB in sectors */
4123 +#define        LVM_DEFAULT_STRIPE_SIZE 16L     /* 16 KB  */
4124 +#define        LVM_MIN_STRIPE_SIZE     ( PAGE_SIZE/SECTOR_SIZE)        /* PAGESIZE in sectors */
4125 +#define        LVM_MAX_STRIPE_SIZE     ( 512L * 1024 / SECTOR_SIZE)    /* 512 KB in sectors */
4126 +#define        LVM_MAX_STRIPES         128     /* max # of stripes */
4127 +#define        LVM_MAX_SIZE            ( 1024LU * 1024 / SECTOR_SIZE * 1024 * 1024)    /* 1TB[sectors] */
4128 +#define        LVM_MAX_MIRRORS         2       /* future use */
4129 +#define        LVM_MIN_READ_AHEAD      0       /* minimum read ahead sectors */
4130 +#define        LVM_DEFAULT_READ_AHEAD  1024    /* sectors for 512k scsi segments */
4131 +#define        LVM_MAX_READ_AHEAD      1024    /* maximum read ahead sectors */
4132 +#define        LVM_MAX_LV_IO_TIMEOUT   60      /* seconds I/O timeout (future use) */
4133 +#define        LVM_PARTITION           0xfe    /* LVM partition id */
4134 +#define        LVM_NEW_PARTITION       0x8e    /* new LVM partition id (10/09/1999) */
4135 +#define        LVM_PE_SIZE_PV_SIZE_REL 5       /* max relation PV size and PE size */
4136 +
4137 +#define        LVM_SNAPSHOT_MAX_CHUNK  1024    /* 1024 KB */
4138 +#define        LVM_SNAPSHOT_DEF_CHUNK  64      /* 64  KB */
4139 +#define        LVM_SNAPSHOT_MIN_CHUNK  (PAGE_SIZE/1024)        /* 4 or 8 KB */
4140 +
4141 +#define        UNDEF   -1
4142 +
4143 +/*
4144 + * ioctls
4145 + * FIXME: the last parameter to _IO{W,R,WR} is a data type.  The macro will
4146 + *       expand this using sizeof(), so putting "1" there is misleading
4147 + *       because sizeof(1) = sizeof(int) = sizeof(2) = 4 on a 32-bit machine!
4148 + */
4149 +/* volume group */
4150 +#define        VG_CREATE_OLD           _IOW ( 0xfe, 0x00, 1)
4151 +#define        VG_REMOVE               _IOW ( 0xfe, 0x01, 1)
4152 +
4153 +#define        VG_EXTEND               _IOW ( 0xfe, 0x03, 1)
4154 +#define        VG_REDUCE               _IOW ( 0xfe, 0x04, 1)
4155 +
4156 +#define        VG_STATUS               _IOWR ( 0xfe, 0x05, 1)
4157 +#define        VG_STATUS_GET_COUNT     _IOWR ( 0xfe, 0x06, 1)
4158 +#define        VG_STATUS_GET_NAMELIST  _IOWR ( 0xfe, 0x07, 1)
4159 +
4160 +#define        VG_SET_EXTENDABLE       _IOW ( 0xfe, 0x08, 1)
4161 +#define        VG_RENAME               _IOW ( 0xfe, 0x09, 1)
4162 +
4163 +/* Since 0.9beta6 */
4164 +#define        VG_CREATE               _IOW ( 0xfe, 0x0a, 1)
4165 +
4166 +/* logical volume */
4167 +#define        LV_CREATE               _IOW ( 0xfe, 0x20, 1)
4168 +#define        LV_REMOVE               _IOW ( 0xfe, 0x21, 1)
4169 +
4170 +#define        LV_ACTIVATE             _IO ( 0xfe, 0x22)
4171 +#define        LV_DEACTIVATE           _IO ( 0xfe, 0x23)
4172 +
4173 +#define        LV_EXTEND               _IOW ( 0xfe, 0x24, 1)
4174 +#define        LV_REDUCE               _IOW ( 0xfe, 0x25, 1)
4175 +
4176 +#define        LV_STATUS_BYNAME        _IOWR ( 0xfe, 0x26, 1)
4177 +#define        LV_STATUS_BYINDEX       _IOWR ( 0xfe, 0x27, 1)
4178 +
4179 +#define LV_SET_ACCESS           _IOW ( 0xfe, 0x28, 1)
4180 +#define LV_SET_ALLOCATION       _IOW ( 0xfe, 0x29, 1)
4181 +#define LV_SET_STATUS           _IOW ( 0xfe, 0x2a, 1)
4182 +
4183 +#define LE_REMAP                _IOW ( 0xfe, 0x2b, 1)
4184 +
4185 +#define LV_SNAPSHOT_USE_RATE    _IOWR ( 0xfe, 0x2c, 1)
4186 +
4187 +#define        LV_STATUS_BYDEV         _IOWR ( 0xfe, 0x2e, 1)
4188 +
4189 +#define        LV_RENAME               _IOW ( 0xfe, 0x2f, 1)
4190 +
4191 +#define        LV_BMAP                 _IOWR ( 0xfe, 0x30, 1)
4192 +
4193 +
4194 +/* physical volume */
4195 +#define        PV_STATUS               _IOWR ( 0xfe, 0x40, 1)
4196 +#define        PV_CHANGE               _IOWR ( 0xfe, 0x41, 1)
4197 +#define        PV_FLUSH                _IOW ( 0xfe, 0x42, 1)
4198 +
4199 +/* physical extent */
4200 +#define        PE_LOCK_UNLOCK          _IOW ( 0xfe, 0x50, 1)
4201 +
4202 +/* i/o protocol version */
4203 +#define        LVM_GET_IOP_VERSION     _IOR ( 0xfe, 0x98, 1)
4204 +
4205 +#ifdef LVM_TOTAL_RESET
4206 +/* special reset function for testing purposes */
4207 +#define        LVM_RESET               _IO ( 0xfe, 0x99)
4208 +#endif
4209 +
4210 +/* lock the logical volume manager */
4211 +#if LVM_DRIVER_IOP_VERSION > 11
4212 +#define        LVM_LOCK_LVM            _IO ( 0xfe, 0x9A)
4213 +#else
4214 +/* This is actually the same as _IO ( 0xff, 0x00), oops.  Remove for IOP 12+ */
4215 +#define        LVM_LOCK_LVM            _IO ( 0xfe, 0x100)
4216 +#endif
4217 +/* END ioctls */
4218 +
4219 +
4220 +/*
4221 + * Status flags
4222 + */
4223 +/* volume group */
4224 +#define        VG_ACTIVE            0x01       /* vg_status */
4225 +#define        VG_EXPORTED          0x02       /*     "     */
4226 +#define        VG_EXTENDABLE        0x04       /*     "     */
4227 +
4228 +#define        VG_READ              0x01       /* vg_access */
4229 +#define        VG_WRITE             0x02       /*     "     */
4230 +#define        VG_CLUSTERED         0x04       /*     "     */
4231 +#define        VG_SHARED            0x08       /*     "     */
4232 +
4233 +/* logical volume */
4234 +#define        LV_ACTIVE            0x01       /* lv_status */
4235 +#define        LV_SPINDOWN          0x02       /*     "     */
4236 +
4237 +#define        LV_READ              0x01       /* lv_access */
4238 +#define        LV_WRITE             0x02       /*     "     */
4239 +#define        LV_SNAPSHOT          0x04       /*     "     */
4240 +#define        LV_SNAPSHOT_ORG      0x08       /*     "     */
4241 +
4242 +#define        LV_BADBLOCK_ON       0x01       /* lv_badblock */
4243 +
4244 +#define        LV_STRICT            0x01       /* lv_allocation */
4245 +#define        LV_CONTIGUOUS        0x02       /*       "       */
4246 +
4247 +/* physical volume */
4248 +#define        PV_ACTIVE            0x01       /* pv_status */
4249 +#define        PV_ALLOCATABLE       0x02       /* pv_allocatable */
4250 +
4251 +
4252 +/* misc */
4253 +#define LVM_SNAPSHOT_DROPPED_SECTOR 1
4254 +
4255 +/*
4256 + * Structure definitions core/disk follow
4257 + *
4258 + * conditional conversion takes place on big endian architectures
4259 + * in functions * pv_copy_*(), vg_copy_*() and lv_copy_*()
4260 + *
4261 + */
4262 +
4263 +#define        NAME_LEN                128     /* don't change!!! */
4264 +#define        UUID_LEN                32      /* don't change!!! */
4265 +
4266 +/* copy on write tables in disk format */
4267 +typedef struct lv_COW_table_disk_v1 {
4268 +       uint64_t pv_org_number;
4269 +       uint64_t pv_org_rsector;
4270 +       uint64_t pv_snap_number;
4271 +       uint64_t pv_snap_rsector;
4272 +} lv_COW_table_disk_t;
4273 +
4274 +/* remap physical sector/rdev pairs including hash */
4275 +typedef struct lv_block_exception_v1 {
4276 +       struct list_head hash;
4277 +       uint32_t rsector_org;
4278 +       kdev_t   rdev_org;
4279 +       uint32_t rsector_new;
4280 +       kdev_t   rdev_new;
4281 +} lv_block_exception_t;
4282 +
4283 +/* disk stored pe information */
4284 +typedef struct {
4285 +       uint16_t lv_num;
4286 +       uint16_t le_num;
4287 +} pe_disk_t;
4288 +
4289 +/* disk stored PV, VG, LV and PE size and offset information */
4290 +typedef struct {
4291 +       uint32_t base;
4292 +       uint32_t size;
4293 +} lvm_disk_data_t;
4294 +
4295 +
4296 +/*
4297 + * physical volume structures
4298 + */
4299 +
4300 +/* core */
4301 +typedef struct pv_v2 {
4302 +       char id[2];             /* Identifier */
4303 +       unsigned short version; /* HM lvm version */
4304 +       lvm_disk_data_t pv_on_disk;
4305 +       lvm_disk_data_t vg_on_disk;
4306 +       lvm_disk_data_t pv_uuidlist_on_disk;
4307 +       lvm_disk_data_t lv_on_disk;
4308 +       lvm_disk_data_t pe_on_disk;
4309 +       char pv_name[NAME_LEN];
4310 +       char vg_name[NAME_LEN];
4311 +       char system_id[NAME_LEN];       /* for vgexport/vgimport */
4312 +       kdev_t pv_dev;
4313 +       uint pv_number;
4314 +       uint pv_status;
4315 +       uint pv_allocatable;
4316 +       uint pv_size;           /* HM */
4317 +       uint lv_cur;
4318 +       uint pe_size;
4319 +       uint pe_total;
4320 +       uint pe_allocated;
4321 +       uint pe_stale;          /* for future use */
4322 +       pe_disk_t *pe;          /* HM */
4323 +       struct block_device *bd;
4324 +       char pv_uuid[UUID_LEN+1];
4325 +
4326 +#ifndef __KERNEL__
4327 +       uint32_t pe_start;      /* in sectors */
4328 +#endif
4329 +} pv_t;
4330 +
4331 +
4332 +/* disk */
4333 +typedef struct pv_disk_v2 {
4334 +       uint8_t id[2];          /* Identifier */
4335 +       uint16_t version;               /* HM lvm version */
4336 +       lvm_disk_data_t pv_on_disk;
4337 +       lvm_disk_data_t vg_on_disk;
4338 +       lvm_disk_data_t pv_uuidlist_on_disk;
4339 +       lvm_disk_data_t lv_on_disk;
4340 +       lvm_disk_data_t pe_on_disk;
4341 +       uint8_t pv_uuid[NAME_LEN];
4342 +       uint8_t vg_name[NAME_LEN];
4343 +       uint8_t system_id[NAME_LEN];    /* for vgexport/vgimport */
4344 +       uint32_t pv_major;
4345 +       uint32_t pv_number;
4346 +       uint32_t pv_status;
4347 +       uint32_t pv_allocatable;
4348 +       uint32_t pv_size;               /* HM */
4349 +       uint32_t lv_cur;
4350 +       uint32_t pe_size;
4351 +       uint32_t pe_total;
4352 +       uint32_t pe_allocated;
4353 +       
4354 +       /* new in struct version 2 */
4355 +       uint32_t pe_start;              /* in sectors */
4356 +
4357 +} pv_disk_t;
4358 +
4359 +
4360 +/*
4361 + * Structures for Logical Volume (LV)
4362 + */
4363 +
4364 +/* core PE information */
4365 +typedef struct {
4366 +       kdev_t dev;
4367 +       uint32_t pe;            /* to be changed if > 2TB */
4368 +       uint32_t reads;
4369 +       uint32_t writes;
4370 +} pe_t;
4371 +
4372 +typedef struct {
4373 +       char lv_name[NAME_LEN];
4374 +       kdev_t old_dev;
4375 +       kdev_t new_dev;
4376 +       uint32_t old_pe;
4377 +       uint32_t new_pe;
4378 +} le_remap_req_t;
4379 +
4380 +typedef struct lv_bmap {
4381 +       uint32_t lv_block;
4382 +       dev_t lv_dev;
4383 +} lv_bmap_t;
4384 +
4385 +/*
4386 + * Structure Logical Volume (LV) Version 3
4387 + */
4388 +
4389 +/* core */
4390 +typedef struct lv_v5 {
4391 +       char lv_name[NAME_LEN];
4392 +       char vg_name[NAME_LEN];
4393 +       uint lv_access;
4394 +       uint lv_status;
4395 +       uint lv_open;           /* HM */
4396 +       kdev_t lv_dev;          /* HM */
4397 +       uint lv_number;         /* HM */
4398 +       uint lv_mirror_copies;  /* for future use */
4399 +       uint lv_recovery;       /*       "        */
4400 +       uint lv_schedule;       /*       "        */
4401 +       uint lv_size;
4402 +       pe_t *lv_current_pe;    /* HM */
4403 +       uint lv_current_le;     /* for future use */
4404 +       uint lv_allocated_le;
4405 +       uint lv_stripes;
4406 +       uint lv_stripesize;
4407 +       uint lv_badblock;       /* for future use */
4408 +       uint lv_allocation;
4409 +       uint lv_io_timeout;     /* for future use */
4410 +       uint lv_read_ahead;
4411 +
4412 +       /* delta to version 1 starts here */
4413 +       struct lv_v5 *lv_snapshot_org;
4414 +       struct lv_v5 *lv_snapshot_prev;
4415 +       struct lv_v5 *lv_snapshot_next;
4416 +       lv_block_exception_t *lv_block_exception;
4417 +       uint lv_remap_ptr;
4418 +       uint lv_remap_end;
4419 +       uint lv_chunk_size;
4420 +       uint lv_snapshot_minor;
4421 +#ifdef __KERNEL__
4422 +       struct kiobuf *lv_iobuf;
4423 +       struct kiobuf *lv_COW_table_iobuf;
4424 +       struct rw_semaphore lv_lock;
4425 +       struct list_head *lv_snapshot_hash_table;
4426 +       uint32_t lv_snapshot_hash_table_size;
4427 +       uint32_t lv_snapshot_hash_mask;
4428 +       wait_queue_head_t lv_snapshot_wait;
4429 +       int     lv_snapshot_use_rate;
4430 +       struct vg_v3    *vg;
4431 +
4432 +       uint lv_allocated_snapshot_le;
4433 +#else
4434 +       char dummy[200];
4435 +#endif
4436 +} lv_t;
4437 +
4438 +/* disk */
4439 +typedef struct lv_disk_v3 {
4440 +       uint8_t lv_name[NAME_LEN];
4441 +       uint8_t vg_name[NAME_LEN];
4442 +       uint32_t lv_access;
4443 +       uint32_t lv_status;
4444 +       uint32_t lv_open;               /* HM */
4445 +       uint32_t lv_dev;                /* HM */
4446 +       uint32_t lv_number;     /* HM */
4447 +       uint32_t lv_mirror_copies;      /* for future use */
4448 +       uint32_t lv_recovery;   /*       "        */
4449 +       uint32_t lv_schedule;   /*       "        */
4450 +       uint32_t lv_size;
4451 +       uint32_t lv_snapshot_minor;/* minor number of original */
4452 +       uint16_t lv_chunk_size; /* chunk size of snapshot */
4453 +       uint16_t dummy;
4454 +       uint32_t lv_allocated_le;
4455 +       uint32_t lv_stripes;
4456 +       uint32_t lv_stripesize;
4457 +       uint32_t lv_badblock;   /* for future use */
4458 +       uint32_t lv_allocation;
4459 +       uint32_t lv_io_timeout; /* for future use */
4460 +       uint32_t lv_read_ahead; /* HM */
4461 +} lv_disk_t;
4462 +
4463 +/*
4464 + * Structure Volume Group (VG) Version 1
4465 + */
4466 +
4467 +/* core */
4468 +typedef struct vg_v3 {
4469 +       char vg_name[NAME_LEN]; /* volume group name */
4470 +       uint vg_number;         /* volume group number */
4471 +       uint vg_access;         /* read/write */
4472 +       uint vg_status;         /* active or not */
4473 +       uint lv_max;            /* maximum logical volumes */
4474 +       uint lv_cur;            /* current logical volumes */
4475 +       uint lv_open;           /* open    logical volumes */
4476 +       uint pv_max;            /* maximum physical volumes */
4477 +       uint pv_cur;            /* current physical volumes FU */
4478 +       uint pv_act;            /* active physical volumes */
4479 +       uint dummy;             /* was obsolete max_pe_per_pv */
4480 +       uint vgda;              /* volume group descriptor arrays FU */
4481 +       uint pe_size;           /* physical extent size in sectors */
4482 +       uint pe_total;          /* total of physical extents */
4483 +       uint pe_allocated;      /* allocated physical extents */
4484 +       uint pvg_total;         /* physical volume groups FU */
4485 +       struct proc_dir_entry *proc;
4486 +       pv_t *pv[ABS_MAX_PV + 1];       /* physical volume struct pointers */
4487 +       lv_t *lv[ABS_MAX_LV + 1];       /* logical  volume struct pointers */
4488 +       char vg_uuid[UUID_LEN+1];       /* volume group UUID */
4489 +#ifdef __KERNEL__
4490 +       struct proc_dir_entry *vg_dir_pde;
4491 +       struct proc_dir_entry *lv_subdir_pde;
4492 +       struct proc_dir_entry *pv_subdir_pde;
4493 +#else
4494 +       char dummy1[200];
4495 +#endif
4496 +} vg_t;
4497 +
4498 +
4499 +/* disk */
4500 +typedef struct vg_disk_v2 {
4501 +       uint8_t vg_uuid[UUID_LEN];      /* volume group UUID */
4502 +       uint8_t vg_name_dummy[NAME_LEN-UUID_LEN];       /* rest of v1 VG name */
4503 +       uint32_t vg_number;     /* volume group number */
4504 +       uint32_t vg_access;     /* read/write */
4505 +       uint32_t vg_status;     /* active or not */
4506 +       uint32_t lv_max;                /* maximum logical volumes */
4507 +       uint32_t lv_cur;                /* current logical volumes */
4508 +       uint32_t lv_open;               /* open    logical volumes */
4509 +       uint32_t pv_max;                /* maximum physical volumes */
4510 +       uint32_t pv_cur;                /* current physical volumes FU */
4511 +       uint32_t pv_act;                /* active physical volumes */
4512 +       uint32_t dummy;
4513 +       uint32_t vgda;          /* volume group descriptor arrays FU */
4514 +       uint32_t pe_size;               /* physical extent size in sectors */
4515 +       uint32_t pe_total;              /* total of physical extents */
4516 +       uint32_t pe_allocated;  /* allocated physical extents */
4517 +       uint32_t pvg_total;     /* physical volume groups FU */
4518 +} vg_disk_t;
4519 +
4520 +
4521 +/*
4522 + * Request structures for ioctls
4523 + */
4524 +
4525 +/* Request structure PV_STATUS_BY_NAME... */
4526 +typedef struct {
4527 +       char pv_name[NAME_LEN];
4528 +       pv_t *pv;
4529 +} pv_status_req_t, pv_change_req_t;
4530 +
4531 +/* Request structure PV_FLUSH */
4532 +typedef struct {
4533 +       char pv_name[NAME_LEN];
4534 +       kdev_t pv_dev;
4535 +} pv_flush_req_t;
4536 +
4537 +
4538 +/* Request structure PE_MOVE */
4539 +typedef struct {
4540 +       enum {
4541 +               LOCK_PE, UNLOCK_PE
4542 +       } lock;
4543 +       struct {
4544 +               kdev_t lv_dev;
4545 +               kdev_t pv_dev;
4546 +               uint32_t pv_offset;
4547 +       } data;
4548 +} pe_lock_req_t;
4549 +
4550 +
4551 +/* Request structure LV_STATUS_BYNAME */
4552 +typedef struct {
4553 +       char lv_name[NAME_LEN];
4554 +       lv_t *lv;
4555 +} lv_status_byname_req_t, lv_req_t;
4556 +
4557 +/* Request structure LV_STATUS_BYINDEX */
4558 +typedef struct {
4559 +       uint32_t lv_index;
4560 +       lv_t *lv;
4561 +       /* Transfer size because user space and kernel space differ */
4562 +       ushort size;
4563 +} lv_status_byindex_req_t;
4564 +
4565 +/* Request structure LV_STATUS_BYDEV... */
4566 +typedef struct {
4567 +       dev_t dev;
4568 +       lv_t *lv;
4569 +} lv_status_bydev_req_t;
4570 +
4571 +
4572 +/* Request structure LV_SNAPSHOT_USE_RATE */
4573 +typedef struct {
4574 +       int     block;
4575 +       int     rate;
4576 +} lv_snapshot_use_rate_req_t;
4577 +
4578 +
4579 +
4580 +/* useful inlines */
4581 +static inline ulong round_up(ulong n, ulong size) {
4582 +       size--;
4583 +       return (n + size) & ~size;
4584 +}
4585 +
4586 +static inline ulong div_up(ulong n, ulong size) {
4587 +       return round_up(n, size) / size;
4588 +}
4589 +
4590 +/* FIXME: nasty capital letters */
4591 +static int inline LVM_GET_COW_TABLE_CHUNKS_PER_PE(vg_t *vg, lv_t *lv) {
4592 +       return vg->pe_size / lv->lv_chunk_size;
4593 +}
4594 +
4595 +static int inline LVM_GET_COW_TABLE_ENTRIES_PER_PE(vg_t *vg, lv_t *lv) {
4596 +       ulong chunks = vg->pe_size / lv->lv_chunk_size;
4597 +       ulong entry_size = sizeof(lv_COW_table_disk_t);
4598 +       ulong chunk_size = lv->lv_chunk_size * SECTOR_SIZE;
4599 +       ulong entries = (vg->pe_size * SECTOR_SIZE) /
4600 +               (entry_size + chunk_size);
4601 +
4602 +       if(chunks < 2)
4603 +               return 0;
4604 +
4605 +       for(; entries; entries--)
4606 +               if((div_up(entries * entry_size, chunk_size) + entries) <=
4607 +                  chunks)
4608 +                       break;
4609 +
4610 +       return entries;
4611 +}
4612 +
4613 +
4614 +#endif                         /* #ifndef _LVM_H_INCLUDE */
4615 +
4616 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/major.h lilo-22.5.9/kernel-headers/linux/major.h
4617 --- lilo-22.5.9-orig/kernel-headers/linux/major.h       1970-01-01 01:00:00.000000000 +0100
4618 +++ lilo-22.5.9/kernel-headers/linux/major.h    2004-07-10 02:59:15.000000000 +0200
4619 @@ -0,0 +1,198 @@
4620 +#ifndef _LINUX_MAJOR_H
4621 +#define _LINUX_MAJOR_H
4622 +
4623 +/*
4624 + * This file has definitions for major device numbers.
4625 + * For the device number assignments, see Documentation/devices.txt.
4626 + */
4627 +
4628 +/* limits */
4629 +
4630 +/*
4631 + * Important: Don't change this to 256.  Major number 255 is and must be
4632 + * reserved for future expansion into a larger dev_t space.
4633 + */
4634 +#define MAX_CHRDEV     255
4635 +#define MAX_BLKDEV     255
4636 +
4637 +#define UNNAMED_MAJOR  0
4638 +#define MEM_MAJOR      1
4639 +#define RAMDISK_MAJOR  1
4640 +#define FLOPPY_MAJOR   2
4641 +#define PTY_MASTER_MAJOR 2
4642 +#define IDE0_MAJOR     3
4643 +#define PTY_SLAVE_MAJOR 3
4644 +#define HD_MAJOR       IDE0_MAJOR
4645 +#define TTY_MAJOR      4
4646 +#define TTYAUX_MAJOR   5
4647 +#define LP_MAJOR       6
4648 +#define VCS_MAJOR      7
4649 +#define LOOP_MAJOR     7
4650 +#define SCSI_DISK0_MAJOR 8
4651 +#define SCSI_TAPE_MAJOR        9
4652 +#define MD_MAJOR        9
4653 +#define MISC_MAJOR     10
4654 +#define SCSI_CDROM_MAJOR 11
4655 +#define        MUX_MAJOR       11      /* PA-RISC only */
4656 +#define QIC02_TAPE_MAJOR 12
4657 +#define XT_DISK_MAJOR  13
4658 +#define SOUND_MAJOR    14
4659 +#define CDU31A_CDROM_MAJOR 15
4660 +#define JOYSTICK_MAJOR 15
4661 +#define GOLDSTAR_CDROM_MAJOR 16
4662 +#define OPTICS_CDROM_MAJOR 17
4663 +#define SANYO_CDROM_MAJOR 18
4664 +#define CYCLADES_MAJOR  19
4665 +#define CYCLADESAUX_MAJOR 20
4666 +#define MITSUMI_X_CDROM_MAJOR 20
4667 +#define MFM_ACORN_MAJOR 21     /* ARM Linux /dev/mfm */
4668 +#define SCSI_GENERIC_MAJOR 21
4669 +#define Z8530_MAJOR 34
4670 +#define DIGI_MAJOR 23
4671 +#define IDE1_MAJOR     22
4672 +#define DIGICU_MAJOR 22
4673 +#define MITSUMI_CDROM_MAJOR 23
4674 +#define CDU535_CDROM_MAJOR 24
4675 +#define STL_SERIALMAJOR 24
4676 +#define MATSUSHITA_CDROM_MAJOR 25
4677 +#define STL_CALLOUTMAJOR 25
4678 +#define MATSUSHITA_CDROM2_MAJOR 26
4679 +#define QIC117_TAPE_MAJOR 27
4680 +#define MATSUSHITA_CDROM3_MAJOR 27
4681 +#define MATSUSHITA_CDROM4_MAJOR 28
4682 +#define STL_SIOMEMMAJOR 28
4683 +#define ACSI_MAJOR     28
4684 +#define AZTECH_CDROM_MAJOR 29
4685 +#define GRAPHDEV_MAJOR 29      /* SparcLinux & Linux/68k /dev/fb */
4686 +#define SHMIQ_MAJOR    85      /* Linux/mips, SGI /dev/shmiq */
4687 +#define CM206_CDROM_MAJOR 32
4688 +#define IDE2_MAJOR     33
4689 +#define IDE3_MAJOR     34
4690 +#define XPRAM_MAJOR     35      /* expanded storage on S/390 = "slow ram" */
4691 +                                /* proposed by Peter                      */
4692 +#define NETLINK_MAJOR  36
4693 +#define PS2ESDI_MAJOR  36
4694 +#define IDETAPE_MAJOR  37
4695 +#define Z2RAM_MAJOR    37
4696 +#define APBLOCK_MAJOR   38   /* AP1000 Block device */
4697 +#define DDV_MAJOR       39   /* AP1000 DDV block device */
4698 +#define NBD_MAJOR      43   /* Network block device    */
4699 +#define RISCOM8_NORMAL_MAJOR 48
4700 +#define DAC960_MAJOR   48      /* 48..55 */
4701 +#define RISCOM8_CALLOUT_MAJOR 49
4702 +#define MKISS_MAJOR    55
4703 +#define DSP56K_MAJOR    55   /* DSP56001 processor device */
4704 +
4705 +#define IDE4_MAJOR     56
4706 +#define IDE5_MAJOR     57
4707 +
4708 +#define LVM_BLK_MAJOR  58      /* Logical Volume Manager */
4709 +
4710 +#define SCSI_DISK1_MAJOR       65
4711 +#define SCSI_DISK2_MAJOR       66
4712 +#define SCSI_DISK3_MAJOR       67
4713 +#define SCSI_DISK4_MAJOR       68
4714 +#define SCSI_DISK5_MAJOR       69
4715 +#define SCSI_DISK6_MAJOR       70
4716 +#define SCSI_DISK7_MAJOR       71
4717 +
4718 +
4719 +#define COMPAQ_SMART2_MAJOR    72
4720 +#define COMPAQ_SMART2_MAJOR1   73
4721 +#define COMPAQ_SMART2_MAJOR2   74
4722 +#define COMPAQ_SMART2_MAJOR3   75
4723 +#define COMPAQ_SMART2_MAJOR4   76
4724 +#define COMPAQ_SMART2_MAJOR5   77
4725 +#define COMPAQ_SMART2_MAJOR6   78
4726 +#define COMPAQ_SMART2_MAJOR7   79
4727 +
4728 +#define SPECIALIX_NORMAL_MAJOR 75
4729 +#define SPECIALIX_CALLOUT_MAJOR 76
4730 +
4731 +#define COMPAQ_CISS_MAJOR      104
4732 +#define COMPAQ_CISS_MAJOR1     105
4733 +#define COMPAQ_CISS_MAJOR2      106
4734 +#define COMPAQ_CISS_MAJOR3      107
4735 +#define COMPAQ_CISS_MAJOR4      108
4736 +#define COMPAQ_CISS_MAJOR5      109
4737 +#define COMPAQ_CISS_MAJOR6      110
4738 +#define COMPAQ_CISS_MAJOR7      111
4739 +
4740 +#define ATARAID_MAJOR          114
4741 +
4742 +#define DASD_MAJOR      94     /* Official assignations from Peter */
4743 +
4744 +#define MDISK_MAJOR     95     /* Official assignations from Peter */
4745 +
4746 +#define I2O_MAJOR              80      /* 80->87 */
4747 +
4748 +#define IDE6_MAJOR     88
4749 +#define IDE7_MAJOR     89
4750 +#define IDE8_MAJOR     90
4751 +#define IDE9_MAJOR     91
4752 +
4753 +#define UBD_MAJOR      98
4754 +
4755 +#define AURORA_MAJOR 79
4756 +
4757 +#define JSFD_MAJOR     99
4758 +
4759 +#define PHONE_MAJOR    100
4760 +
4761 +#define LVM_CHAR_MAJOR 109     /* Logical Volume Manager */
4762 +
4763 +#define        UMEM_MAJOR      116     /* http://www.umem.com/ Battery Backed RAM */
4764 +
4765 +#define RTF_MAJOR      150
4766 +#define RAW_MAJOR      162
4767 +
4768 +#define USB_ACM_MAJOR          166
4769 +#define USB_ACM_AUX_MAJOR      167
4770 +#define USB_CHAR_MAJOR         180
4771 +
4772 +#define UNIX98_PTY_MASTER_MAJOR        128
4773 +#define UNIX98_PTY_MAJOR_COUNT 8
4774 +#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT)
4775 +
4776 +#define VXVM_MAJOR             199     /* VERITAS volume i/o driver    */
4777 +#define VXSPEC_MAJOR           200     /* VERITAS volume config driver */
4778 +#define VXDMP_MAJOR            201     /* VERITAS volume multipath driver */
4779 +
4780 +#define MSR_MAJOR              202
4781 +#define CPUID_MAJOR            203
4782 +
4783 +#define OSST_MAJOR     206     /* OnStream-SCx0 SCSI tape */
4784 +
4785 +#define IBM_TTY3270_MAJOR       227    /* Official allocations now */
4786 +#define IBM_FS3270_MAJOR        228
4787 +
4788 +/*
4789 + * Tests for SCSI devices.
4790 + */
4791 +
4792 +#define SCSI_DISK_MAJOR(M) ((M) == SCSI_DISK0_MAJOR || \
4793 +  ((M) >= SCSI_DISK1_MAJOR && (M) <= SCSI_DISK7_MAJOR))
4794 +  
4795 +#define SCSI_BLK_MAJOR(M) \
4796 +  (SCSI_DISK_MAJOR(M)  \
4797 +   || (M) == SCSI_CDROM_MAJOR)
4798 +
4799 +static __inline__ int scsi_blk_major(int m) {
4800 +       return SCSI_BLK_MAJOR(m);
4801 +}
4802 +
4803 +/*
4804 + * Tests for IDE devices
4805 + */
4806 +#define IDE_DISK_MAJOR(M)      ((M) == IDE0_MAJOR || (M) == IDE1_MAJOR || \
4807 +                               (M) == IDE2_MAJOR || (M) == IDE3_MAJOR || \
4808 +                               (M) == IDE4_MAJOR || (M) == IDE5_MAJOR || \
4809 +                               (M) == IDE6_MAJOR || (M) == IDE7_MAJOR || \
4810 +                               (M) == IDE8_MAJOR || (M) == IDE9_MAJOR)
4811 +
4812 +static __inline__ int ide_blk_major(int m)
4813 +{
4814 +       return IDE_DISK_MAJOR(m);
4815 +}
4816 +
4817 +#endif
4818 diff -Nur lilo-22.5.9-orig/kernel-headers/linux/unistd.h lilo-22.5.9/kernel-headers/linux/unistd.h
4819 --- lilo-22.5.9-orig/kernel-headers/linux/unistd.h      1970-01-01 01:00:00.000000000 +0100
4820 +++ lilo-22.5.9/kernel-headers/linux/unistd.h   2004-07-10 02:59:14.000000000 +0200
4821 @@ -0,0 +1,11 @@
4822 +#ifndef _LINUX_UNISTD_H_
4823 +#define _LINUX_UNISTD_H_
4824 +
4825 +extern int errno;
4826 +
4827 +/*
4828 + * Include machine specific syscallX macros
4829 + */
4830 +#include <asm/unistd.h>
4831 +
4832 +#endif /* _LINUX_UNISTD_H_ */