]> git.pld-linux.org Git - packages/kernel.git/blob - 40_lfs-2.2.20pre10aa1-28
- fix unresolved symbols in ipv6 netfilter
[packages/kernel.git] / 40_lfs-2.2.20pre10aa1-28
1 diff -urN lfs-ref/arch/alpha/kernel/entry.S lfs/arch/alpha/kernel/entry.S
2 --- lfs-ref/arch/alpha/kernel/entry.S   Wed Sep 12 02:39:56 2001
3 +++ lfs/arch/alpha/kernel/entry.S       Wed Sep 12 02:42:14 2001
4 @@ -8,7 +8,7 @@
5  
6  #define SIGCHLD 20
7  
8 -#define NR_SYSCALLS 377
9 +#define NR_SYSCALLS 378
10  
11  /*
12   * These offsets must match with alpha_mv in <asm/machvec.h>.
13 @@ -1162,3 +1162,4 @@
14         .quad sys_ni_syscall
15         .quad sys_ni_syscall                    /* 375 */
16         .quad sys_pciconfig_iobase
17 +       .quad sys_getdents64
18 diff -urN lfs-ref/arch/alpha/kernel/osf_sys.c lfs/arch/alpha/kernel/osf_sys.c
19 --- lfs-ref/arch/alpha/kernel/osf_sys.c Fri Apr 20 22:31:15 2001
20 +++ lfs/arch/alpha/kernel/osf_sys.c     Wed Sep 12 02:42:14 2001
21 @@ -110,7 +110,7 @@
22         int error;
23  };
24  
25 -static int osf_filldir(void *__buf, const char *name, int namlen, off_t offset, ino_t ino)
26 +static int osf_filldir(void *__buf, const char *name, int namlen, off_t offset, ino_t ino, unsigned int d_type)
27  {
28         struct osf_dirent *dirent;
29         struct osf_dirent_callback *buf = (struct osf_dirent_callback *) __buf;
30 diff -urN lfs-ref/arch/i386/kernel/entry.S lfs/arch/i386/kernel/entry.S
31 --- lfs-ref/arch/i386/kernel/entry.S    Wed Sep 12 02:39:56 2001
32 +++ lfs/arch/i386/kernel/entry.S        Wed Sep 12 02:42:14 2001
33 @@ -572,6 +572,18 @@
34         .long SYMBOL_NAME(sys_ni_syscall)               /* streams1 */
35         .long SYMBOL_NAME(sys_ni_syscall)               /* streams2 */
36         .long SYMBOL_NAME(sys_vfork)            /* 190 */
37 +       .long SYMBOL_NAME(sys_ni_syscall)               /* getrlimit */
38 +       .long SYMBOL_NAME(sys_mmap2)            /* 192 */
39 +       .long SYMBOL_NAME(sys_truncate64)       /* 193 */
40 +       .long SYMBOL_NAME(sys_ftruncate64)      /* 194 */
41 +       .long SYMBOL_NAME(sys_stat64)           /* 195 */
42 +       .long SYMBOL_NAME(sys_lstat64)          /* 196 */
43 +       .long SYMBOL_NAME(sys_fstat64)          /* 197 */
44 +       .rept 22
45 +               .long SYMBOL_NAME(sys_ni_syscall)
46 +       .endr
47 +       .long SYMBOL_NAME(sys_getdents64)       /* 220 */
48 +       .long SYMBOL_NAME(sys_fcntl64)          /* 221 */
49  
50         /*
51          * NOTE!! This doesn't have to be exact - we just have
52 @@ -579,6 +591,6 @@
53          * entries. Don't panic if you notice that this hasn't
54          * been shrunk every time we add a new system call.
55          */
56 -       .rept NR_syscalls-190
57 +       .rept NR_syscalls-221
58                 .long SYMBOL_NAME(sys_ni_syscall)
59         .endr
60 diff -urN lfs-ref/arch/i386/kernel/sys_i386.c lfs/arch/i386/kernel/sys_i386.c
61 --- lfs-ref/arch/i386/kernel/sys_i386.c Mon Jan 17 16:44:33 2000
62 +++ lfs/arch/i386/kernel/sys_i386.c     Wed Sep 12 02:42:14 2001
63 @@ -41,6 +41,42 @@
64         return error;
65  }
66  
67 +/* common code for old and new mmaps */
68 +static inline long do_mmap2(
69 +       unsigned long addr, unsigned long len,
70 +       unsigned long prot, unsigned long flags,
71 +       unsigned long fd, unsigned long pgoff)
72 +{
73 +       int error = -EBADF;
74 +       struct file * file = NULL;
75 +
76 +       down(&current->mm->mmap_sem);
77 +       lock_kernel();
78 +
79 +       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
80 +       if (!(flags & MAP_ANONYMOUS)) {
81 +               file = fget(fd);
82 +               if (!file)
83 +                       goto out;
84 +       }
85 +
86 +       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
87 +
88 +       if (file)
89 +               fput(file);
90 +out:
91 +       unlock_kernel();
92 +       up(&current->mm->mmap_sem);
93 +       return error;
94 +}
95 +
96 +asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
97 +       unsigned long prot, unsigned long flags,
98 +       unsigned long fd, unsigned long pgoff)
99 +{
100 +       return do_mmap2(addr, len, prot, flags, fd, pgoff);
101 +}
102 +
103  /*
104   * Perform the select(nd, in, out, ex, tv) and mmap() system
105   * calls. Linux/i386 didn't use to be able to handle more than
106 @@ -59,30 +95,19 @@
107  
108  asmlinkage int old_mmap(struct mmap_arg_struct *arg)
109  {
110 -       int error = -EFAULT;
111 -       struct file * file = NULL;
112         struct mmap_arg_struct a;
113 +       int err = -EFAULT;
114  
115         if (copy_from_user(&a, arg, sizeof(a)))
116 -               return -EFAULT;
117 +               goto out;
118  
119 -       down(&current->mm->mmap_sem);
120 -       lock_kernel();
121 -       if (!(a.flags & MAP_ANONYMOUS)) {
122 -               error = -EBADF;
123 -               file = fget(a.fd);
124 -               if (!file)
125 -                       goto out;
126 -       }
127 -       a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
128 +       err = -EINVAL;
129 +       if (a.offset & ~PAGE_MASK)
130 +               goto out;
131  
132 -       error = do_mmap(file, a.addr, a.len, a.prot, a.flags, a.offset);
133 -       if (file)
134 -               fput(file);
135 +       err = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
136  out:
137 -       unlock_kernel();
138 -       up(&current->mm->mmap_sem);
139 -       return error;
140 +       return err;
141  }
142  
143  extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
144 diff -urN lfs-ref/arch/mips/kernel/sysirix.c lfs/arch/mips/kernel/sysirix.c
145 --- lfs-ref/arch/mips/kernel/sysirix.c  Mon Jan 17 16:44:34 2000
146 +++ lfs/arch/mips/kernel/sysirix.c      Wed Sep 12 02:42:14 2001
147 @@ -1984,7 +1984,7 @@
148  #define ROUND_UP32(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
149  
150  static int irix_filldir32(void *__buf, const char *name, int namlen,
151 -                          off_t offset, ino_t ino)
152 +                          off_t offset, ino_t ino, unsigned int d_type)
153  {
154         struct irix_dirent32 *dirent;
155         struct irix_dirent32_callback *buf =
156 @@ -2097,7 +2097,7 @@
157  #define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
158  
159  static int irix_filldir64(void * __buf, const char * name, int namlen,
160 -                         off_t offset, ino_t ino)
161 +                         off_t offset, ino_t ino, unsigned int d_type)
162  {
163         struct irix_dirent64 *dirent;
164         struct irix_dirent64_callback * buf =
165 diff -urN lfs-ref/arch/ppc/kernel/misc.S lfs/arch/ppc/kernel/misc.S
166 --- lfs-ref/arch/ppc/kernel/misc.S      Fri Apr 20 22:31:15 2001
167 +++ lfs/arch/ppc/kernel/misc.S  Wed Sep 12 02:42:14 2001
168 @@ -958,7 +958,7 @@
169         .long sys_swapon
170         .long sys_reboot
171         .long old_readdir
172 -       .long sys_mmap          /* 90 */
173 +       .long old_mmap          /* 90 */
174         .long sys_munmap
175         .long sys_truncate
176         .long sys_ftruncate
177 @@ -1058,18 +1058,20 @@
178         .long sys_ni_syscall            /* streams1 */
179         .long sys_ni_syscall            /* streams2 */
180         .long sys_vfork
181 -       .long sys_ni_syscall            /* 190 */       /* MacOnLinux - old */
182 +       .long sys_ni_syscall            /* 190 getrlimit */
183         .long sys_ni_syscall            /* 191 */       /* Unused */
184 -       .long sys_ni_syscall            /* 192 - reserved - mmap2 */
185 -       .long sys_ni_syscall            /* 193 - reserved - truncate64 */
186 -       .long sys_ni_syscall            /* 194 - reserved - ftruncate64 */
187 -       .long sys_ni_syscall            /* 195 - reserved - stat64 */
188 -       .long sys_ni_syscall            /* 196 - reserved - lstat64 */
189 -       .long sys_ni_syscall            /* 197 - reserved - fstat64 */
190 +       .long sys_mmap2                 /* 192 */
191 +       .long sys_truncate64            /* 193 */
192 +       .long sys_ftruncate64           /* 194 */
193 +       .long sys_stat64                /* 195 */
194 +       .long sys_lstat64               /* 196 */
195 +       .long sys_fstat64               /* 197 */
196         .long sys_pciconfig_read        /* 198 */
197         .long sys_pciconfig_write       /* 199 */
198         .long sys_pciconfig_iobase      /* 200 */
199         .long sys_ni_syscall            /* 201 - reserved - MacOnLinux - new */
200 -       .rept NR_syscalls-201
201 +       .long sys_getdents64            /* 202 */
202 +       .long sys_fcntl64               /* 203 */
203 +       .rept NR_syscalls-203
204                 .long sys_ni_syscall
205         .endr
206 diff -urN lfs-ref/arch/ppc/kernel/syscalls.c lfs/arch/ppc/kernel/syscalls.c
207 --- lfs-ref/arch/ppc/kernel/syscalls.c  Mon Dec 11 16:57:46 2000
208 +++ lfs/arch/ppc/kernel/syscalls.c      Wed Sep 12 02:42:14 2001
209 @@ -33,6 +33,7 @@
210  #include <linux/sys.h>
211  #include <linux/ipc.h>
212  #include <linux/utsname.h>
213 +#include <linux/file.h>
214  
215  #include <asm/uaccess.h>
216  #include <asm/ipc.h>
217 @@ -192,25 +193,55 @@
218         return error;
219  }
220  
221 -asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
222 -                                 unsigned long prot, unsigned long flags,
223 -                                 unsigned long fd, off_t offset)
224 +/* common code for old and new mmaps */
225 +static inline long do_mmap2(
226 +       unsigned long addr, unsigned long len,
227 +       unsigned long prot, unsigned long flags,
228 +       unsigned long fd, unsigned long pgoff)
229  {
230         struct file * file = NULL;
231         int ret = -EBADF;
232  
233         down(&current->mm->mmap_sem);
234 -       lock_kernel();
235 +
236         if (!(flags & MAP_ANONYMOUS)) {
237 -               if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
238 +               file = fget(fd);
239 +               if (!file)
240                         goto out;
241         }
242 -       
243 +
244         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
245 -       ret = do_mmap(file, addr, len, prot, flags, offset);
246 -out:
247 +       ret = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
248 +
249 +       if (file)
250 +               fput(file);
251 + out:
252         unlock_kernel();
253         up(&current->mm->mmap_sem);
254 +       return ret;
255 +
256 +}
257 +
258 +asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
259 +                         unsigned long prot, unsigned long flags,
260 +                         unsigned long fd, unsigned long pgoff)
261 +{
262 +       return do_mmap2(addr, len, prot, flags, fd, pgoff);
263 +}
264 +
265 +asmlinkage unsigned long old_mmap(unsigned long addr, size_t len,
266 +                                 unsigned long prot, unsigned long flags,
267 +                                 unsigned long fd, off_t offset)
268 +{
269 +       int ret;
270 +
271 +       ret = -EINVAL;
272 +       if (offset & ~PAGE_MASK)
273 +               goto out;
274 +
275 +       ret = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
276 +
277 + out:
278         return ret;
279  }
280  
281 diff -urN lfs-ref/arch/sparc/kernel/sys_sparc.c lfs/arch/sparc/kernel/sys_sparc.c
282 --- lfs-ref/arch/sparc/kernel/sys_sparc.c       Thu May  4 13:00:36 2000
283 +++ lfs/arch/sparc/kernel/sys_sparc.c   Wed Sep 12 02:42:14 2001
284 @@ -176,9 +176,9 @@
285  }
286  
287  /* Linux version of mmap */
288 -asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
289 +asmlinkage unsigned long do_mmap2(unsigned long addr, unsigned long len,
290         unsigned long prot, unsigned long flags, unsigned long fd,
291 -       unsigned long off)
292 +       unsigned long pgoff)
293  {
294         struct file * file = NULL;
295         unsigned long retval = -EBADF;
296 @@ -211,7 +211,7 @@
297                 goto out_putf;
298  
299         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
300 -       retval = do_mmap(file, addr, len, prot, flags, off);
301 +       retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
302  
303  out_putf:
304         if (file)
305 @@ -220,6 +220,22 @@
306         unlock_kernel();
307         up(&current->mm->mmap_sem);
308         return retval;
309 +}
310 +
311 +asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
312 +       unsigned long prot, unsigned long flags, unsigned long fd,
313 +       unsigned long pgoff)
314 +{
315 +       /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
316 +          we have. */
317 +       return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12));
318 +}
319 +
320 +asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
321 +       unsigned long prot, unsigned long flags, unsigned long fd,
322 +       unsigned long off)
323 +{
324 +       return do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
325  }
326  
327  /* we come to here via sys_nis_syscall so it can setup the regs argument */
328 diff -urN lfs-ref/arch/sparc/kernel/sys_sunos.c lfs/arch/sparc/kernel/sys_sunos.c
329 --- lfs-ref/arch/sparc/kernel/sys_sunos.c       Wed Sep 12 02:39:57 2001
330 +++ lfs/arch/sparc/kernel/sys_sunos.c   Wed Sep 12 02:42:14 2001
331 @@ -409,7 +409,7 @@
332  #define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
333  
334  static int sunos_filldir(void * __buf, const char * name, int namlen,
335 -                        off_t offset, ino_t ino)
336 +                        off_t offset, ino_t ino, unsigned int d_type)
337  {
338         struct sunos_dirent * dirent;
339         struct sunos_dirent_callback * buf = (struct sunos_dirent_callback *) __buf;
340 @@ -500,7 +500,7 @@
341  };
342  
343  static int sunos_filldirentry(void * __buf, const char * name, int namlen,
344 -                             off_t offset, ino_t ino)
345 +                             off_t offset, ino_t ino, unsigned int d_type)
346  {
347         struct sunos_direntry * dirent;
348         struct sunos_direntry_callback * buf = (struct sunos_direntry_callback *) __buf;
349 diff -urN lfs-ref/arch/sparc/kernel/systbls.S lfs/arch/sparc/kernel/systbls.S
350 --- lfs-ref/arch/sparc/kernel/systbls.S Fri Apr 20 22:31:15 2001
351 +++ lfs/arch/sparc/kernel/systbls.S     Wed Sep 12 02:42:14 2001
352 @@ -29,12 +29,12 @@
353  /*40*/ .long sys_newlstat, sys_dup, sys_pipe, sys_times, sys_lfs_syscall
354  /*45*/ .long sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
355  /*50*/ .long sys_getegid, sys_acct, sys_nis_syscall, sys_nis_syscall, sys_ioctl
356 -/*55*/ .long sys_reboot, sys_lfs_syscall, sys_symlink, sys_readlink, sys_execve
357 -/*60*/ .long sys_umask, sys_chroot, sys_newfstat, sys_lfs_syscall, sys_getpagesize
358 +/*55*/ .long sys_reboot, sys_mmap2, sys_symlink, sys_readlink, sys_execve
359 +/*60*/ .long sys_umask, sys_chroot, sys_newfstat, sys_fstat64, sys_getpagesize
360  /*65*/ .long sys_msync, sys_vfork, sys_pread, sys_pwrite, sys_nis_syscall
361  /*70*/ .long sys_nis_syscall, sys_mmap, sys_nis_syscall, sys_munmap, sys_mprotect
362 -/*75*/ .long sys_nis_syscall, sys_vhangup, sys_lfs_syscall, sys_nis_syscall, sys_getgroups
363 -/*80*/ .long sys_setgroups, sys_getpgrp, sys_nis_syscall, sys_setitimer, sys_lfs_syscall
364 +/*75*/ .long sys_nis_syscall, sys_vhangup, sys_truncate64, sys_nis_syscall, sys_getgroups
365 +/*80*/ .long sys_setgroups, sys_getpgrp, sys_nis_syscall, sys_setitimer, sys_ftruncate64
366  /*85*/ .long sys_swapon, sys_getitimer, sys_nis_syscall, sys_sethostname, sys_nis_syscall
367  /*90*/ .long sys_dup2, sys_nis_syscall, sys_fcntl, sys_select, sys_nis_syscall
368  /*95*/ .long sys_fsync, sys_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
369 @@ -44,12 +44,12 @@
370  /*115*/        .long sys_nis_syscall, sys_gettimeofday, sys_getrusage, sys_nis_syscall, sys_getcwd
371  /*120*/        .long sys_readv, sys_writev, sys_settimeofday, sys_fchown, sys_fchmod
372  /*125*/        .long sys_nis_syscall, sys_setreuid, sys_setregid, sys_rename, sys_truncate
373 -/*130*/        .long sys_ftruncate, sys_flock, sys_lfs_syscall, sys_nis_syscall, sys_nis_syscall
374 -/*135*/        .long sys_nis_syscall, sys_mkdir, sys_rmdir, sys_utimes, sys_lfs_syscall
375 +/*130*/        .long sys_ftruncate, sys_flock, sys_lstat64, sys_nis_syscall, sys_nis_syscall
376 +/*135*/        .long sys_nis_syscall, sys_mkdir, sys_rmdir, sys_utimes, sys_stat64
377  /*140*/        .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getrlimit
378  /*145*/        .long sys_setrlimit, sys_nis_syscall, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
379 -/*150*/        .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_lfs_syscall
380 -/*155*/        .long sys_lfs_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
381 +/*150*/        .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
382 +/*155*/        .long sys_fcntl64, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
383  /*160*/        .long sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
384  /*165*/        .long sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_nis_syscall
385  /*170*/        .long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getdents
386 diff -urN lfs-ref/arch/sparc64/kernel/sparc64_ksyms.c lfs/arch/sparc64/kernel/sparc64_ksyms.c
387 --- lfs-ref/arch/sparc64/kernel/sparc64_ksyms.c Wed Sep 12 02:05:39 2001
388 +++ lfs/arch/sparc64/kernel/sparc64_ksyms.c     Wed Sep 12 02:42:14 2001
389 @@ -84,6 +84,7 @@
390  extern int sys32_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
391  extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *);
392  extern void VISenter(void);
393 +extern long sparc32_open(const char * filename, int flags, int mode);
394  extern int io_remap_page_range(unsigned long from, unsigned long offset, unsigned long size, pgprot_t prot, int space);
395                  
396  extern void bcopy (const char *, char *, int);
397 @@ -283,6 +284,7 @@
398  EXPORT_SYMBOL(prom_cpu_nodes);
399  EXPORT_SYMBOL(sys_ioctl);
400  EXPORT_SYMBOL(sys32_ioctl);
401 +EXPORT_SYMBOL(sparc32_open);
402  EXPORT_SYMBOL(move_addr_to_kernel);
403  EXPORT_SYMBOL(move_addr_to_user);
404  #endif
405 diff -urN lfs-ref/arch/sparc64/kernel/sys32.S lfs/arch/sparc64/kernel/sys32.S
406 --- lfs-ref/arch/sparc64/kernel/sys32.S Thu May  4 13:00:36 2000
407 +++ lfs/arch/sparc64/kernel/sys32.S     Wed Sep 12 02:42:14 2001
408 @@ -60,3 +60,12 @@
409         sethi           %hi(sys_bdflush), %g1
410         jmpl            %g1 + %lo(sys_bdflush), %g0
411          sra            %o1, 0, %o1
412 +
413 +       .align          32
414 +       .globl          sys32_mmap2
415 +sys32_mmap2:
416 +       srl             %o4, 0, %o4
417 +       sethi           %hi(sys_mmap), %g1
418 +       srl             %o5, 0, %o5
419 +       jmpl            %g1 + %lo(sys_mmap), %g0
420 +        sllx           %o5, 12, %o5
421 diff -urN lfs-ref/arch/sparc64/kernel/sys_sparc32.c lfs/arch/sparc64/kernel/sys_sparc32.c
422 --- lfs-ref/arch/sparc64/kernel/sys_sparc32.c   Wed Sep 12 02:05:39 2001
423 +++ lfs/arch/sparc64/kernel/sys_sparc32.c       Wed Sep 12 02:42:14 2001
424 @@ -600,15 +600,27 @@
425                         old_fs = get_fs(); set_fs (KERNEL_DS);
426                         ret = sys_fcntl(fd, cmd, (unsigned long)&f);
427                         set_fs (old_fs);
428 +                       if (ret) return ret;
429 +                       if (f.l_start >= 0x7fffffffUL ||
430 +                           f.l_len >= 0x7fffffffUL ||
431 +                           f.l_start + f.l_len >= 0x7fffffffUL)
432 +                               return -EOVERFLOW;
433                         if(put_flock(&f, (struct flock32 *)arg))
434                                 return -EFAULT;
435 -                       return ret;
436 +                       return 0;
437                 }
438         default:
439                 return sys_fcntl(fd, cmd, (unsigned long)arg);
440         }
441  }
442  
443 +asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
444 +{
445 +       if (cmd >= F_GETLK64 && cmd <= F_SETLKW64)
446 +               return sys_fcntl(fd, cmd + F_GETLK - F_GETLK64, arg);
447 +       return sys32_fcntl(fd, cmd, arg);
448 +}
449 +
450  struct dqblk32 {
451      __u32 dqb_bhardlimit;
452      __u32 dqb_bsoftlimit;
453 @@ -720,6 +732,25 @@
454         return ret;
455  }
456  
457 +extern asmlinkage long sys_truncate(const char * path, unsigned long length);
458 +extern asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
459 +
460 +asmlinkage int sys32_truncate64(const char * path, unsigned long high, unsigned long low)
461 +{
462 +       if ((int)high < 0)
463 +               return -EINVAL;
464 +       else
465 +               return sys_truncate(path, (high << 32) | low);
466 +}
467 +
468 +asmlinkage int sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low)
469 +{
470 +       if ((int)high < 0)
471 +               return -EINVAL;
472 +       else
473 +               return sys_ftruncate(fd, (high << 32) | low);
474 +}
475 +
476  extern asmlinkage int sys_utime(char * filename, struct utimbuf * times);
477  
478  struct utimbuf32 {
479 @@ -917,7 +948,7 @@
480  };
481  
482  static int fillonedir(void * __buf, const char * name, int namlen,
483 -                     off_t offset, ino_t ino)
484 +                     off_t offset, ino_t ino, unsigned int d_type)
485  {
486         struct readdir_callback32 * buf = (struct readdir_callback32 *) __buf;
487         struct old_linux_dirent32 * dirent;
488 @@ -982,7 +1013,8 @@
489         int error;
490  };
491  
492 -static int filldir(void * __buf, const char * name, int namlen, off_t offset, ino_t ino)
493 +static int filldir(void * __buf, const char * name, int namlen, off_t offset, ino_t ino,
494 +                  unsigned int d_type)
495  {
496         struct linux_dirent32 * dirent;
497         struct getdents_callback32 * buf = (struct getdents_callback32 *) __buf;
498 @@ -4049,6 +4081,39 @@
499                 return -EFAULT;
500                 
501         return ret;
502 +}
503 +
504 +/* This is just a version for 32-bit applications which does
505 + * not force O_LARGEFILE on.
506 + */
507 +
508 +asmlinkage long sparc32_open(const char * filename, int flags, int mode)
509 +{
510 +       char * tmp;
511 +       int fd, error;
512 +
513 +       tmp = getname(filename);
514 +       fd = PTR_ERR(tmp);
515 +       if (!IS_ERR(tmp)) {
516 +               lock_kernel();
517 +               fd = get_unused_fd();
518 +               if (fd >= 0) {
519 +                       struct file * f = filp_open(tmp, flags, mode);
520 +                       error = PTR_ERR(f);
521 +                       if (IS_ERR(f))
522 +                               goto out_error;
523 +                       fd_install(fd, f);
524 +               }
525 +out:
526 +               unlock_kernel();
527 +               putname(tmp);
528 +       }
529 +       return fd;
530 +
531 +out_error:
532 +       put_unused_fd(fd);
533 +       fd = error;
534 +       goto out;
535  }
536  
537  /* Handle adjtimex compatability. */
538 diff -urN lfs-ref/arch/sparc64/kernel/sys_sunos32.c lfs/arch/sparc64/kernel/sys_sunos32.c
539 --- lfs-ref/arch/sparc64/kernel/sys_sunos32.c   Fri Apr 20 22:31:15 2001
540 +++ lfs/arch/sparc64/kernel/sys_sunos32.c       Wed Sep 12 02:42:14 2001
541 @@ -366,7 +366,7 @@
542  #define ROUND_UP(x) (((x)+sizeof(s32)-1) & ~(sizeof(s32)-1))
543  
544  static int sunos_filldir(void * __buf, const char * name, int namlen,
545 -                        off_t offset, ino_t ino)
546 +                        off_t offset, ino_t ino, unsigned int d_type)
547  {
548         struct sunos_dirent * dirent;
549         struct sunos_dirent_callback * buf = (struct sunos_dirent_callback *) __buf;
550 @@ -458,7 +458,7 @@
551  };
552  
553  static int sunos_filldirentry(void * __buf, const char * name, int namlen,
554 -                             off_t offset, ino_t ino)
555 +                             off_t offset, ino_t ino, unsigned int d_type)
556  {
557         struct sunos_direntry * dirent;
558         struct sunos_direntry_callback * buf = (struct sunos_direntry_callback *) __buf;
559 @@ -1297,13 +1297,15 @@
560         return rval;
561  }
562  
563 +extern asmlinkage long sparc32_open(const char * filename, int flags, int mode);
564 +
565  asmlinkage int sunos_open(u32 filename, int flags, int mode)
566  {
567         int ret;
568  
569         lock_kernel();
570         current->personality |= PER_BSD;
571 -       ret = sys_open ((char *)A(filename), flags, mode);
572 +       ret = sparc32_open ((char *)A(filename), flags, mode);
573         unlock_kernel();
574         return ret;
575  }
576 diff -urN lfs-ref/arch/sparc64/kernel/systbls.S lfs/arch/sparc64/kernel/systbls.S
577 --- lfs-ref/arch/sparc64/kernel/systbls.S       Fri Apr 20 22:31:15 2001
578 +++ lfs/arch/sparc64/kernel/systbls.S   Wed Sep 12 02:42:14 2001
579 @@ -20,7 +20,7 @@
580         .globl sys_call_table32
581  sys_call_table32:
582  /*0*/  .word sys_nis_syscall, sparc_exit, sys_fork, sys_read, sys_write
583 -/*5*/  .word sys_open, sys_close, sys32_wait4, sys_creat, sys_link
584 +/*5*/  .word sparc32_open, sys_close, sys32_wait4, sys_creat, sys_link
585  /*10*/  .word sys_unlink, sunos_execv, sys_chdir, sys32_chown16, sys32_mknod
586  /*15*/ .word sys32_chmod, sys32_lchown16, sparc_brk, sys_perfctr, sys32_lseek
587  /*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid, sys_getuid
588 @@ -30,12 +30,12 @@
589  /*40*/ .word sys32_newlstat, sys_dup, sys_pipe, sys32_times, sys_lfs_syscall
590         .word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
591  /*50*/ .word sys_getegid, sys_acct, sys_nis_syscall, sys_nis_syscall, sys32_ioctl
592 -       .word sys_reboot, sys_lfs_syscall, sys_symlink, sys_readlink, sys32_execve
593 -/*60*/ .word sys_umask, sys_chroot, sys32_newfstat, sys_lfs_syscall, sys_getpagesize
594 +       .word sys_reboot, sys32_mmap2, sys_symlink, sys_readlink, sys32_execve
595 +/*60*/ .word sys_umask, sys_chroot, sys32_newfstat, sys_fstat64, sys_getpagesize
596         .word sys_msync, sys_vfork, sys32_pread, sys32_pwrite, sys_nis_syscall
597  /*70*/ .word sys_nis_syscall, sys32_mmap, sys_nis_syscall, sys_munmap, sys_mprotect
598 -       .word sys_nis_syscall, sys_vhangup, sys_lfs_syscall, sys_nis_syscall, sys32_getgroups
599 -/*80*/ .word sys32_setgroups, sys_getpgrp, sys_nis_syscall, sys32_setitimer, sys_lfs_syscall
600 +       .word sys_nis_syscall, sys_vhangup, sys32_truncate64, sys_nis_syscall, sys32_getgroups
601 +/*80*/ .word sys32_setgroups, sys_getpgrp, sys_nis_syscall, sys32_setitimer, sys32_ftruncate64
602         .word sys_swapon, sys32_getitimer, sys_nis_syscall, sys_sethostname, sys_nis_syscall
603  /*90*/ .word sys_dup2, sys_nis_syscall, sys32_fcntl, sys32_select, sys_nis_syscall
604         .word sys_fsync, sys_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
605 @@ -45,12 +45,12 @@
606         .word sys_nis_syscall, sys32_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd
607  /*120*/        .word sys32_readv, sys32_writev, sys32_settimeofday, sys32_fchown16, sys_fchmod
608         .word sys_nis_syscall, sys32_setreuid, sys32_setregid, sys_rename, sys_truncate
609 -/*130*/        .word sys_ftruncate, sys_flock, sys_lfs_syscall, sys_nis_syscall, sys_nis_syscall
610 -       .word sys_nis_syscall, sys_mkdir, sys_rmdir, sys32_utimes, sys_lfs_syscall
611 +/*130*/        .word sys_ftruncate, sys_flock, sys_lstat64, sys_nis_syscall, sys_nis_syscall
612 +       .word sys_nis_syscall, sys_mkdir, sys_rmdir, sys32_utimes, sys_stat64
613  /*140*/        .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getrlimit
614         .word sys32_setrlimit, sys_nis_syscall, sys32_prctl, sys32_pciconfig_read, sys32_pciconfig_write
615 -/*150*/        .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_lfs_syscall
616 -       .word sys_lfs_syscall, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
617 +/*150*/        .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
618 +       .word sys32_fcntl64, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
619  /*160*/        .word sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
620         .word sys32_quotactl, sys_nis_syscall, sys32_mount, sys_ustat, sys_nis_syscall
621  /*170*/        .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getdents
622 @@ -108,7 +108,7 @@
623         .word sys_socketpair, sys_mkdir, sys_rmdir, sys_utimes, sys_nis_syscall
624  /*140*/        .word sys_nis_syscall, sys_getpeername, sys_nis_syscall, sys_nis_syscall, sys_getrlimit
625         .word sys_setrlimit, sys_nis_syscall, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
626 -/*150*/        .word sys_getsockname, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_nis_syscall
627 +/*150*/        .word sys_getsockname, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
628         .word sys_nis_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
629  /*160*/        .word sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_utrap_install
630         .word sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_nis_syscall
631 diff -urN lfs-ref/arch/sparc64/solaris/fs.c lfs/arch/sparc64/solaris/fs.c
632 --- lfs-ref/arch/sparc64/solaris/fs.c   Mon Jan 17 16:44:36 2000
633 +++ lfs/arch/sparc64/solaris/fs.c       Wed Sep 12 02:42:14 2001
634 @@ -572,20 +572,20 @@
635         return error;
636  }
637  
638 +extern asmlinkage long sparc32_open(const char * filename, int flags, int mode);
639 +
640  asmlinkage int solaris_open(u32 filename, int flags, u32 mode)
641  {
642 -       int (*sys_open)(const char *,int,int) = 
643 -               (int (*)(const char *,int,int))SYS(open);
644         int fl = flags & 0xf;
645  
646 -/*     if (flags & 0x2000) - allow LFS                 */
647 +       if (flags & 0x2000) fl |= O_LARGEFILE;
648         if (flags & 0x8050) fl |= O_SYNC;
649         if (flags & 0x80) fl |= O_NONBLOCK;
650         if (flags & 0x100) fl |= O_CREAT;
651         if (flags & 0x200) fl |= O_TRUNC;
652         if (flags & 0x400) fl |= O_EXCL;
653         if (flags & 0x800) fl |= O_NOCTTY;
654 -       return sys_open((const char *)A(filename), fl, mode);
655 +       return sparc32_open((const char *)A(filename), fl, mode);
656  }
657  
658  #define SOL_F_SETLK    6
659 diff -urN lfs-ref/drivers/block/loop.c lfs/drivers/block/loop.c
660 --- lfs-ref/drivers/block/loop.c        Wed Sep 12 02:39:57 2001
661 +++ lfs/drivers/block/loop.c    Wed Sep 12 02:42:14 2001
662 @@ -143,12 +143,12 @@
663         int     size;
664  
665         if (S_ISREG(lo->lo_dentry->d_inode->i_mode))
666 -               size = (lo->lo_dentry->d_inode->i_size - lo->lo_offset) / BLOCK_SIZE;
667 +               size = (lo->lo_dentry->d_inode->i_size - lo->lo_offset) >> BLOCK_SIZE_BITS;
668         else {
669                 kdev_t lodev = lo->lo_device;
670                 if (blk_size[MAJOR(lodev)])
671                         size = blk_size[MAJOR(lodev)][MINOR(lodev)] -
672 -                                lo->lo_offset / BLOCK_SIZE;
673 +                                (lo->lo_offset >> BLOCK_SIZE_BITS);
674                 else
675                         size = MAX_DISK_SIZE;
676         }
677 diff -urN lfs-ref/drivers/usb/inode.c lfs/drivers/usb/inode.c
678 --- lfs-ref/drivers/usb/inode.c Mon Dec 11 16:57:58 2000
679 +++ lfs/drivers/usb/inode.c     Wed Sep 12 02:42:14 2001
680 @@ -302,14 +302,14 @@
681         i = filp->f_pos;
682         switch (i) {
683         case 0:
684 -               if (filldir(dirent, ".", 1, i, IROOT) < 0)
685 +               if (filldir(dirent, ".", 1, i, IROOT, DT_DIR) < 0)
686                         return 0;
687                 filp->f_pos++;
688                 i++;
689                 /* fall through */
690  
691         case 1:
692 -               if (filldir(dirent, "..", 2, i, IROOT) < 0)
693 +               if (filldir(dirent, "..", 2, i, IROOT, DT_DIR) < 0)
694                         return 0;
695                 filp->f_pos++;
696                 i++;
697 @@ -319,7 +319,7 @@
698                 
699                 while (i >= 2 && i < 2+NRSPECIAL) {
700                         spec = &special[filp->f_pos-2];
701 -                       if (filldir(dirent, spec->name, strlen(spec->name), i, ISPECIAL | (filp->f_pos-2+IROOT)) < 0)
702 +                       if (filldir(dirent, spec->name, strlen(spec->name), i, ISPECIAL | (filp->f_pos-2+IROOT), DT_UNKNOWN) < 0)
703                                 return 0;
704                         filp->f_pos++;
705                         i++;
706 @@ -335,7 +335,7 @@
707                         }
708                         bus = list_entry(list, struct usb_bus, bus_list);
709                         sprintf(numbuf, "%03d", bus->busnum);
710 -                       if (filldir(dirent, numbuf, 3, filp->f_pos, IBUS | ((bus->busnum & 0xff) << 8)) < 0)
711 +                       if (filldir(dirent, numbuf, 3, filp->f_pos, IBUS | ((bus->busnum & 0xff) << 8), DT_UNKNOWN) < 0)
712                                 break;
713                         filp->f_pos++;
714                 }
715 @@ -355,7 +355,7 @@
716         if (pos > 0)
717                 pos--;
718         else {
719 -               if (filldir(dirent, numbuf, 3, filp->f_pos, ino | (dev->devnum & 0xff)) < 0)
720 +               if (filldir(dirent, numbuf, 3, filp->f_pos, ino | (dev->devnum & 0xff), DT_UNKNOWN) < 0)
721                         return -1;
722                 filp->f_pos++;
723         }
724 @@ -380,13 +380,13 @@
725                 return -EINVAL;
726         switch ((unsigned int)filp->f_pos) {
727         case 0:
728 -               if (filldir(dirent, ".", 1, filp->f_pos, ino) < 0)
729 +               if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) < 0)
730                         return 0;
731                 filp->f_pos++;
732                 /* fall through */
733  
734         case 1:
735 -               if (filldir(dirent, "..", 2, filp->f_pos, IROOT) < 0)
736 +               if (filldir(dirent, "..", 2, filp->f_pos, IROOT, DT_DIR) < 0)
737                         return 0;
738                 filp->f_pos++;
739                 /* fall through */
740 diff -urN lfs-ref/fs/adfs/dir.c lfs/fs/adfs/dir.c
741 --- lfs-ref/fs/adfs/dir.c       Mon Dec 11 16:58:00 2000
742 +++ lfs/fs/adfs/dir.c   Wed Sep 12 02:42:14 2001
743 @@ -40,12 +40,12 @@
744  
745         switch ((unsigned long)filp->f_pos) {
746         case 0:
747 -               if (filldir(dirent, ".", 1, 0, inode->i_ino) < 0)
748 +               if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
749                         goto free_out;
750                 filp->f_pos += 1;
751  
752         case 1:
753 -               if (filldir(dirent, "..", 2, 1, dir.parent_id) < 0)
754 +               if (filldir(dirent, "..", 2, 1, dir.parent_id, DT_DIR) < 0)
755                         goto free_out;
756                 filp->f_pos += 1;
757  
758 @@ -60,7 +60,7 @@
759                 goto unlock_out;
760         while (ops->getnext(&dir, &obj) == 0) {
761                 if (filldir(dirent, obj.name, obj.name_len,
762 -                           filp->f_pos, obj.file_id) < 0)
763 +                           filp->f_pos, obj.file_id, DT_UNKNOWN) < 0)
764                         goto unlock_out;
765                 filp->f_pos += 1;
766         }
767 diff -urN lfs-ref/fs/affs/dir.c lfs/fs/affs/dir.c
768 --- lfs-ref/fs/affs/dir.c       Mon Jan 17 16:44:41 2000
769 +++ lfs/fs/affs/dir.c   Wed Sep 12 02:42:14 2001
770 @@ -98,14 +98,14 @@
771  
772         if (filp->f_pos == 0) {
773                 filp->private_data = (void *)0;
774 -               if (filldir(dirent,".",1,filp->f_pos,inode->i_ino) < 0) {
775 +               if (filldir(dirent,".",1,filp->f_pos,inode->i_ino, DT_DIR) < 0) {
776                         return 0;
777                 }
778                 ++filp->f_pos;
779                 stored++;
780         }
781         if (filp->f_pos == 1) {
782 -               if (filldir(dirent,"..",2,filp->f_pos,affs_parent_ino(inode)) < 0) {
783 +               if (filldir(dirent,"..",2,filp->f_pos,affs_parent_ino(inode), DT_DIR) < 0) {
784                         return stored;
785                 }
786                 filp->f_pos = 2;
787 @@ -161,7 +161,7 @@
788                         pr_debug("AFFS: readdir(): filldir(\"%.*s\",ino=%lu), i=%d\n",
789                                  namelen,name,ino,i);
790                         filp->private_data = (void *)ino;
791 -                       if (filldir(dirent,name,namelen,filp->f_pos,ino) < 0)
792 +                       if (filldir(dirent,name,namelen,filp->f_pos,ino, DT_UNKNOWN) < 0)
793                                 goto readdir_done;
794                         filp->private_data = (void *)i;
795                         affs_brelse(fh_bh);
796 diff -urN lfs-ref/fs/affs/file.c lfs/fs/affs/file.c
797 --- lfs-ref/fs/affs/file.c      Tue Sep  5 02:28:47 2000
798 +++ lfs/fs/affs/file.c  Wed Sep 12 02:42:14 2001
799 @@ -582,17 +582,17 @@
800  affs_file_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
801  {
802         struct inode            *inode = filp->f_dentry->d_inode;
803 -       off_t                    pos;
804 +       loff_t                   pos;
805         ssize_t                  written;
806         ssize_t                  c;
807 -       ssize_t                  blocksize;
808 +       ssize_t                  blocksize, blockshift;
809         struct buffer_head      *bh;
810         char                    *p;
811  
812         if (!count)
813                 return 0;
814 -       pr_debug("AFFS: file_write(ino=%lu,pos=%lu,count=%d)\n",inode->i_ino,
815 -                (unsigned long)*ppos,count);
816 +       pr_debug("AFFS: file_write(ino=%lu,pos=%Lu,count=%d)\n",inode->i_ino,
817 +                *ppos,count);
818  
819         if (!inode) {
820                 affs_error(inode->i_sb,"file_write","Inode = NULL");
821 @@ -611,16 +611,22 @@
822         else
823                 pos = *ppos;
824         written   = 0;
825 -       blocksize = AFFS_I2BSIZE(inode);
826 +       blocksize  = AFFS_I2BSIZE(inode);
827 +       blockshift = AFFS_I2BITS(inode);
828 +
829 +       if (pos >= 0x7fffffff) /* Max size: 2G-1 */
830 +               return -EFBIG;
831 +       if ((pos + count) > 0x7fffffff)
832 +               count = 0x7fffffff - pos;
833  
834         while (written < count) {
835 -               bh = affs_getblock(inode,pos / blocksize);
836 +               bh = affs_getblock(inode, pos >> blockshift);
837                 if (!bh) {
838                         if (!written)
839                                 written = -ENOSPC;
840                         break;
841                 }
842 -               c = blocksize - (pos % blocksize);
843 +               c = blocksize - (pos & (blocksize -1));
844                 if (c > count - written)
845                         c = count - written;
846                 if (c != blocksize && !buffer_uptodate(bh)) {
847 @@ -633,7 +639,7 @@
848                                 break;
849                         }
850                 }
851 -               p  = (pos % blocksize) + bh->b_data;
852 +               p  = (pos & (blocksize -1)) + bh->b_data;
853                 c -= copy_from_user(p,buf,c);
854                 if (!c) {
855                         affs_brelse(bh);
856 @@ -664,7 +670,7 @@
857         off_t                    pos;
858         ssize_t                  written;
859         ssize_t                  c;
860 -       ssize_t                  blocksize;
861 +       ssize_t                  blocksize, blockshift;
862         struct buffer_head      *bh;
863         char                    *p;
864  
865 @@ -692,15 +698,16 @@
866  
867         bh        = NULL;
868         blocksize = AFFS_I2BSIZE(inode) - 24;
869 +       blockshift = AFFS_I2BITS(inode);
870         written   = 0;
871         while (written < count) {
872 -               bh = affs_getblock(inode,pos / blocksize);
873 +               bh = affs_getblock(inode,pos >> blockshift);
874                 if (!bh) {
875                         if (!written)
876                                 written = -ENOSPC;
877                         break;
878                 }
879 -               c = blocksize - (pos % blocksize);
880 +               c = blocksize - (pos & (blocksize -1));
881                 if (c > count - written)
882                         c = count - written;
883                 if (c != blocksize && !buffer_uptodate(bh)) {
884 @@ -713,7 +720,7 @@
885                                 break;
886                         }
887                 }
888 -               p  = (pos % blocksize) + bh->b_data + 24;
889 +               p  = (pos & (blocksize -1)) + bh->b_data + 24;
890                 c -= copy_from_user(p,buf,c);
891                 if (!c) {
892                         affs_brelse(bh);
893 @@ -782,10 +789,10 @@
894         int      rem;
895         int      ext;
896  
897 -       pr_debug("AFFS: truncate(inode=%ld,size=%lu)\n",inode->i_ino,inode->i_size);
898 +       pr_debug("AFFS: truncate(inode=%ld,size=%Lu)\n",inode->i_ino,inode->i_size);
899  
900         net_blocksize = blocksize - ((inode->i_sb->u.affs_sb.s_flags & SF_OFS) ? 24 : 0);
901 -       first = (inode->i_size + net_blocksize - 1) / net_blocksize;
902 +       first = (u_long)(inode->i_size + net_blocksize - 1) / net_blocksize;
903         if (inode->u.affs_i.i_lastblock < first - 1) {
904                 /* There has to be at least one new block to be allocated */
905                 if (!inode->u.affs_i.i_ec && alloc_ext_cache(inode)) {
906 @@ -795,9 +802,9 @@
907                 bh = affs_getblock(inode,first - 1);
908                 if (!bh) {
909                         affs_warning(inode->i_sb,"truncate","Cannot extend file");
910 -                       inode->i_size = net_blocksize * (inode->u.affs_i.i_lastblock + 1);
911 +                       inode->i_size = (inode->u.affs_i.i_lastblock + 1) * net_blocksize;
912                 } else if (inode->i_sb->u.affs_sb.s_flags & SF_OFS) {
913 -                       rem = inode->i_size % net_blocksize;
914 +                       rem = ((u_long)inode->i_size) & (net_blocksize -1);
915                         DATA_FRONT(bh)->data_size = cpu_to_be32(rem ? rem : net_blocksize);
916                         affs_fix_checksum(blocksize,bh->b_data,5);
917                         mark_buffer_dirty(bh,0);
918 @@ -864,7 +871,7 @@
919                         affs_free_block(inode->i_sb,ekey);
920                 ekey = key;
921         }
922 -       block = ((inode->i_size + net_blocksize - 1) / net_blocksize) - 1;
923 +       block = (((u_long)inode->i_size + net_blocksize - 1) / net_blocksize) - 1;
924         inode->u.affs_i.i_lastblock = block;
925  
926         /* If the file is not truncated to a block boundary,
927 @@ -872,7 +879,7 @@
928          * so it cannot become accessible again.
929          */
930  
931 -       rem = inode->i_size % net_blocksize;
932 +       rem = inode->i_size & (net_blocksize -1);
933         if (rem) {
934                 if ((inode->i_sb->u.affs_sb.s_flags & SF_OFS)) 
935                         rem += 24;
936 diff -urN lfs-ref/fs/affs/inode.c lfs/fs/affs/inode.c
937 --- lfs-ref/fs/affs/inode.c     Sun Apr  2 21:07:49 2000
938 +++ lfs/fs/affs/inode.c Wed Sep 12 02:42:14 2001
939 @@ -146,7 +146,7 @@
940                                 block = AFFS_I2BSIZE(inode) - 24;
941                         else
942                                 block = AFFS_I2BSIZE(inode);
943 -                       inode->u.affs_i.i_lastblock = ((inode->i_size + block - 1) / block) - 1;
944 +                       inode->u.affs_i.i_lastblock = (((u_long)inode->i_size + block - 1) / block) - 1;
945                         break;
946                 case ST_SOFTLINK:
947                         inode->i_mode |= S_IFLNK;
948 diff -urN lfs-ref/fs/autofs/dir.c lfs/fs/autofs/dir.c
949 --- lfs-ref/fs/autofs/dir.c     Mon Jan 17 16:44:41 2000
950 +++ lfs/fs/autofs/dir.c Wed Sep 12 02:42:14 2001
951 @@ -20,12 +20,12 @@
952         switch((unsigned long) filp->f_pos)
953         {
954         case 0:
955 -               if (filldir(dirent, ".", 1, 0, inode->i_ino) < 0)
956 +               if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
957                         return 0;
958                 filp->f_pos++;
959                 /* fall through */
960         case 1:
961 -               if (filldir(dirent, "..", 2, 1, AUTOFS_ROOT_INO) < 0)
962 +               if (filldir(dirent, "..", 2, 1, AUTOFS_ROOT_INO, DT_DIR) < 0)
963                         return 0;
964                 filp->f_pos++;
965                 /* fall through */
966 diff -urN lfs-ref/fs/autofs/root.c lfs/fs/autofs/root.c
967 --- lfs-ref/fs/autofs/root.c    Mon Jan 17 16:44:41 2000
968 +++ lfs/fs/autofs/root.c        Wed Sep 12 02:42:14 2001
969 @@ -79,19 +79,19 @@
970         switch(nr)
971         {
972         case 0:
973 -               if (filldir(dirent, ".", 1, nr, inode->i_ino) < 0)
974 +               if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0)
975                         return 0;
976                 filp->f_pos = ++nr;
977                 /* fall through */
978         case 1:
979 -               if (filldir(dirent, "..", 2, nr, inode->i_ino) < 0)
980 +               if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0)
981                         return 0;
982                 filp->f_pos = ++nr;
983                 /* fall through */
984         default:
985                 while ( onr = nr, ent = autofs_hash_enum(dirhash,&nr,ent) ) {
986                         if ( !ent->dentry || ent->dentry->d_mounts != ent->dentry ) {
987 -                               if (filldir(dirent,ent->name,ent->len,onr,ent->ino) < 0)
988 +                               if (filldir(dirent,ent->name,ent->len,onr,ent->ino, DT_UNKNOWN) < 0)
989                                         return 0;
990                                 filp->f_pos = nr;
991                         }
992 diff -urN lfs-ref/fs/binfmt_aout.c lfs/fs/binfmt_aout.c
993 --- lfs-ref/fs/binfmt_aout.c    Wed Sep 12 02:05:57 2001
994 +++ lfs/fs/binfmt_aout.c        Wed Sep 12 02:42:14 2001
995 @@ -369,7 +369,11 @@
996                 file = fget(fd);
997  
998                 if (!file->f_op || !file->f_op->mmap ||
999 +#if 0
1000                     fd_offset & (bprm->dentry->d_inode->i_sb->s_blocksize-1)) {
1001 +#else /* LFS enforces PAGE_SIZE file offset granularity in mmap */
1002 +                   fd_offset & ~PAGE_MASK) {
1003 +#endif
1004                         if (warnings++<10)
1005                                 printk(KERN_NOTICE
1006                                        "fd_offset is not blocksize aligned. Loading %s in anonymous memory.\n",
1007 @@ -467,7 +471,11 @@
1008  
1009         start_addr =  ex.a_entry & 0xfffff000;
1010  
1011 +#if 0
1012         if (N_TXTOFF(ex) & (inode->i_sb->s_blocksize-1)) {
1013 +#else /* LFS enforces PAGE_SIZE file offset granularity in mmap */
1014 +       if (N_TXTOFF(ex) & ~PAGE_MASK) {
1015 +#endif
1016                 if (warnings++<10)
1017                         printk(KERN_NOTICE
1018                                "N_TXTOFF is not blocksize aligned. Loading library %s in anonymous memory.\n",
1019 diff -urN lfs-ref/fs/buffer.c lfs/fs/buffer.c
1020 --- lfs-ref/fs/buffer.c Wed Sep 12 02:39:58 2001
1021 +++ lfs/fs/buffer.c     Wed Sep 12 02:42:15 2001
1022 @@ -1219,7 +1219,7 @@
1023  #endif
1024         }
1025         if (test_and_clear_bit(PG_swap_unlock_after, &page->flags))
1026 -               swap_after_unlock_page(page->offset);
1027 +               swap_after_unlock_page(pgoff2ulong(page->index));
1028         if (test_and_clear_bit(PG_free_after, &page->flags))
1029                 __free_page(page);
1030  }
1031 @@ -1682,15 +1682,46 @@
1032         set_bit(PG_locked, &page->flags);
1033         set_bit(PG_free_after, &page->flags);
1034         
1035 +       /* Blocks within a page */
1036         i = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
1037 -       block = page->offset >> inode->i_sb->s_blocksize_bits;
1038 -       p = nr;
1039 -       do {
1040 -               *p = inode->i_op->bmap(inode, block);
1041 -               i--;
1042 -               block++;
1043 -               p++;
1044 -       } while (i > 0);
1045 +
1046 +       block = pgoff2ulong(page->index);
1047 +       /* Scaled already by PAGE_SHIFT, which said shift should
1048 +          be same or larger, than that of any filesystem in
1049 +          this system -- that is, at i386 with 4k pages one
1050 +          can't use 8k (primitive) blocks at the filesystems... */
1051 +
1052 +       if (i > 0) {
1053 +               /* Filesystem blocksize is same, or smaller than CPU
1054 +                  page size, we can easily process this.. */
1055 +
1056 +               if (i > 1)
1057 +                       block *= i;
1058 +               /* Scale by FS blocks per page, presuming FS-blocks are smaller
1059 +                  than the processor page... */
1060 +
1061 +               p = nr;
1062 +               do {
1063 +                       *p = inode->i_op->bmap(inode, block);
1064 +                       i--;
1065 +                       block++;
1066 +                       p++;
1067 +               } while (i > 0);
1068 +       } else {
1069 +               /* Filesystem blocksize is larger than CPU page size,
1070 +                  but if the underlying storage system block size is
1071 +                  smaller than CPU page size, all is well, else we
1072 +                  are in deep trouble -- for direct paging in at least.. */
1073 +               /* Nobody needs such monsterous fs block sizes ?
1074 +                  Well, it is the only way to get files in terabyte
1075 +                  range..  Nobody needs them ?  You are for a surprise..
1076 +                  However EXT2 (at least) needs access to internal
1077 +                  blocks and there it needs allocations of 8k/16k (or
1078 +                  whatever the block size is) for internal uses..
1079 +                  Fixing this function alone isn't enough, although
1080 +                  perhaps fairly trivial.. */
1081 +               /* FIXME: WRITE THE CODE HERE !!! */
1082 +       }
1083  
1084         /* IO start */
1085         brw_page(READ, page, inode->i_dev, nr, inode->i_sb->s_blocksize, 1);
1086 diff -urN lfs-ref/fs/coda/dir.c lfs/fs/coda/dir.c
1087 --- lfs-ref/fs/coda/dir.c       Tue Sep  5 02:28:47 2000
1088 +++ lfs/fs/coda/dir.c   Wed Sep 12 02:42:15 2001
1089 @@ -749,7 +749,7 @@
1090                          char *name  = vdirent->d_name;
1091  
1092                         errfill = filldir(getdent,  name, namlen, 
1093 -                                         offs, ino); 
1094 +                                         offs, ino, DT_UNKNOWN);
1095  CDEBUG(D_FILE, "entry %d: ino %ld, namlen %d, reclen %d, type %d, pos %d, string_offs %d, name %*s, offset %d, result: %d, errfill: %d.\n", i,vdirent->d_fileno, vdirent->d_namlen, vdirent->d_reclen, vdirent->d_type, pos,  string_offset, vdirent->d_namlen, vdirent->d_name, (u_int) offs, result, errfill);
1096                         /* errfill means no space for filling in this round */
1097                         if ( errfill < 0 ) {
1098 diff -urN lfs-ref/fs/coda/file.c lfs/fs/coda/file.c
1099 --- lfs-ref/fs/coda/file.c      Fri Apr 20 22:31:20 2001
1100 +++ lfs/fs/coda/file.c  Wed Sep 12 02:42:15 2001
1101 @@ -99,7 +99,7 @@
1102                               &cont_file, &cont_dentry);
1103  
1104          CDEBUG(D_INODE, "coda ino: %ld, cached ino %ld, page offset: %lx\n", 
1105 -              coda_inode->i_ino, cii->c_ovp->i_ino, page->offset);
1106 +              coda_inode->i_ino, cii->c_ovp->i_ino, pgoff2ulong(page->index));
1107  
1108          generic_readpage(&cont_file, page);
1109          EXIT;
1110 diff -urN lfs-ref/fs/devpts/root.c lfs/fs/devpts/root.c
1111 --- lfs-ref/fs/devpts/root.c    Mon Jan 17 16:44:41 2000
1112 +++ lfs/fs/devpts/root.c        Wed Sep 12 02:42:15 2001
1113 @@ -86,12 +86,12 @@
1114         switch(nr)
1115         {
1116         case 0:
1117 -               if (filldir(dirent, ".", 1, nr, inode->i_ino) < 0)
1118 +               if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0)
1119                         return 0;
1120                 filp->f_pos = ++nr;
1121                 /* fall through */
1122         case 1:
1123 -               if (filldir(dirent, "..", 2, nr, inode->i_ino) < 0)
1124 +               if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0)
1125                         return 0;
1126                 filp->f_pos = ++nr;
1127                 /* fall through */
1128 @@ -100,7 +100,7 @@
1129                         int ptynr = nr - 2;
1130                         if ( sbi->inodes[ptynr] ) {
1131                                 genptsname(numbuf, ptynr);
1132 -                               if ( filldir(dirent, numbuf, strlen(numbuf), nr, nr) < 0 )
1133 +                               if ( filldir(dirent, numbuf, strlen(numbuf), nr, nr, DT_CHR) < 0 )
1134                                         return 0;
1135                         }
1136                         filp->f_pos = ++nr;
1137 diff -urN lfs-ref/fs/dquot.c lfs/fs/dquot.c
1138 --- lfs-ref/fs/dquot.c  Wed Sep 12 02:05:57 2001
1139 +++ lfs/fs/dquot.c      Wed Sep 12 02:42:15 2001
1140 @@ -1529,7 +1529,7 @@
1141         if (!S_ISREG(inode->i_mode))
1142                 goto out_f;
1143         error = -EINVAL;
1144 -       if (inode->i_size == 0 || (inode->i_size % sizeof(struct dqblk)) != 0)
1145 +       if (inode->i_size == 0 || ((off_t)inode->i_size % sizeof(struct dqblk)) != 0)
1146                 goto out_f;
1147         dquot_drop(inode);      /* We don't want quota on quota files */
1148  
1149 diff -urN lfs-ref/fs/efs/dir.c lfs/fs/efs/dir.c
1150 --- lfs-ref/fs/efs/dir.c        Mon Jan 17 16:44:41 2000
1151 +++ lfs/fs/efs/dir.c    Wed Sep 12 02:42:15 2001
1152 @@ -107,7 +107,7 @@
1153                                 filp->f_pos = (block << EFS_DIRBSIZE_BITS) | slot;
1154  
1155                                 /* copy filename and data in dirslot */
1156 -                               filldir(dirent, nameptr, namelen, filp->f_pos, inodenum);
1157 +                               filldir(dirent, nameptr, namelen, filp->f_pos, inodenum, DT_UNKNOWN);
1158  
1159                                 /* sanity check */
1160                                 if (nameptr - (char *) dirblock + namelen > EFS_DIRBSIZE) {
1161 diff -urN lfs-ref/fs/ext2/dir.c lfs/fs/ext2/dir.c
1162 --- lfs-ref/fs/ext2/dir.c       Thu May  4 13:00:39 2000
1163 +++ lfs/fs/ext2/dir.c   Wed Sep 12 02:42:15 2001
1164 @@ -32,6 +32,10 @@
1165         return -EISDIR;
1166  }
1167  
1168 +static unsigned char ext2_filetype_table[] = {
1169 +       DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
1170 +};
1171 +
1172  static int ext2_readdir(struct file *, void *, filldir_t);
1173  
1174  static struct file_operations ext2_dir_operations = {
1175 @@ -201,10 +205,14 @@
1176                                  * the descriptor.
1177                                  */
1178                                 unsigned long version = filp->f_version;
1179 +                               unsigned char d_type = DT_UNKNOWN;
1180  
1181 +                               if (EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_FILETYPE)
1182 +                                   && de->file_type < EXT2_FT_MAX)
1183 +                                       d_type = ext2_filetype_table[de->file_type];
1184                                 error = filldir(dirent, de->name,
1185                                                 de->name_len,
1186 -                                               filp->f_pos, le32_to_cpu(de->inode));
1187 +                                               filp->f_pos, le32_to_cpu(de->inode), d_type);
1188                                 if (error)
1189                                         break;
1190                                 if (version != filp->f_version)
1191 diff -urN lfs-ref/fs/ext2/file.c lfs/fs/ext2/file.c
1192 --- lfs-ref/fs/ext2/file.c      Wed Sep 12 02:39:57 2001
1193 +++ lfs/fs/ext2/file.c  Wed Sep 12 02:42:15 2001
1194 @@ -39,10 +39,6 @@
1195  static long long ext2_file_lseek(struct file *, long long, int);
1196  static ssize_t ext2_file_write (struct file *, const char *, size_t, loff_t *);
1197  static int ext2_release_file (struct inode *, struct file *);
1198 -#if BITS_PER_LONG < 64
1199 -static int ext2_open_file (struct inode *, struct file *);
1200 -
1201 -#else
1202  
1203  #define EXT2_MAX_SIZE(bits)                                                    \
1204         (((EXT2_NDIR_BLOCKS + (1LL << (bits - 2)) +                             \
1205 @@ -55,8 +51,6 @@
1206  EXT2_MAX_SIZE(10), EXT2_MAX_SIZE(11), EXT2_MAX_SIZE(12), EXT2_MAX_SIZE(13)
1207  };
1208  
1209 -#endif
1210 -
1211  /*
1212   * We have mostly NULL's here: the current defaults are ok for
1213   * the ext2 filesystem.
1214 @@ -69,11 +63,7 @@
1215         NULL,                   /* poll - default */
1216         ext2_ioctl,             /* ioctl */
1217         generic_file_mmap,      /* mmap */
1218 -#if BITS_PER_LONG == 64        
1219         NULL,                   /* no special open is needed */
1220 -#else
1221 -       ext2_open_file,
1222 -#endif
1223         NULL,                   /* flush */
1224         ext2_release_file,      /* release */
1225         ext2_sync_file,         /* fsync */
1226 @@ -120,14 +110,9 @@
1227                 case 1:
1228                         offset += file->f_pos;
1229         }
1230 -#if BITS_PER_LONG < 64
1231 -       if (offset >> 31)
1232 -               return -EINVAL;
1233 -#else
1234         if (offset < 0 ||
1235             offset > ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(inode->i_sb)])
1236                 return -EINVAL;
1237 -#endif
1238         if (offset != file->f_pos) {
1239                 file->f_pos = offset;
1240                 file->f_reada = 0;
1241 @@ -155,7 +140,7 @@
1242                                 size_t count, loff_t *ppos)
1243  {
1244         struct inode * inode = filp->f_dentry->d_inode;
1245 -       off_t pos;
1246 +       loff_t pos;
1247         long block;
1248         int offset;
1249         size_t written, c;
1250 @@ -202,24 +187,17 @@
1251  
1252         /* Check for overflow.. */
1253  
1254 -#if BITS_PER_LONG < 64
1255 -       /* If the fd's pos is already greater than or equal to the file
1256 -        * descriptor's offset maximum, then we need to return EFBIG for
1257 -        * any non-zero count (and we already tested for zero above). */
1258 -       if (((unsigned long) pos) >= 0x7FFFFFFFUL)
1259 -               return -EFBIG;
1260 -       
1261 -       /* If we are about to overflow the maximum file size, we also
1262 -        * need to return the error, but only if no bytes can be written
1263 -        * successfully. */
1264 -       if (((unsigned long) pos + count) > 0x7FFFFFFFUL) {
1265 -               count = 0x7FFFFFFFL - pos;
1266 -               if (((ssize_t) count) < 0)
1267 +       /* L-F-S spec 2.2.1.27: */
1268 +       if (!(filp->f_flags & O_LARGEFILE)) {
1269 +               if (pos >= 0x7fffffffULL) /* pos@2G forbidden */
1270                         return -EFBIG;
1271         }
1272 -#else
1273
1274 +               if (pos + count > 0x7fffffffULL)
1275 +                       /* Write only until end of allowed region */
1276 +                       count = 0x7fffffffULL - pos;
1277         {
1278 -               off_t max = ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(sb)];
1279 +               loff_t max = ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(sb)];
1280  
1281                 if (pos >= max)
1282                         return -EFBIG;
1283 @@ -239,20 +217,18 @@
1284                         mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
1285                 }
1286         }
1287 -#endif
1288  
1289         /* From SUS: We must generate a SIGXFSZ for file size overflow
1290          * only if no bytes were actually written to the file. --sct */
1291  
1292         limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
1293 -       if (limit < RLIM_INFINITY) {
1294 -               if (((size_t) pos+count) >= limit) {
1295 -                       count = limit - pos;
1296 -                       if (((ssize_t) count) <= 0) {
1297 -                               send_sig(SIGXFSZ, current, 0);
1298 -                               return -EFBIG;
1299 -                       }
1300 +       if (limit != RLIM_INFINITY) {
1301 +               if (pos >= limit) {
1302 +                       send_sig(SIGXFSZ, current, 0);
1303 +                       return -EFBIG;
1304                 }
1305 +               if (pos+count > limit)
1306 +                       count = limit - pos;
1307         }
1308  
1309         /*
1310 @@ -382,15 +358,3 @@
1311         return 0;
1312  }
1313  
1314 -#if BITS_PER_LONG < 64
1315 -/*
1316 - * Called when an inode is about to be open.
1317 - * We use this to disallow opening RW large files on 32bit systems.
1318 - */
1319 -static int ext2_open_file (struct inode * inode, struct file * filp)
1320 -{
1321 -       if (inode->u.ext2_i.i_high_size && (filp->f_mode & FMODE_WRITE))
1322 -               return -EFBIG;
1323 -       return 0;
1324 -}
1325 -#endif
1326 diff -urN lfs-ref/fs/ext2/inode.c lfs/fs/ext2/inode.c
1327 --- lfs-ref/fs/ext2/inode.c     Wed Sep 12 02:39:57 2001
1328 +++ lfs/fs/ext2/inode.c Wed Sep 12 02:42:15 2001
1329 @@ -537,15 +537,8 @@
1330                 inode->u.ext2_i.i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
1331         else {
1332                 inode->u.ext2_i.i_dir_acl = 0;
1333 -               inode->u.ext2_i.i_high_size =
1334 -                       le32_to_cpu(raw_inode->i_size_high);
1335 -#if BITS_PER_LONG < 64
1336 -               if (raw_inode->i_size_high)
1337 -                       inode->i_size = (__u32)-1;
1338 -#else
1339 -               inode->i_size |= ((__u64)le32_to_cpu(raw_inode->i_size_high))
1340 -                       << 32;
1341 -#endif
1342 +               inode->i_size = ((__u64)(inode->i_size & 0xFFFFFFFFUL)) |
1343 +                       (((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32);
1344         }
1345         inode->u.ext2_i.i_block_group = block_group;
1346         inode->u.ext2_i.i_next_alloc_block = 0;
1347 @@ -667,12 +660,7 @@
1348         if (S_ISDIR(inode->i_mode))
1349                 raw_inode->i_dir_acl = cpu_to_le32(inode->u.ext2_i.i_dir_acl);
1350         else { 
1351 -#if BITS_PER_LONG < 64
1352 -               raw_inode->i_size_high =
1353 -                       cpu_to_le32(inode->u.ext2_i.i_high_size);
1354 -#else
1355                 raw_inode->i_size_high = cpu_to_le32(inode->i_size >> 32);
1356 -#endif
1357         }
1358         if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
1359                 raw_inode->i_block[0] = cpu_to_le32(kdev_t_to_nr(inode->i_rdev));
1360 @@ -724,21 +712,18 @@
1361         }
1362  
1363         if (iattr->ia_valid & ATTR_SIZE) {
1364 -               off_t size = iattr->ia_size;
1365 +               loff_t size = iattr->ia_size;
1366                 unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
1367  
1368                 if (size < 0)
1369                         return -EINVAL;
1370 -#if BITS_PER_LONG == 64        
1371                 if (size > ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(inode->i_sb)])
1372                         return -EFBIG;
1373 -#endif
1374 -               if (limit < RLIM_INFINITY && size > limit) {
1375 +               if (limit != RLIM_INFINITY && size > limit) {
1376                         send_sig(SIGXFSZ, current, 0);
1377                         return -EFBIG;
1378                 }
1379  
1380 -#if BITS_PER_LONG == 64        
1381                 if (size >> 31) {
1382                         struct super_block *sb = inode->i_sb;
1383                         struct ext2_super_block *es = sb->u.ext2_sb.s_es;
1384 @@ -751,7 +736,6 @@
1385                                 mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
1386                         }
1387                 }
1388 -#endif
1389         }
1390         
1391         retval = inode_change_ok(inode, iattr);
1392 diff -urN lfs-ref/fs/ext2/truncate.c lfs/fs/ext2/truncate.c
1393 --- lfs-ref/fs/ext2/truncate.c  Mon Dec 11 16:58:00 2000
1394 +++ lfs/fs/ext2/truncate.c      Wed Sep 12 02:42:15 2001
1395 @@ -53,9 +53,10 @@
1396   * Currently we always hold the inode semaphore during truncate, so
1397   * there's no need to test for changes during the operation.
1398   */
1399 -#define DIRECT_BLOCK(inode) \
1400 -       ((inode->i_size + inode->i_sb->s_blocksize - 1) / \
1401 -                         inode->i_sb->s_blocksize)
1402 +#define DIRECT_BLOCK(inode)    \
1403 +       ((long)                 \
1404 +        ((inode->i_size + inode->i_sb->s_blocksize - 1) >> \
1405 +                         inode->i_sb->s_blocksize_bits))
1406  #define INDIRECT_BLOCK(inode,offset) ((int)DIRECT_BLOCK(inode) - offset)
1407  #define DINDIRECT_BLOCK(inode,offset) \
1408         (INDIRECT_BLOCK(inode,offset) / addr_per_block)
1409 diff -urN lfs-ref/fs/fat/dir.c lfs/fs/fat/dir.c
1410 --- lfs-ref/fs/fat/dir.c        Mon Dec 11 16:58:00 2000
1411 +++ lfs/fs/fat/dir.c    Wed Sep 12 02:42:15 2001
1412 @@ -315,7 +315,7 @@
1413  /* Fake . and .. for the root directory. */
1414         if (inode->i_ino == MSDOS_ROOT_INO) {
1415                 while (cpos < 2) {
1416 -                       if (filldir(dirent, "..", cpos+1, cpos, MSDOS_ROOT_INO) < 0)
1417 +                       if (filldir(dirent, "..", cpos+1, cpos, MSDOS_ROOT_INO, DT_DIR) < 0)
1418                                 return 0;
1419                         cpos++;
1420                         filp->f_pos++;
1421 @@ -458,7 +458,8 @@
1422         if (!long_slots||shortnames) {
1423                 if (both)
1424                         bufname[i] = '\0';
1425 -               if (filldir(dirent, bufname, i, *furrfu, inum) < 0)
1426 +               if (filldir(dirent, bufname, i, *furrfu, inum,
1427 +                           (de->attr & ATTR_DIR) ? DT_DIR : DT_REG) < 0)
1428                         goto FillFailed;
1429         } else {
1430                 char longname[275];
1431 @@ -469,7 +470,8 @@
1432                         memcpy(&longname[long_len+1], bufname, i);
1433                         long_len += i;
1434                 }
1435 -               if (filldir(dirent, longname, long_len, *furrfu, inum) < 0)
1436 +               if (filldir(dirent, longname, long_len, *furrfu, inum,
1437 +                           (de->attr & ATTR_DIR) ? DT_DIR : DT_REG) < 0)
1438                         goto FillFailed;
1439         }
1440  
1441 @@ -499,7 +501,8 @@
1442         const char * name,
1443         int name_len,
1444         off_t offset,
1445 -       ino_t ino)
1446 +       ino_t ino,
1447 +       unsigned int d_type)
1448  {
1449         struct dirent *d1 = (struct dirent *)buf;
1450         struct dirent *d2 = d1 + 1;
1451 diff -urN lfs-ref/fs/fat/file.c lfs/fs/fat/file.c
1452 --- lfs-ref/fs/fat/file.c       Mon Jan 17 16:44:42 2000
1453 +++ lfs/fs/fat/file.c   Wed Sep 12 02:42:15 2001
1454 @@ -227,7 +227,7 @@
1455                 Each time we process one block in bhlist, we replace
1456                 it by a new prefetch block if needed.
1457         */
1458 -       PRINTK (("#### ino %ld pos %ld size %ld count %d\n",inode->i_ino,*ppos,inode->i_size,count));
1459 +       PRINTK (("#### ino %ld pos %ld size %ld count %d\n",inode->i_ino,*ppos,(u_long)inode->i_size,count));
1460         {
1461                 /*
1462                         We must prefetch complete block, so we must
1463 @@ -253,7 +253,7 @@
1464         }
1465         pre.nolist = 0;
1466         PRINTK (("count %d ahead %d nblist %d\n",count,read_ahead[MAJOR(inode->i_dev)],pre.nblist));
1467 -       while ((left_in_file = inode->i_size - *ppos) > 0
1468 +       while ((left_in_file = (u_long)inode->i_size - *ppos) > 0
1469                 && buf < end){
1470                 struct buffer_head *bh = pre.bhlist[pre.nolist];
1471                 char *data;
1472 @@ -451,7 +451,7 @@
1473  
1474  void fat_truncate(struct inode *inode)
1475  {
1476 -       int cluster;
1477 +       int cluster_bytes, cluster_shift;
1478  
1479         /* Why no return value?  Surely the disk could fail... */
1480         if (IS_IMMUTABLE(inode))
1481 @@ -460,8 +460,10 @@
1482                 printk("FAT: fat_truncate called though fs is read-only, uhh...\n");
1483                 return /* -EROFS */;
1484         }
1485 -       cluster = SECTOR_SIZE*MSDOS_SB(inode->i_sb)->cluster_size;
1486 -       (void) fat_free(inode,(inode->i_size+(cluster-1))/cluster);
1487 +       cluster_bytes = SECTOR_SIZE * MSDOS_SB(inode->i_sb)->cluster_size;
1488 +       cluster_shift = fslog2(cluster_bytes);
1489 +       (void) fat_free(inode,
1490 +                       (inode->i_size+(cluster_bytes-1)) >> cluster_shift);
1491         MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
1492         mark_inode_dirty(inode);
1493  }
1494 diff -urN lfs-ref/fs/fat/inode.c lfs/fs/fat/inode.c
1495 --- lfs-ref/fs/fat/inode.c      Mon Dec 11 16:58:00 2000
1496 +++ lfs/fs/fat/inode.c  Wed Sep 12 02:42:15 2001
1497 @@ -399,8 +399,9 @@
1498                         sizeof(struct msdos_dir_entry);
1499         }
1500         inode->i_blksize = MSDOS_SB(sb)->cluster_size* SECTOR_SIZE;
1501 -       inode->i_blocks = (inode->i_size+inode->i_blksize-1)/
1502 -                   inode->i_blksize*MSDOS_SB(sb)->cluster_size;
1503 +               inode->i_blocks = (((inode->i_size+inode->i_blksize-1) >>
1504 +                                   fslog2(inode->i_blksize)) *
1505 +                                  MSDOS_SB(sb)->cluster_size);
1506         MSDOS_I(inode)->i_logstart = 0;
1507  
1508         MSDOS_I(inode)->i_attrs = 0;
1509 @@ -830,8 +831,9 @@
1510         MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED;
1511         /* this is as close to the truth as we can get ... */
1512         inode->i_blksize = MSDOS_SB(sb)->cluster_size*SECTOR_SIZE;
1513 -       inode->i_blocks = (inode->i_size+inode->i_blksize-1)/
1514 -           inode->i_blksize*MSDOS_SB(sb)->cluster_size;
1515 +       inode->i_blocks = (((inode->i_size+inode->i_blksize-1) >>
1516 +                           fslog2(inode->i_blksize)) *
1517 +                          MSDOS_SB(sb)->cluster_size);
1518         inode->i_mtime = inode->i_atime =
1519             date_dos2unix(CF_LE_W(de->time),CF_LE_W(de->date));
1520         inode->i_ctime =
1521 diff -urN lfs-ref/fs/fcntl.c lfs/fs/fcntl.c
1522 --- lfs-ref/fs/fcntl.c  Wed Sep 12 02:39:56 2001
1523 +++ lfs/fs/fcntl.c      Wed Sep 12 02:42:15 2001
1524 @@ -145,17 +145,11 @@
1525         return 0;
1526  }
1527  
1528 -asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
1529 -{      
1530 -       struct file * filp;
1531 -       long err = -EBADF;
1532 -
1533 -       lock_kernel();
1534 -       filp = fget(fd);
1535 -       if (!filp)
1536 -               goto out;
1537 +static long do_fcntl(unsigned int fd, unsigned int cmd,
1538 +                    unsigned long arg, struct file * filp)
1539 +{
1540 +       long err = 0;
1541  
1542 -       err = 0;
1543         switch (cmd) {
1544                 case F_DUPFD:
1545                         err = dupfd(fd, arg);
1546 @@ -219,11 +213,60 @@
1547                                 err = sock_fcntl (filp, cmd, arg);
1548                         break;
1549         }
1550 +
1551 +       return err;
1552 +}
1553 +
1554 +asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
1555 +{      
1556 +       struct file * filp;
1557 +       long err = -EBADF;
1558 +
1559 +       lock_kernel();
1560 +       filp = fget(fd);
1561 +       if (!filp)
1562 +               goto out;
1563 +
1564 +       err = do_fcntl(fd, cmd, arg, filp);
1565 +
1566 +       fput(filp);
1567 +out:
1568 +       unlock_kernel();
1569 +       return err;
1570 +}
1571 +
1572 +#if BITS_PER_LONG == 32
1573 +asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
1574 +{      
1575 +       struct file * filp;
1576 +       long err = -EBADF;
1577 +
1578 +       lock_kernel();
1579 +       filp = fget(fd);
1580 +       if (!filp)
1581 +               goto out;
1582 +
1583 +       switch (cmd) {
1584 +               case F_GETLK64:
1585 +                       err = fcntl_getlk64(fd, (struct flock64 *) arg);
1586 +                       break;
1587 +               case F_SETLK64:
1588 +                       err = fcntl_setlk64(fd, cmd, (struct flock64 *) arg);
1589 +                       break;
1590 +               case F_SETLKW64:
1591 +                       err = fcntl_setlk64(fd, cmd, (struct flock64 *) arg);
1592 +                       break;
1593 +               default:
1594 +                       err = do_fcntl(fd, cmd, arg, filp);
1595 +                       break;
1596 +       }
1597 +
1598         fput(filp);
1599  out:
1600         unlock_kernel();
1601         return err;
1602  }
1603 +#endif
1604  
1605  /* Table to convert sigio signal codes into poll band bitmaps */
1606  
1607 diff -urN lfs-ref/fs/hfs/dir_cap.c lfs/fs/hfs/dir_cap.c
1608 --- lfs-ref/fs/hfs/dir_cap.c    Mon Jan 17 16:44:42 2000
1609 +++ lfs/fs/hfs/dir_cap.c        Wed Sep 12 02:42:15 2001
1610 @@ -243,7 +243,7 @@
1611  
1612         if (filp->f_pos == 0) {
1613                 /* Entry 0 is for "." */
1614 -               if (filldir(dirent, DOT->Name, DOT_LEN, 0, dir->i_ino)) {
1615 +               if (filldir(dirent, DOT->Name, DOT_LEN, 0, dir->i_ino, DT_DIR)) {
1616                         return 0;
1617                 }
1618                 filp->f_pos = 1;
1619 @@ -260,7 +260,7 @@
1620                 }
1621  
1622                 if (filldir(dirent, DOT_DOT->Name,
1623 -                           DOT_DOT_LEN, 1, ntohl(cnid))) {
1624 +                           DOT_DOT_LEN, 1, ntohl(cnid), DT_DIR)) {
1625                         return 0;
1626                 }
1627                 filp->f_pos = 2;
1628 @@ -287,7 +287,7 @@
1629                                 len = hfs_namein(dir, tmp_name,
1630                                     &((struct hfs_cat_key *)brec.key)->CName);
1631                                 if (filldir(dirent, tmp_name, len,
1632 -                                           filp->f_pos, ino)) {
1633 +                                           filp->f_pos, ino, DT_UNKNOWN)) {
1634                                         hfs_cat_close(entry, &brec);
1635                                         return 0;
1636                                 }
1637 @@ -303,7 +303,7 @@
1638                         /* In root dir last-2 entry is for ".rootinfo" */
1639                         if (filldir(dirent, DOT_ROOTINFO->Name,
1640                                     DOT_ROOTINFO_LEN, filp->f_pos,
1641 -                                   ntohl(entry->cnid) | HFS_CAP_FNDR)) {
1642 +                                   ntohl(entry->cnid) | HFS_CAP_FNDR, DT_UNKNOWN)) {
1643                                 return 0;
1644                         }
1645                 }
1646 @@ -315,7 +315,7 @@
1647                         /* In normal dirs last-1 entry is for ".finderinfo" */
1648                         if (filldir(dirent, DOT_FINDERINFO->Name,
1649                                     DOT_FINDERINFO_LEN, filp->f_pos,
1650 -                                   ntohl(entry->cnid) | HFS_CAP_FDIR)) {
1651 +                                   ntohl(entry->cnid) | HFS_CAP_FDIR, DT_UNKNOWN)) {
1652                                 return 0;
1653                         }
1654                 }
1655 @@ -327,7 +327,7 @@
1656                         /* In normal dirs last entry is for ".resource" */
1657                         if (filldir(dirent, DOT_RESOURCE->Name,
1658                                     DOT_RESOURCE_LEN, filp->f_pos,
1659 -                                   ntohl(entry->cnid) | HFS_CAP_RDIR)) {
1660 +                                   ntohl(entry->cnid) | HFS_CAP_RDIR, DT_UNKNOWN)) {
1661                                 return 0;
1662                         }
1663                 }
1664 diff -urN lfs-ref/fs/hfs/dir_dbl.c lfs/fs/hfs/dir_dbl.c
1665 --- lfs-ref/fs/hfs/dir_dbl.c    Mon Jan 17 16:44:42 2000
1666 +++ lfs/fs/hfs/dir_dbl.c        Wed Sep 12 02:42:15 2001
1667 @@ -206,7 +206,7 @@
1668  
1669         if (filp->f_pos == 0) {
1670                 /* Entry 0 is for "." */
1671 -               if (filldir(dirent, DOT->Name, DOT_LEN, 0, dir->i_ino)) {
1672 +               if (filldir(dirent, DOT->Name, DOT_LEN, 0, dir->i_ino, DT_DIR)) {
1673                         return 0;
1674                 }
1675                 filp->f_pos = 1;
1676 @@ -215,7 +215,7 @@
1677         if (filp->f_pos == 1) {
1678                 /* Entry 1 is for ".." */
1679                 if (filldir(dirent, DOT_DOT->Name, DOT_DOT_LEN, 1,
1680 -                           hfs_get_hl(entry->key.ParID))) {
1681 +                           hfs_get_hl(entry->key.ParID), DT_DIR)) {
1682                         return 0;
1683                 }
1684                 filp->f_pos = 2;
1685 @@ -252,7 +252,7 @@
1686                                     &((struct hfs_cat_key *)brec.key)->CName);
1687                         }
1688  
1689 -                       if (filldir(dirent, tmp_name, len, filp->f_pos, ino)) {
1690 +                       if (filldir(dirent, tmp_name, len, filp->f_pos, ino, DT_UNKNOWN)) {
1691                                 hfs_cat_close(entry, &brec);
1692                                 return 0;
1693                         }
1694 @@ -266,7 +266,7 @@
1695                         /* In root dir last entry is for "%RootInfo" */
1696                         if (filldir(dirent, PCNT_ROOTINFO->Name,
1697                                     PCNT_ROOTINFO_LEN, filp->f_pos,
1698 -                                   ntohl(entry->cnid) | HFS_DBL_HDR)) {
1699 +                                   ntohl(entry->cnid) | HFS_DBL_HDR, DT_UNKNOWN)) {
1700                                 return 0;
1701                         }
1702                 }
1703 diff -urN lfs-ref/fs/hfs/dir_nat.c lfs/fs/hfs/dir_nat.c
1704 --- lfs-ref/fs/hfs/dir_nat.c    Mon Jan 17 16:44:42 2000
1705 +++ lfs/fs/hfs/dir_nat.c        Wed Sep 12 02:42:15 2001
1706 @@ -231,7 +231,7 @@
1707  
1708         if (filp->f_pos == 0) {
1709                 /* Entry 0 is for "." */
1710 -               if (filldir(dirent, DOT->Name, DOT_LEN, 0, dir->i_ino)) {
1711 +               if (filldir(dirent, DOT->Name, DOT_LEN, 0, dir->i_ino, DT_DIR)) {
1712                         return 0;
1713                 }
1714                 filp->f_pos = 1;
1715 @@ -248,7 +248,7 @@
1716                 }
1717  
1718                 if (filldir(dirent, DOT_DOT->Name,
1719 -                           DOT_DOT_LEN, 1, ntohl(cnid))) {
1720 +                           DOT_DOT_LEN, 1, ntohl(cnid), DT_DIR)) {
1721                         return 0;
1722                 }
1723                 filp->f_pos = 2;
1724 @@ -275,7 +275,7 @@
1725                                 len = hfs_namein(dir, tmp_name,
1726                                     &((struct hfs_cat_key *)brec.key)->CName);
1727                                 if (filldir(dirent, tmp_name, len,
1728 -                                           filp->f_pos, ino)) {
1729 +                                           filp->f_pos, ino, DT_UNKNOWN)) {
1730                                         hfs_cat_close(entry, &brec);
1731                                         return 0;
1732                                 }
1733 @@ -290,14 +290,14 @@
1734                         /* In normal dirs entry 2 is for ".AppleDouble" */
1735                         if (filldir(dirent, DOT_APPLEDOUBLE->Name,
1736                                     DOT_APPLEDOUBLE_LEN, filp->f_pos,
1737 -                                   ntohl(entry->cnid) | HFS_NAT_HDIR)) {
1738 +                                   ntohl(entry->cnid) | HFS_NAT_HDIR, DT_UNKNOWN)) {
1739                                 return 0;
1740                         }
1741                 } else if (type == HFS_NAT_HDIR) {
1742                         /* In .AppleDouble entry 2 is for ".Parent" */
1743                         if (filldir(dirent, DOT_PARENT->Name,
1744                                     DOT_PARENT_LEN, filp->f_pos,
1745 -                                   ntohl(entry->cnid) | HFS_NAT_HDR)) {
1746 +                                   ntohl(entry->cnid) | HFS_NAT_HDR, DT_UNKNOWN)) {
1747                                 return 0;
1748                         }
1749                 }
1750 @@ -310,7 +310,7 @@
1751                     (type == HFS_NAT_HDIR)) {
1752                         if (filldir(dirent, ROOTINFO->Name,
1753                                     ROOTINFO_LEN, filp->f_pos,
1754 -                                   ntohl(entry->cnid) | HFS_NAT_HDR)) {
1755 +                                   ntohl(entry->cnid) | HFS_NAT_HDR, DT_UNKNOWN)) {
1756                                 return 0;
1757                         }
1758                 }
1759 diff -urN lfs-ref/fs/hpfs/hpfs_fs.c lfs/fs/hpfs/hpfs_fs.c
1760 --- lfs-ref/fs/hpfs/hpfs_fs.c   Mon Jan 17 16:44:42 2000
1761 +++ lfs/fs/hpfs/hpfs_fs.c       Wed Sep 12 02:42:15 2001
1762 @@ -1376,13 +1376,13 @@
1763                 break;
1764  
1765         case 0:
1766 -               if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino) < 0)
1767 +               if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino, DT_DIR) < 0)
1768                         break;
1769                 filp->f_pos = -1;
1770                 /* fall through */
1771  
1772         case -1:
1773 -               if (filldir(dirent, "..", 2, filp->f_pos, inode->i_hpfs_parent_dir) < 0)
1774 +               if (filldir(dirent, "..", 2, filp->f_pos, inode->i_hpfs_parent_dir, DT_DIR) < 0)
1775                         break;
1776                 filp->f_pos = 1;
1777                 /* fall through */
1778 @@ -1402,7 +1402,7 @@
1779                         else
1780                                 ino = file_ino(de->fnode);
1781                         brelse4(&qbh);
1782 -                       if (filldir(dirent, tempname, namelen, old_pos, ino) < 0) {
1783 +                       if (filldir(dirent, tempname, namelen, old_pos, ino, DT_UNKNOWN) < 0) {
1784                                 filp->f_pos = old_pos;
1785                                 break;
1786                         }
1787 diff -urN lfs-ref/fs/isofs/dir.c lfs/fs/isofs/dir.c
1788 --- lfs-ref/fs/isofs/dir.c      Fri Apr 20 22:31:20 2001
1789 +++ lfs/fs/isofs/dir.c  Wed Sep 12 02:42:15 2001
1790 @@ -206,7 +206,7 @@
1791  
1792                 /* Handle the case of the '.' directory */
1793                 if (de->name_len[0] == 1 && de->name[0] == 0) {
1794 -                       if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino) < 0)
1795 +                       if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino, DT_DIR) < 0)
1796                                 break;
1797                         filp->f_pos += de_len;
1798                         continue;
1799 @@ -217,7 +217,7 @@
1800                 /* Handle the case of the '..' directory */
1801                 if (de->name_len[0] == 1 && de->name[0] == 1) {
1802                         inode_number = filp->f_dentry->d_parent->d_inode->i_ino;
1803 -                       if (filldir(dirent, "..", 2, filp->f_pos, inode_number) < 0)
1804 +                       if (filldir(dirent, "..", 2, filp->f_pos, inode_number, DT_DIR) < 0)
1805                                 break;
1806                         filp->f_pos += de_len;
1807                         continue;
1808 @@ -261,7 +261,7 @@
1809                         }
1810                 }
1811                 if (len > 0) {
1812 -                       if (filldir(dirent, p, len, filp->f_pos, inode_number) < 0)
1813 +                       if (filldir(dirent, p, len, filp->f_pos, inode_number, DT_UNKNOWN) < 0)
1814                                 break;
1815                 }
1816                 filp->f_pos += de_len;
1817 diff -urN lfs-ref/fs/isofs/inode.c lfs/fs/isofs/inode.c
1818 --- lfs-ref/fs/isofs/inode.c    Fri Apr 20 22:31:20 2001
1819 +++ lfs/fs/isofs/inode.c        Wed Sep 12 02:42:15 2001
1820 @@ -908,7 +908,8 @@
1821  
1822  int isofs_bmap(struct inode * inode,int block)
1823  {
1824 -       off_t b_off, offset, size;
1825 +       loff_t b_off;
1826 +       unsigned offset, size;
1827         struct inode *ino;
1828         unsigned int firstext;
1829         unsigned long nextino;
1830 @@ -919,7 +920,7 @@
1831                 return 0;
1832         }
1833  
1834 -       b_off = block << ISOFS_BUFFER_BITS(inode);
1835 +       b_off = (loff_t)block << ISOFS_BUFFER_BITS(inode);
1836  
1837         /*
1838          * If we are beyond the end of this file, don't give out any
1839 @@ -927,7 +928,7 @@
1840          */
1841         if( b_off >= inode->i_size )
1842           {
1843 -           off_t       max_legal_read_offset;
1844 +           loff_t      max_legal_read_offset;
1845  
1846             /*
1847              * If we are *way* beyond the end of the file, print a message.
1848 @@ -942,7 +943,7 @@
1849             if( b_off >= max_legal_read_offset )
1850               {
1851  
1852 -               printk("_isofs_bmap: block>= EOF(%d, %ld)\n", block,
1853 +               printk("_isofs_bmap: block>= EOF(%d, %Ld)\n", block,
1854                        inode->i_size);
1855               }
1856             return 0;
1857 @@ -1209,7 +1210,7 @@
1858  
1859  #ifdef DEBUG
1860         printk("Get inode %x: %d %d: %d\n",inode->i_ino, block,
1861 -              ((int)pnt) & 0x3ff, inode->i_size);
1862 +              ((int)pnt) & 0x3ff, (u_long)inode->i_size);
1863  #endif
1864  
1865         inode->i_mtime = inode->i_atime = inode->i_ctime =
1866 diff -urN lfs-ref/fs/lockd/svclock.c lfs/fs/lockd/svclock.c
1867 --- lfs-ref/fs/lockd/svclock.c  Fri Apr 20 22:31:20 2001
1868 +++ lfs/fs/lockd/svclock.c      Wed Sep 12 02:42:15 2001
1869 @@ -100,14 +100,18 @@
1870         struct nlm_block        **head, *block;
1871         struct file_lock        *fl;
1872  
1873 -       dprintk("lockd: nlmsvc_lookup_block f=%p pd=%d %ld-%ld ty=%d\n",
1874 -                               file, lock->fl.fl_pid, lock->fl.fl_start,
1875 -                               lock->fl.fl_end, lock->fl.fl_type);
1876 +       dprintk("lockd: nlmsvc_lookup_block f=%p pd=%d %Ld-%Ld ty=%d\n",
1877 +                               file, lock->fl.fl_pid,
1878 +                               (long long)lock->fl.fl_start,
1879 +                               (long long)lock->fl.fl_end,
1880 +                               lock->fl.fl_type);
1881         for (head = &nlm_blocked; (block = *head); head = &block->b_next) {
1882                 fl = &block->b_call.a_args.lock.fl;
1883 -               dprintk("lockd: check f=%p pd=%d %ld-%ld ty=%d cookie=%x\n",
1884 -                               block->b_file, fl->fl_pid, fl->fl_start,
1885 -                               fl->fl_end, fl->fl_type, 
1886 +               dprintk("lockd: check f=%p pd=%d %Ld-%Ld ty=%d cookie=%x\n",
1887 +                               block->b_file, fl->fl_pid,
1888 +                               (long long)lock->fl.fl_start,
1889 +                               (long long)lock->fl.fl_end,
1890 +                               fl->fl_type, 
1891                                 *(u32 *)(&block->b_call.a_args.cookie.data));
1892                 if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) {
1893                         if (remove)
1894 @@ -293,12 +297,12 @@
1895         struct inode            *inode = file->f_file.f_dentry->d_inode;
1896         int                     error;
1897  
1898 -       dprintk("lockd: nlmsvc_lock(%04x/%ld, ty=%d, pi=%d, %ld-%ld, bl=%d)\n",
1899 +       dprintk("lockd: nlmsvc_lock(%04x/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
1900                                 file->f_file.f_dentry->d_inode->i_dev,
1901                                 file->f_file.f_dentry->d_inode->i_ino,
1902                                 lock->fl.fl_type, lock->fl.fl_pid,
1903 -                               lock->fl.fl_start,
1904 -                               lock->fl.fl_end,
1905 +                               (long long)lock->fl.fl_start,
1906 +                               (long long)lock->fl.fl_end,
1907                                 wait);
1908         
1909         /* Checking for read only file system */
1910 @@ -371,16 +375,18 @@
1911  {
1912         struct file_lock        *fl;
1913  
1914 -       dprintk("lockd: nlmsvc_testlock(%04x/%ld, ty=%d, %ld-%ld)\n",
1915 +       dprintk("lockd: nlmsvc_testlock(%04x/%ld, ty=%d, %Ld-%Ld)\n",
1916                                 file->f_file.f_dentry->d_inode->i_dev,
1917                                 file->f_file.f_dentry->d_inode->i_ino,
1918                                 lock->fl.fl_type,
1919 -                               lock->fl.fl_start,
1920 -                               lock->fl.fl_end);
1921 +                               (long long)lock->fl.fl_start,
1922 +                               (long long)lock->fl.fl_end);
1923  
1924         if ((fl = posix_test_lock(&file->f_file, &lock->fl)) != NULL) {
1925 -               dprintk("lockd: conflicting lock(ty=%d, %ld-%ld)\n",
1926 -                               fl->fl_type, fl->fl_start, fl->fl_end );
1927 +               dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n",
1928 +                               fl->fl_type,
1929 +                               (long long)lock->fl.fl_start,
1930 +                               (long long)lock->fl.fl_end);
1931  
1932                 conflock->caller = "somehost";  /* FIXME */
1933                 conflock->oh.len = 0;           /* don't return OH info */
1934 @@ -403,12 +409,12 @@
1935  {
1936         int     error;
1937  
1938 -       dprintk("lockd: nlmsvc_unlock(%04x/%ld, pi=%d, %ld-%ld)\n",
1939 +       dprintk("lockd: nlmsvc_unlock(%04x/%ld, pi=%d, %Ld-%Ld)\n",
1940                                 file->f_file.f_dentry->d_inode->i_dev,
1941                                 file->f_file.f_dentry->d_inode->i_ino,
1942                                 lock->fl.fl_pid,
1943 -                               lock->fl.fl_start,
1944 -                               lock->fl.fl_end);
1945 +                               (long long)lock->fl.fl_start,
1946 +                               (long long)lock->fl.fl_end);
1947  
1948         /* First, cancel any lock that might be there */
1949         nlmsvc_cancel_blocked(file, lock);
1950 @@ -431,12 +437,12 @@
1951  {
1952         struct nlm_block        *block;
1953  
1954 -       dprintk("lockd: nlmsvc_cancel(%04x/%ld, pi=%d, %ld-%ld)\n",
1955 +       dprintk("lockd: nlmsvc_cancel(%04x/%ld, pi=%d, %Ld-%Ld)\n",
1956                                 file->f_file.f_dentry->d_inode->i_dev,
1957                                 file->f_file.f_dentry->d_inode->i_ino,
1958                                 lock->fl.fl_pid,
1959 -                               lock->fl.fl_start,
1960 -                               lock->fl.fl_end);
1961 +                               (long long)lock->fl.fl_start,
1962 +                               (long long)lock->fl.fl_end);
1963  
1964         down(&file->f_sema);
1965         if ((block = nlmsvc_lookup_block(file, lock, 1)) != NULL)
1966 diff -urN lfs-ref/fs/lockd/xdr.c lfs/fs/lockd/xdr.c
1967 --- lfs-ref/fs/lockd/xdr.c      Mon Dec 11 16:58:00 2000
1968 +++ lfs/fs/lockd/xdr.c  Wed Sep 12 02:42:15 2001
1969 @@ -24,7 +24,6 @@
1970  
1971  #define NLMDBG_FACILITY                NLMDBG_XDR
1972  #define NLM_MAXSTRLEN          1024
1973 -#define OFFSET_MAX             LONG_MAX
1974  
1975  #define QUADLEN(len)           (((len) + 3) >> 2)
1976  
1977 @@ -37,6 +36,25 @@
1978  static void nlm_register_stats(void);
1979  static void nlm_unregister_stats(void);
1980  
1981 +static inline loff_t
1982 +s32_to_loff_t(__s32 offset)
1983 +{
1984 +       return (loff_t)offset;
1985 +}
1986 +
1987 +static inline __s32
1988 +loff_t_to_s32(loff_t offset)
1989 +{
1990 +       __s32 res;
1991 +       if (offset >= NLM_OFFSET_MAX)
1992 +               res = NLM_OFFSET_MAX;
1993 +       else if (offset <= -NLM_OFFSET_MAX)
1994 +               res = -NLM_OFFSET_MAX;
1995 +       else
1996 +               res = offset;
1997 +       return res;
1998 +}
1999 +
2000  /*
2001   * Initialization of NFS status variables
2002   */
2003 @@ -157,7 +175,7 @@
2004  nlm_decode_lock(u32 *p, struct nlm_lock *lock)
2005  {
2006         struct file_lock        *fl = &lock->fl;
2007 -       int                     len;
2008 +       s32                     start, len, end;
2009  
2010         if (!(p = xdr_decode_string(p, &lock->caller, &len, NLM_MAXSTRLEN))
2011          || !(p = nlm_decode_fh(p, &lock->fh))
2012 @@ -169,10 +187,16 @@
2013         fl->fl_pid   = ntohl(*p++);
2014         fl->fl_flags = FL_POSIX;
2015         fl->fl_type  = F_RDLCK;         /* as good as anything else */
2016 -       fl->fl_start = ntohl(*p++);
2017 +       start = ntohl(*p++);
2018         len = ntohl(*p++);
2019 -       if (len == 0 || (fl->fl_end = fl->fl_start + len - 1) < 0)
2020 +       end = start + len - 1;
2021 +
2022 +       fl->fl_start = s32_to_loff_t(start);
2023 +
2024 +       if (len == 0 || end < 0)
2025                 fl->fl_end = OFFSET_MAX;
2026 +       else
2027 +               fl->fl_end = s32_to_loff_t(end);
2028         return p;
2029  }
2030  
2031 @@ -183,6 +207,7 @@
2032  nlm_encode_lock(u32 *p, struct nlm_lock *lock)
2033  {
2034         struct file_lock        *fl = &lock->fl;
2035 +       __s32                   start, len;
2036  
2037         if (!(p = xdr_encode_string(p, lock->caller, -1))
2038          || !(p = nlm_encode_fh(p, &lock->fh))
2039 @@ -193,12 +218,15 @@
2040          || (fl->fl_end > NLM_OFFSET_MAX && fl->fl_end != OFFSET_MAX))
2041                 return NULL;
2042  
2043 -       *p++ = htonl(fl->fl_pid);
2044 -       *p++ = htonl(fl->fl_start);
2045 +       start = loff_t_to_s32(fl->fl_start);
2046         if (fl->fl_end == OFFSET_MAX)
2047 -               *p++ = xdr_zero;
2048 +               len = 0;
2049         else
2050 -               *p++ = htonl(fl->fl_end - fl->fl_start + 1);
2051 +               len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
2052 +
2053 +       *p++ = htonl(fl->fl_pid);
2054 +       *p++ = htonl(start);
2055 +       *p++ = htonl(len);
2056  
2057         return p;
2058  }
2059 @@ -209,6 +237,8 @@
2060  static u32 *
2061  nlm_encode_testres(u32 *p, struct nlm_res *resp)
2062  {
2063 +       s32             start, len;
2064 +
2065         if (!(p = nlm_encode_cookie(p, &resp->cookie)))
2066                 return 0;
2067         *p++ = resp->status;
2068 @@ -223,11 +253,14 @@
2069                 if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
2070                         return 0;
2071  
2072 -               *p++ = htonl(fl->fl_start);
2073 +               start = loff_t_to_s32(fl->fl_start);
2074                 if (fl->fl_end == OFFSET_MAX)
2075 -                       *p++ = xdr_zero;
2076 +                       len = xdr_zero;
2077                 else
2078 -                       *p++ = htonl(fl->fl_end - fl->fl_start + 1);
2079 +                       len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
2080 +
2081 +               *p++ = htonl(start);
2082 +               *p++ = htonl(len);
2083         }
2084  
2085         return p;
2086 @@ -446,7 +479,8 @@
2087         resp->status = ntohl(*p++);
2088         if (resp->status == NLM_LCK_DENIED) {
2089                 struct file_lock        *fl = &resp->lock.fl;
2090 -               u32                     excl, len;
2091 +               u32                     excl;
2092 +               s32                     start, len, end;
2093  
2094                 memset(&resp->lock, 0, sizeof(resp->lock));
2095                 excl = ntohl(*p++);
2096 @@ -456,10 +490,15 @@
2097  
2098                 fl->fl_flags = FL_POSIX;
2099                 fl->fl_type  = excl? F_WRLCK : F_RDLCK;
2100 -               fl->fl_start = ntohl(*p++);
2101 +               start = ntohl(*p++);
2102                 len = ntohl(*p++);
2103 -               if (len == 0 || (fl->fl_end = fl->fl_start + len - 1) < 0)
2104 +               end = start + len - 1;
2105 +
2106 +               fl->fl_start = s32_to_loff_t(start);
2107 +               if (len == 0 || end < 0)
2108                         fl->fl_end = OFFSET_MAX;
2109 +               else
2110 +                       fl->fl_end = s32_to_loff_t(end);
2111         }
2112         return 0;
2113  }
2114 diff -urN lfs-ref/fs/lockd/xdr4.c lfs/fs/lockd/xdr4.c
2115 --- lfs-ref/fs/lockd/xdr4.c     Mon Dec 11 16:58:00 2000
2116 +++ lfs/fs/lockd/xdr4.c Wed Sep 12 02:42:15 2001
2117 @@ -23,7 +23,6 @@
2118  
2119  #define NLMDBG_FACILITY                NLMDBG_XDR
2120  #define NLM_MAXSTRLEN          1024
2121 -#define OFFSET_MAX             ((off_t)LONG_MAX)
2122  
2123  #define QUADLEN(len)           (((len) + 3) >> 2)
2124  
2125 @@ -34,11 +33,23 @@
2126  
2127  typedef struct nlm_args        nlm_args;
2128  
2129 -static inline off_t
2130 -size_to_off_t(__s64 size)
2131 +static inline loff_t
2132 +s64_to_loff_t(__s64 offset)
2133  {
2134 -        size = (size > (__s64)LONG_MAX) ? (off_t)LONG_MAX : (off_t) size;
2135 -        return (size < (__s64)-LONG_MAX) ? (off_t)-LONG_MAX : (off_t) size;
2136 +       return (loff_t)offset;
2137 +}
2138
2139 +static inline s64
2140 +loff_t_to_s64(loff_t offset)
2141 +{
2142 +       s64 res;
2143 +       if (offset > NLM4_OFFSET_MAX)
2144 +               res = NLM4_OFFSET_MAX;
2145 +       else if (offset < -NLM4_OFFSET_MAX)
2146 +               res = -NLM4_OFFSET_MAX;
2147 +       else
2148 +               res = offset;
2149 +       return res;
2150  }
2151  
2152  /*
2153 @@ -139,11 +150,12 @@
2154         p = xdr_decode_hyper(p, &len);
2155         end = start + len - 1;
2156  
2157 -       fl->fl_start = size_to_off_t(start);
2158 -       fl->fl_end = size_to_off_t(end);
2159 +       fl->fl_start = s64_to_loff_t(start);
2160  
2161 -       if (len == 0 || fl->fl_end < 0)
2162 +       if (len == 0 || end < 0)
2163                 fl->fl_end = OFFSET_MAX;
2164 +       else
2165 +               fl->fl_end = s64_to_loff_t(end);
2166         return p;
2167  }
2168  
2169 @@ -154,18 +166,26 @@
2170  nlm4_encode_lock(u32 *p, struct nlm_lock *lock)
2171  {
2172         struct file_lock        *fl = &lock->fl;
2173 +       __s64                   start, len;
2174  
2175         if (!(p = xdr_encode_string(p, lock->caller, -1))
2176          || !(p = nlm4_encode_fh(p, &lock->fh))
2177          || !(p = nlm4_encode_oh(p, &lock->oh)))
2178                 return NULL;
2179  
2180 -       *p++ = htonl(fl->fl_pid);
2181 -       p = xdr_encode_hyper(p, fl->fl_start);
2182 +       if (fl->fl_start > NLM4_OFFSET_MAX
2183 +        || (fl->fl_end > NLM4_OFFSET_MAX && fl->fl_end != OFFSET_MAX))
2184 +               return NULL;
2185 +
2186 +       start = loff_t_to_s64(fl->fl_start);
2187         if (fl->fl_end == OFFSET_MAX)
2188 -               p = xdr_encode_hyper(p, 0);
2189 +               len = 0;
2190         else
2191 -               p = xdr_encode_hyper(p, fl->fl_end - fl->fl_start + 1);
2192 +               len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
2193 +
2194 +       *p++ = htonl(fl->fl_pid);
2195 +       p = xdr_encode_hyper(p, start);
2196 +       p = xdr_encode_hyper(p, len);
2197  
2198         return p;
2199  }
2200 @@ -176,6 +196,7 @@
2201  static u32 *
2202  nlm4_encode_testres(u32 *p, struct nlm_res *resp)
2203  {
2204 +       s64             start, len;
2205  
2206         dprintk("xdr: before encode_testres (p %p resp %p)\n", p, resp);
2207         if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
2208 @@ -192,14 +213,17 @@
2209                 if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
2210                         return 0;
2211  
2212 -               p = xdr_encode_hyper(p, fl->fl_start);
2213 +               start = loff_t_to_s64(fl->fl_start);
2214                 if (fl->fl_end == OFFSET_MAX)
2215 -                       p = xdr_encode_hyper(p, 0);
2216 +                       len = 0;
2217                 else
2218 -                       p = xdr_encode_hyper(p, fl->fl_end - fl->fl_start + 1);
2219 -               dprintk("xdr: encode_testres (status %d pid %d type %d start %ld end %ld)\n", resp->status, fl->fl_pid, fl->fl_type, fl->fl_start,  fl->fl_end);
2220 -
2221 -
2222 +                       len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
2223 +               
2224 +               p = xdr_encode_hyper(p, start);
2225 +               p = xdr_encode_hyper(p, len);
2226 +               dprintk("xdr: encode_testres (status %d pid %d type %d start %Ld end %Ld)\n",
2227 +                       resp->status, fl->fl_pid, fl->fl_type,
2228 +                       fl->fl_start, fl->fl_end);
2229         }
2230  
2231         dprintk("xdr: after encode_testres (p %p resp %p)\n", p, resp);
2232 @@ -435,10 +459,11 @@
2233                 p = xdr_decode_hyper(p, &len);
2234                 end = start + len - 1;
2235  
2236 -               fl->fl_start = size_to_off_t(start);
2237 -               fl->fl_end = size_to_off_t(end);
2238 -               if (len == 0 || fl->fl_end < 0)
2239 +               fl->fl_start = s64_to_loff_t(start);
2240 +               if (len == 0 || end < 0)
2241                         fl->fl_end = OFFSET_MAX;
2242 +               else
2243 +                       fl->fl_end = s64_to_loff_t(end);
2244         }
2245         return 0;
2246  }
2247 diff -urN lfs-ref/fs/locks.c lfs/fs/locks.c
2248 --- lfs-ref/fs/locks.c  Wed Sep 12 02:05:57 2001
2249 +++ lfs/fs/locks.c      Wed Sep 12 02:42:15 2001
2250 @@ -111,12 +111,12 @@
2251  
2252  #include <asm/uaccess.h>
2253  
2254 -#define OFFSET_MAX     ((off_t)LONG_MAX)       /* FIXME: move elsewhere? */
2255 -
2256  static int flock_make_lock(struct file *filp, struct file_lock *fl,
2257                                unsigned int cmd);
2258 -static int posix_make_lock(struct file *filp, struct file_lock *fl,
2259 +static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
2260                                struct flock *l);
2261 +static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
2262 +                                struct flock64 *l);
2263  static int flock_locks_conflict(struct file_lock *caller_fl,
2264                                 struct file_lock *sys_fl);
2265  static int posix_locks_conflict(struct file_lock *caller_fl,
2266 @@ -195,7 +195,7 @@
2267  
2268         if (waiter->fl_prevblock) {
2269                 printk(KERN_ERR "locks_insert_block: remove duplicated lock "
2270 -                       "(pid=%d %ld-%ld type=%d)\n",
2271 +                       "(pid=%d %Ld-%Ld type=%d)\n",
2272                         waiter->fl_pid, waiter->fl_start,
2273                         waiter->fl_end, waiter->fl_type);
2274                 locks_delete_block(waiter->fl_prevblock, waiter);
2275 @@ -344,9 +344,10 @@
2276         if (!filp->f_dentry || !filp->f_dentry->d_inode || !filp->f_op)
2277                 goto out_putf;
2278  
2279 -       if (!posix_make_lock(filp, &file_lock, &flock))
2280 +       if ((error = flock_to_posix_lock(filp, &file_lock, &flock)))
2281                 goto out_putf;
2282  
2283 +       error = -EINVAL;
2284         if (filp->f_op->lock) {
2285                 error = filp->f_op->lock(filp, F_GETLK, &file_lock);
2286                 if (error < 0)
2287 @@ -363,6 +364,18 @@
2288         flock.l_type = F_UNLCK;
2289         if (fl != NULL) {
2290                 flock.l_pid = fl->fl_pid;
2291 +#if BITS_PER_LONG == 32
2292 +               /*
2293 +                * Make sure we can represent the posix lock via
2294 +                * legacy 32bit flock.
2295 +                */
2296 +               error = -EOVERFLOW;
2297 +               if (fl->fl_start > OFFT_OFFSET_MAX)
2298 +                       goto out_putf;
2299 +               if ((fl->fl_end != OFFSET_MAX)
2300 +                   && (fl->fl_end > OFFT_OFFSET_MAX))
2301 +                       goto out_putf;
2302 +#endif
2303                 flock.l_start = fl->fl_start;
2304                 flock.l_len = fl->fl_end == OFFSET_MAX ? 0 :
2305                         fl->fl_end - fl->fl_start + 1;
2306 @@ -424,8 +437,7 @@
2307                 goto out_putf;
2308         }
2309  
2310 -       error = -EINVAL;
2311 -       if (!posix_make_lock(filp, &file_lock, &flock))
2312 +       if ((error = flock_to_posix_lock(filp, &file_lock, &flock)))
2313                 goto out_putf;
2314         
2315         error = -EBADF;
2316 @@ -475,6 +487,169 @@
2317         return error;
2318  }
2319  
2320 +#if BITS_PER_LONG == 32
2321 +/* Report the first existing lock that would conflict with l.
2322 + * This implements the F_GETLK command of fcntl().
2323 + */
2324 +int fcntl_getlk64(unsigned int fd, struct flock64 *l)
2325 +{
2326 +       struct file *filp;
2327 +       struct file_lock *fl,file_lock;
2328 +       struct flock64 flock;
2329 +       int error;
2330 +
2331 +       error = -EFAULT;
2332 +       if (copy_from_user(&flock, l, sizeof(flock)))
2333 +               goto out;
2334 +       error = -EINVAL;
2335 +       if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
2336 +               goto out;
2337 +
2338 +       error = -EBADF;
2339 +       filp = fget(fd);
2340 +       if (!filp)
2341 +               goto out;
2342 +
2343 +       error = -EINVAL;
2344 +       if (!filp->f_dentry || !filp->f_dentry->d_inode || !filp->f_op)
2345 +               goto out_putf;
2346 +
2347 +       if (!flock64_to_posix_lock(filp, &file_lock, &flock))
2348 +               goto out_putf;
2349 +
2350 +       if (filp->f_op->lock) {
2351 +               error = filp->f_op->lock(filp, F_GETLK, &file_lock);
2352 +               if (error < 0)
2353 +                       goto out_putf;
2354 +               else if (error == LOCK_USE_CLNT)
2355 +                 /* Bypass for NFS with no locking - 2.0.36 compat */
2356 +                 fl = posix_test_lock(filp, &file_lock);
2357 +               else
2358 +                 fl = (file_lock.fl_type == F_UNLCK ? NULL : &file_lock);
2359 +       } else {
2360 +               fl = posix_test_lock(filp, &file_lock);
2361 +       }
2362
2363 +       flock.l_type = F_UNLCK;
2364 +       if (fl != NULL) {
2365 +               flock.l_pid = fl->fl_pid;
2366 +               flock.l_start = fl->fl_start;
2367 +               flock.l_len = fl->fl_end == OFFSET_MAX ? 0 :
2368 +                       fl->fl_end - fl->fl_start + 1;
2369 +               flock.l_whence = 0;
2370 +               flock.l_type = fl->fl_type;
2371 +       }
2372 +       error = -EFAULT;
2373 +       if (!copy_to_user(l, &flock, sizeof(flock)))
2374 +               error = 0;
2375 +  
2376 +out_putf:
2377 +       fput(filp);
2378 +out:
2379 +       return error;
2380 +}
2381 +
2382 +/* Apply the lock described by l to an open file descriptor.
2383 + * This implements both the F_SETLK and F_SETLKW commands of fcntl().
2384 + */
2385 +int fcntl_setlk64(unsigned int fd, unsigned int cmd, struct flock64 *l)
2386 +{
2387 +       struct file *filp;
2388 +       struct file_lock file_lock;
2389 +       struct flock64 flock;
2390 +       struct dentry * dentry;
2391 +       struct inode *inode;
2392 +       int error;
2393 +
2394 +       /*
2395 +        * This might block, so we do it before checking the inode.
2396 +        */
2397 +       error = -EFAULT;
2398 +       if (copy_from_user(&flock, l, sizeof(flock)))
2399 +               goto out;
2400 +
2401 +       /* Get arguments and validate them ...
2402 +        */
2403 +
2404 +       error = -EBADF;
2405 +       filp = fget(fd);
2406 +       if (!filp)
2407 +               goto out;
2408 +
2409 +       error = -EINVAL;
2410 +       if (!(dentry = filp->f_dentry))
2411 +               goto out_putf;
2412 +       if (!(inode = dentry->d_inode))
2413 +               goto out_putf;
2414 +       if (!filp->f_op)
2415 +               goto out_putf;
2416 +
2417 +       /* Don't allow mandatory locks on files that may be memory mapped
2418 +        * and shared.
2419 +        */
2420 +       if (IS_MANDLOCK(inode) &&
2421 +           (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
2422 +           inode->i_mmap) {
2423 +               struct vm_area_struct *vma = inode->i_mmap;
2424 +               error = -EAGAIN;
2425 +               do {
2426 +                       if (vma->vm_flags & VM_MAYSHARE)
2427 +                               goto out_putf;
2428 +               } while ((vma = vma->vm_next_share) != NULL);
2429 +       }
2430 +
2431 +       error = -EINVAL;
2432 +       if (!flock64_to_posix_lock(filp, &file_lock, &flock))
2433 +               goto out_putf;
2434 +       
2435 +       error = -EBADF;
2436 +       switch (flock.l_type) {
2437 +       case F_RDLCK:
2438 +               if (!(filp->f_mode & FMODE_READ))
2439 +                       goto out_putf;
2440 +               break;
2441 +       case F_WRLCK:
2442 +               if (!(filp->f_mode & FMODE_WRITE))
2443 +                       goto out_putf;
2444 +               break;
2445 +       case F_UNLCK:
2446 +               break;
2447 +       case F_SHLCK:
2448 +       case F_EXLCK:
2449 +#ifdef __sparc__
2450 +/* warn a bit for now, but don't overdo it */
2451 +{
2452 +       static int count = 0;
2453 +       if (!count) {
2454 +               count=1;
2455 +               printk(KERN_WARNING
2456 +                      "fcntl_setlk() called by process %d (%s) with broken flock() emulation\n",
2457 +                      current->pid, current->comm);
2458 +       }
2459 +}
2460 +               if (!(filp->f_mode & 3))
2461 +                       goto out_putf;
2462 +               break;
2463 +#endif
2464 +       default:
2465 +               error = -EINVAL;
2466 +               goto out_putf;
2467 +       }
2468 +
2469 +       if (filp->f_op->lock != NULL) {
2470 +               error = filp->f_op->lock(filp, cmd, &file_lock);
2471 +               if (error < 0)
2472 +                       goto out_putf;
2473 +       }
2474 +       error = posix_lock_file(filp, &file_lock, cmd == F_SETLKW64);
2475 +
2476 +out_putf:
2477 +       fput(filp);
2478 +out:
2479 +       return error;
2480 +}
2481 +#endif /* BITS_PER_LONG == 32 */
2482 +
2483  /*
2484   * This function is called when the file is being removed
2485   * from the task's fd array.
2486 @@ -655,10 +830,70 @@
2487  /* Verify a "struct flock" and copy it to a "struct file_lock" as a POSIX
2488   * style lock.
2489   */
2490 -static int posix_make_lock(struct file *filp, struct file_lock *fl,
2491 -                          struct flock *l)
2492 +static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
2493 +                              struct flock *l)
2494 +{
2495 +       loff_t start;
2496 +       int ret = -EINVAL;
2497 +
2498 +       memset(fl, 0, sizeof(*fl));
2499 +       
2500 +       fl->fl_flags = FL_POSIX;
2501 +
2502 +       switch (l->l_type) {
2503 +       case F_RDLCK:
2504 +       case F_WRLCK:
2505 +       case F_UNLCK:
2506 +               fl->fl_type = l->l_type;
2507 +               break;
2508 +       default:
2509 +               goto out;
2510 +       }
2511 +
2512 +       switch (l->l_whence) {
2513 +       case 0: /*SEEK_SET*/
2514 +               start = 0;
2515 +               break;
2516 +       case 1: /*SEEK_CUR*/
2517 +               start = filp->f_pos;
2518 +               break;
2519 +       case 2: /*SEEK_END*/
2520 +               start = filp->f_dentry->d_inode->i_size;
2521 +               break;
2522 +       default:
2523 +               goto out;
2524 +       }
2525 +
2526 +       if (((start += l->l_start) < 0) || (l->l_len < 0))
2527 +               goto out;
2528 +       fl->fl_end = start + l->l_len - 1;
2529 +       if (l->l_len > 0 && fl->fl_end < 0)
2530 +               goto out;
2531 +       fl->fl_start = start;   /* we record the absolute position */
2532 +       if (l->l_len != 0) {
2533 +               start = fl->fl_end;
2534 +       } else {
2535 +               start = fl->fl_start;
2536 +               fl->fl_end = OFFSET_MAX;
2537 +       }
2538 +       ret = -EOVERFLOW;
2539 +       if (start > OFFT_OFFSET_MAX)
2540 +               goto out;
2541 +       
2542 +       fl->fl_file = filp;
2543 +       fl->fl_owner = current->files;
2544 +       fl->fl_pid = current->pid;
2545 +
2546 +       ret = 0;
2547 + out:
2548 +       return ret;
2549 +}
2550 +
2551 +#if BITS_PER_LONG == 32
2552 +static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
2553 +                                struct flock64 *l)
2554  {
2555 -       off_t start;
2556 +       loff_t start;
2557  
2558         memset(fl, 0, sizeof(*fl));
2559         
2560 @@ -703,6 +938,7 @@
2561  
2562         return (1);
2563  }
2564 +#endif
2565  
2566  /* Verify a call to flock() and fill in a file_lock structure with
2567   * an appropriate FLOCK lock.
2568 @@ -1218,7 +1454,7 @@
2569                 p += sprintf(p, "FLOCK  ADVISORY  ");
2570         }
2571         p += sprintf(p, "%s ", (fl->fl_type == F_RDLCK) ? "READ " : "WRITE");
2572 -       p += sprintf(p, "%d %s:%ld %ld %ld ",
2573 +       p += sprintf(p, "%d %s:%ld %Ld %Ld ",
2574                      fl->fl_pid,
2575                      kdevname(inode->i_dev), inode->i_ino, fl->fl_start,
2576                      fl->fl_end);
2577 @@ -1282,6 +1518,3 @@
2578                 *start = buffer;
2579         return (q - buffer);
2580  }
2581 -
2582 -
2583 -
2584 diff -urN lfs-ref/fs/minix/dir.c lfs/fs/minix/dir.c
2585 --- lfs-ref/fs/minix/dir.c      Mon Jan 17 16:44:42 2000
2586 +++ lfs/fs/minix/dir.c  Wed Sep 12 02:42:15 2001
2587 @@ -82,7 +82,7 @@
2588                         de = (struct minix_dir_entry *) (offset + bh->b_data);
2589                         if (de->inode) {
2590                                 int size = strnlen(de->name, info->s_namelen);
2591 -                               if (filldir(dirent, de->name, size, filp->f_pos, de->inode) < 0) {
2592 +                               if (filldir(dirent, de->name, size, filp->f_pos, de->inode, DT_UNKNOWN) < 0) {
2593                                         brelse(bh);
2594                                         return 0;
2595                                 }
2596 diff -urN lfs-ref/fs/minix/file.c lfs/fs/minix/file.c
2597 --- lfs-ref/fs/minix/file.c     Mon Jan 17 16:44:42 2000
2598 +++ lfs/fs/minix/file.c Wed Sep 12 02:42:15 2001
2599 @@ -70,8 +70,8 @@
2600                                 size_t count, loff_t *ppos)
2601  {
2602         struct inode * inode = filp->f_dentry->d_inode;
2603 -       off_t pos;
2604 -       ssize_t written, c;
2605 +       loff_t pos;
2606 +       ssize_t written, c, m;
2607         struct buffer_head * bh;
2608         char * p;
2609  
2610 @@ -87,15 +87,34 @@
2611                 pos = inode->i_size;
2612         else
2613                 pos = *ppos;
2614 +
2615 +       /* L-F-S spec 2.2.1.27: */
2616 +       if (!(filp->f_flags & O_LARGEFILE)) {
2617 +               if (pos >= 0x7fffffffULL) /* pos@2G forbidden */
2618 +                       return -EFBIG;
2619 +
2620 +               if (pos + count > 0x7fffffffULL)
2621 +                       /* Write only until end of allowed region */
2622 +                       count = 0x7fffffffULL - pos;
2623 +       }
2624 +       /* MINIX i-node file-size can't exceed 4G-1 */
2625 +       /* With 1k blocks and triple indirection MINIX can have files
2626 +          up to 16 GB in size -- filesystem maximum is then 4G*1k = 4T */
2627 +       if (pos >= 0xffffffffULL)
2628 +               return -EFBIG; /* Absolutely too much! */
2629 +       if ((pos + count) >= 0x100000000ULL) /* too much to write! */
2630 +               count = 0xffffffffULL - pos;
2631 +
2632         written = 0;
2633         while (written < count) {
2634 -               bh = minix_getblk(inode,pos/BLOCK_SIZE,1);
2635 +               bh = minix_getblk(inode, pos >> BLOCK_SIZE_BITS, 1);
2636                 if (!bh) {
2637                         if (!written)
2638                                 written = -ENOSPC;
2639                         break;
2640                 }
2641 -               c = BLOCK_SIZE - (pos % BLOCK_SIZE);
2642 +               m = pos & (BLOCK_SIZE - 1);
2643 +               c = BLOCK_SIZE - m;
2644                 if (c > count-written)
2645                         c = count-written;
2646                 if (c != BLOCK_SIZE && !buffer_uptodate(bh)) {
2647 @@ -108,7 +127,7 @@
2648                                 break;
2649                         }
2650                 }
2651 -               p = (pos % BLOCK_SIZE) + bh->b_data;
2652 +               p = bh->b_data + m;
2653                 c -= copy_from_user(p,buf,c);
2654                 if (!c) {
2655                         brelse(bh);
2656 diff -urN lfs-ref/fs/ncpfs/dir.c lfs/fs/ncpfs/dir.c
2657 --- lfs-ref/fs/ncpfs/dir.c      Mon Dec 11 16:58:00 2000
2658 +++ lfs/fs/ncpfs/dir.c  Wed Sep 12 02:42:15 2001
2659 @@ -449,14 +449,14 @@
2660         result = 0;
2661         if (filp->f_pos == 0) {
2662                 ncp_invalid_dir_cache(inode);
2663 -               if (filldir(dirent, ".", 1, 0, inode->i_ino) < 0) {
2664 +               if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) {
2665                         goto finished;
2666                 }
2667                 filp->f_pos = 1;
2668         }
2669         if (filp->f_pos == 1) {
2670                 if (filldir(dirent, "..", 2, 1,
2671 -                               dentry->d_parent->d_inode->i_ino) < 0) {
2672 +                               dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
2673                         goto finished;
2674                 }
2675                 filp->f_pos = 2;
2676 @@ -537,7 +537,7 @@
2677                         ino = ncp_invent_inos(1);
2678  
2679                 if (filldir(dirent, entry->i.entryName, entry->i.nameLen,
2680 -                           entry->f_pos, ino) < 0) {
2681 +                           entry->f_pos, ino, DT_UNKNOWN) < 0) {
2682                         break;
2683                 }
2684                 if ((inode->i_dev != c_dev)
2685 diff -urN lfs-ref/fs/ncpfs/file.c lfs/fs/ncpfs/file.c
2686 --- lfs-ref/fs/ncpfs/file.c     Mon Dec 11 16:58:00 2000
2687 +++ lfs/fs/ncpfs/file.c Wed Sep 12 02:42:15 2001
2688 @@ -17,6 +17,7 @@
2689  #include <linux/mm.h>
2690  #include <linux/locks.h>
2691  #include <linux/malloc.h>
2692 +#include <linux/unistd.h>
2693  
2694  #include <linux/ncp_fs.h>
2695  #include "ncplib_kernel.h"
2696 @@ -161,7 +162,7 @@
2697         /* First read in as much as possible for each bufsize. */
2698         while (already_read < count) {
2699                 int read_this_time;
2700 -               size_t to_read = min(bufsize - (pos % bufsize),
2701 +               size_t to_read = min(bufsize - (pos & (bufsize-1)),
2702                                   count - already_read);
2703  
2704                 error = ncp_read_bounce(NCP_SERVER(inode),
2705 @@ -201,7 +202,7 @@
2706         struct dentry *dentry = file->f_dentry;
2707         struct inode *inode = dentry->d_inode;
2708         size_t already_written = 0;
2709 -       off_t pos;
2710 +       loff_t pos;
2711         size_t bufsize;
2712         int errno;
2713         void* bouncebuffer;
2714 @@ -238,12 +239,18 @@
2715  
2716         already_written = 0;
2717  
2718 +       /* Maximum file size: 2G-1 */
2719 +       if (pos >= 0x7fffffffULL)
2720 +               return -EFBIG;
2721 +       if ((pos + count) >= 0x7fffffffULL)
2722 +               count = 0x7fffffffULL - pos;
2723 +
2724         bouncebuffer = kmalloc(bufsize, GFP_NFS);
2725         if (!bouncebuffer)
2726                 return -EIO;    /* -ENOMEM */
2727         while (already_written < count) {
2728                 int written_this_time;
2729 -               size_t to_write = min(bufsize - (pos % bufsize),
2730 +               size_t to_write = min(bufsize - (pos & (bufsize-1)),
2731                                    count - already_written);
2732  
2733                 if (copy_from_user(bouncebuffer, buf, to_write)) {
2734 diff -urN lfs-ref/fs/ncpfs/inode.c lfs/fs/ncpfs/inode.c
2735 --- lfs-ref/fs/ncpfs/inode.c    Tue Jun 13 03:48:14 2000
2736 +++ lfs/fs/ncpfs/inode.c        Wed Sep 12 02:42:15 2001
2737 @@ -131,7 +131,7 @@
2738         }
2739         inode->i_blocks = 0;
2740         if ((inode->i_size)&&(inode->i_blksize)) {
2741 -               inode->i_blocks = (inode->i_size-1)/(inode->i_blksize)+1;
2742 +               inode->i_blocks = ((inode->i_size-1) >> fslog2(inode->i_blksize)) +1;
2743         }
2744  
2745         inode->i_mtime = ncp_date_dos2unix(le16_to_cpu(nwi->modifyTime),
2746 @@ -201,8 +201,7 @@
2747  
2748         inode->i_blocks = 0;
2749         if ((inode->i_blksize != 0) && (inode->i_size != 0)) {
2750 -               inode->i_blocks =
2751 -                   (inode->i_size - 1) / inode->i_blksize + 1;
2752 +               inode->i_blocks = ((inode->i_size - 1) >> fslog2(inode->i_blksize)) + 1;
2753         }
2754  
2755         inode->i_mtime = ncp_date_dos2unix(le16_to_cpu(nwi->modifyTime),
2756 diff -urN lfs-ref/fs/nfs/dir.c lfs/fs/nfs/dir.c
2757 --- lfs-ref/fs/nfs/dir.c        Wed Sep 12 02:05:57 2001
2758 +++ lfs/fs/nfs/dir.c    Wed Sep 12 02:42:15 2001
2759 @@ -137,7 +137,7 @@
2760         int             plus = NFS_USE_READDIRPLUS(inode);
2761         int             error;
2762  
2763 -       dfprintk(VFS, "NFS: nfs_readdir_filler() reading cookie %Lu into page %lu.\n", (long long)desc->entry->cookie, page->offset);
2764 +       dfprintk(VFS, "NFS: nfs_readdir_filler() reading cookie %Lu into page %Lu.\n", (long long)desc->entry->cookie, (long long) nfs_page_offset(page));
2765  
2766   again:
2767         error = NFS_PROTO(inode)->readdir(inode, cred,
2768 @@ -158,7 +158,7 @@
2769          * Note: assumes we have exclusive access to this inode either
2770          *       throught inode->i_sem or some other mechanism.
2771          */
2772 -       if (page->offset == 0)
2773 +       if (page_index(page) == 0)
2774                 invalidate_inode_pages(inode);
2775         nfs_unlock_page(page);
2776         return 0;
2777 @@ -294,7 +294,7 @@
2778                  *       retrieving the current dirent on the server */
2779                 fileid = nfs_fileid_to_ino_t(entry->ino);
2780                 res = filldir(dirent, entry->name, entry->len, 
2781 -                             entry->prev_cookie, fileid);
2782 +                             entry->prev_cookie, fileid, DT_UNKNOWN);
2783                 if (res < 0)
2784                         break;
2785                 file->f_pos = desc->target = entry->cookie;
2786 diff -urN lfs-ref/fs/nfs/file.c lfs/fs/nfs/file.c
2787 --- lfs-ref/fs/nfs/file.c       Fri Apr 20 22:31:20 2001
2788 +++ lfs/fs/nfs/file.c   Wed Sep 12 02:42:15 2001
2789 @@ -164,6 +164,9 @@
2790  
2791  static int nfs_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
2792  {
2793 +       if (!NFS_PROTO(file->f_dentry->d_inode)->bigfiles &&
2794 +           page_index(page) > (0x7fffffff>>PAGE_SHIFT))
2795 +               return -EFBIG;
2796         return nfs_flush_incompatible(file, page);
2797  }
2798  
2799 @@ -232,10 +235,10 @@
2800         struct inode * inode = dentry->d_inode;
2801         int     status = 0;
2802  
2803 -       dprintk("NFS: nfs_lock(f=%4x/%ld, t=%x, fl=%x, r=%ld:%ld)\n",
2804 +       dprintk("NFS: nfs_lock(f=%4x/%ld, t=%x, fl=%x, r=%Ld:%Ld)\n",
2805                         inode->i_dev, inode->i_ino,
2806                         fl->fl_type, fl->fl_flags,
2807 -                       fl->fl_start, fl->fl_end);
2808 +                       (long long)fl->fl_start, (long long)fl->fl_end);
2809  
2810         if (!inode)
2811                 return -EINVAL;
2812 diff -urN lfs-ref/fs/nfs/inode.c lfs/fs/nfs/inode.c
2813 --- lfs-ref/fs/nfs/inode.c      Wed Sep 12 02:05:57 2001
2814 +++ lfs/fs/nfs/inode.c  Wed Sep 12 02:42:15 2001
2815 @@ -639,7 +639,7 @@
2816                  * Preset the size and mtime, as there's no need
2817                  * to invalidate the caches.
2818                  */
2819 -               inode->i_size  = nfs_size_to_off_t(fattr->size);
2820 +               inode->i_size  = nfs_size_to_loff_t(fattr->size);
2821                 inode->i_mtime = nfs_time_to_secs(fattr->mtime);
2822                 inode->i_atime = nfs_time_to_secs(fattr->atime);
2823                 inode->i_ctime = nfs_time_to_secs(fattr->ctime);
2824 @@ -773,6 +773,11 @@
2825         if (!S_ISREG(inode->i_mode))
2826                 attr->ia_valid &= ~ATTR_SIZE;
2827  
2828 +       error = -EFBIG;
2829 +       if ((attr->ia_valid & ATTR_SIZE) && !NFS_PROTO(inode)->bigfiles && 
2830 +           attr->ia_size > 0x7fffffff)
2831 +               goto out; 
2832 +
2833         error = nfs_wb_all(inode);
2834         if (error < 0)
2835                 goto out;
2836 @@ -831,6 +836,10 @@
2837         struct rpc_cred *cred = rpcauth_lookupcred(auth, 0);
2838  
2839         filp->private_data = cred;
2840 +
2841 +       if (!NFS_PROTO(filp->f_dentry->d_inode)->bigfiles)     
2842 +               filp->f_flags &= ~O_LARGEFILE; 
2843 +
2844         return 0;
2845  }
2846  
2847 @@ -912,8 +921,8 @@
2848  int
2849  nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
2850  {
2851 -       off_t           new_size, new_isize;
2852 -       __u64           new_mtime;
2853 +       __u64           new_size, new_mtime;
2854 +       loff_t          new_isize;
2855         int             invalid = 0;
2856         int             error = -EIO;
2857  
2858 @@ -960,7 +969,7 @@
2859  
2860         new_mtime = fattr->mtime;
2861         new_size = fattr->size;
2862 -       new_isize = nfs_size_to_off_t(fattr->size);
2863 +       new_isize = nfs_size_to_loff_t(fattr->size);
2864  
2865         error = 0;
2866  
2867 diff -urN lfs-ref/fs/nfs/nfs3proc.c lfs/fs/nfs/nfs3proc.c
2868 --- lfs-ref/fs/nfs/nfs3proc.c   Fri Apr 20 22:31:20 2001
2869 +++ lfs/fs/nfs/nfs3proc.c       Wed Sep 12 02:42:15 2001
2870 @@ -145,7 +145,7 @@
2871  static int
2872  nfs3_proc_read(struct inode *inode, struct rpc_cred *cred,
2873                struct nfs_fattr *fattr, int flags,
2874 -              unsigned long offset, unsigned int count,
2875 +              loff_t offset, unsigned int count,
2876                void *buffer, int *eofp)
2877  {
2878         struct nfs_readargs     arg = { NFS_FH(inode), offset, count, 1,
2879 @@ -155,7 +155,7 @@
2880         struct rpc_message      msg = { NFS3PROC_READ, &arg, &res, cred };
2881         int                     status;
2882  
2883 -       dprintk("NFS call  read %d @ %ld\n", count, offset);
2884 +       dprintk("NFS call  read %d @ %Ld\n", count, (long long) offset);
2885         fattr->valid = 0;
2886         status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
2887         dprintk("NFS reply read: %d\n", status);
2888 @@ -166,7 +166,7 @@
2889  static int
2890  nfs3_proc_write(struct inode *inode, struct rpc_cred *cred,
2891                 struct nfs_fattr *fattr, int flags,
2892 -               unsigned long offset, unsigned int count,
2893 +               loff_t offset, unsigned int count,
2894                 void *buffer, struct nfs_writeverf *verf)
2895  {
2896         struct nfs_writeargs    arg = { NFS_FH(inode), offset, count,
2897 @@ -177,7 +177,7 @@
2898         struct rpc_message      msg = { NFS3PROC_WRITE, &arg, &res, cred };
2899         int                     status, rpcflags = 0;
2900  
2901 -       dprintk("NFS call  write %d @ %ld\n", count, offset);
2902 +       dprintk("NFS call  write %d @ %Ld\n", count, (long long) offset);
2903         fattr->valid = 0;
2904         if (flags & NFS_RW_SWAP)
2905                 rpcflags |= NFS_RPC_SWAPFLAGS;
2906 @@ -517,4 +517,6 @@
2907         nfs3_proc_statfs,
2908  
2909         nfs3_decode_dirent,
2910 +
2911 +       1, 
2912  };
2913 diff -urN lfs-ref/fs/nfs/proc.c lfs/fs/nfs/proc.c
2914 --- lfs-ref/fs/nfs/proc.c       Fri Apr 20 22:31:20 2001
2915 +++ lfs/fs/nfs/proc.c   Wed Sep 12 02:42:15 2001
2916 @@ -134,7 +134,7 @@
2917  
2918  static int
2919  nfs_proc_read(struct inode *inode, struct rpc_cred *cred, fattr *fattr,
2920 -             int flags, unsigned long offset, unsigned int count,
2921 +             int flags, loff_t offset, unsigned int count,
2922               void *buffer, int *eofp)
2923  {
2924         struct nfs_readargs     arg = { NFS_FH(inode), offset, count, 1,
2925 @@ -144,7 +144,7 @@
2926         struct rpc_message      msg = { NFSPROC_READ, &arg, &res, cred };
2927         int                     status;
2928  
2929 -       dprintk("NFS call  read %d @ %ld\n", count, offset);
2930 +       dprintk("NFS call  read %d @ %Ld\n", count, (long long) offset);
2931         fattr->valid = 0;
2932         status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
2933  
2934 @@ -155,7 +155,7 @@
2935  
2936  static int
2937  nfs_proc_write(struct inode *inode, struct rpc_cred *cred, fattr *fattr,
2938 -              int how, unsigned long offset, unsigned int count,
2939 +              int how, loff_t offset, unsigned int count,
2940                void *buffer, struct nfs_writeverf *verf)
2941  {
2942         struct nfs_writeargs    arg = {NFS_FH(inode), offset, count,
2943 @@ -166,7 +166,7 @@
2944         struct rpc_message      msg = { NFSPROC_WRITE, &arg, &res, cred };
2945         int                     status, flags = 0;
2946  
2947 -       dprintk("NFS call  write %d @ %ld\n", count, offset);
2948 +       dprintk("NFS call  write %d @ %Ld\n", count, (long long) offset);
2949         fattr->valid = 0;
2950         if (how & NFS_RW_SWAP)
2951                 flags |= NFS_RPC_SWAPFLAGS;
2952 @@ -407,4 +407,5 @@
2953         nfs_proc_mknod,
2954         nfs_proc_statfs,
2955         nfs_decode_dirent,
2956 +       0,
2957  };
2958 diff -urN lfs-ref/fs/nfs/read.c lfs/fs/nfs/read.c
2959 --- lfs-ref/fs/nfs/read.c       Fri Apr 20 22:31:20 2001
2960 +++ lfs/fs/nfs/read.c   Wed Sep 12 02:42:15 2001
2961 @@ -91,7 +91,7 @@
2962  {
2963         struct rpc_cred *cred = NULL;
2964         struct nfs_fattr fattr;
2965 -       unsigned long   offset = nfs_page_offset(page);
2966 +       loff_t          offset = nfs_page_offset(page);
2967         char            *buffer = (char *) page_address(page);
2968         int             rsize = NFS_SERVER(inode)->rsize;
2969         int             result, refresh = 0;
2970 @@ -112,10 +112,10 @@
2971                 if ((chunk = rsize) > count)
2972                         chunk = count;
2973  
2974 -               dprintk("NFS: nfs_proc_read(%s, (%x/%Ld), %ld, %d, %p)\n",
2975 +               dprintk("NFS: nfs_proc_read(%s, (%x/%Ld), %Ld, %d, %p)\n",
2976                         NFS_SERVER(inode)->hostname,
2977                         inode->i_dev, (long long)NFS_FILEID(inode),
2978 -                       offset, chunk, buffer);
2979 +                       (long long) offset, chunk, buffer);
2980  
2981                 result = NFS_PROTO(inode)->read(inode, cred, &fattr, flags,
2982                                                 offset, chunk, buffer, &eof);
2983 @@ -439,11 +439,11 @@
2984                         set_bit(PG_error, &page->flags);
2985                 nfs_unlock_page(page);
2986  
2987 -               dprintk("NFS: read (%x/%Ld %d@%ld)\n",
2988 +               dprintk("NFS: read (%x/%Ld %d@%Ld)\n",
2989                         req->wb_inode->i_dev,
2990                         (long long)NFS_FILEID(req->wb_inode),
2991                          req->wb_bytes,
2992 -                        (nfs_page_offset(page) + req->wb_offset));
2993 +                        (long long)(nfs_page_offset(page) + req->wb_offset));
2994                 nfs_unlock_request(req);
2995                 nfs_release_request(req);
2996         }
2997 @@ -475,8 +475,8 @@
2998         else
2999                 inode = file->f_dentry->d_inode;
3000  
3001 -       dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
3002 -               page, PAGE_CACHE_SIZE, page->offset);
3003 +       dprintk("NFS: nfs_readpage (%p %ld@%Lu)\n",
3004 +               page, PAGE_CACHE_SIZE, (long long) nfs_page_offset(page));
3005  
3006         /*
3007          * Try to flush any pending writes to the file
3008 diff -urN lfs-ref/fs/nfs/write.c lfs/fs/nfs/write.c
3009 --- lfs-ref/fs/nfs/write.c      Fri Apr 20 22:31:20 2001
3010 +++ lfs/fs/nfs/write.c  Wed Sep 12 02:42:15 2001
3011 @@ -144,7 +144,7 @@
3012   */
3013  static int
3014  nfs_writepage_sync(struct file *file, struct inode *inode, struct page *page,
3015 -                  unsigned long offset, unsigned int count)
3016 +                  unsigned int offset, unsigned int count)
3017  {
3018         struct rpc_cred *cred = NULL;
3019         unsigned int    wsize = NFS_SERVER(inode)->wsize;
3020 @@ -152,16 +152,17 @@
3021         u8              *buffer;
3022         struct nfs_fattr fattr;
3023         struct nfs_writeverf verifier;
3024 +       loff_t          base;
3025  
3026         if (file)
3027                 cred = nfs_file_cred(file);
3028  
3029 -       dprintk("NFS:      nfs_writepage_sync(%x/%Ld %d@%ld)\n",
3030 +       dprintk("NFS:      nfs_writepage_sync(%x/%Ld %d@%Ld)\n",
3031                 inode->i_dev, (long long)NFS_FILEID(inode),
3032 -               count, nfs_page_offset(page) + offset);
3033 +               count, (long long) (nfs_page_offset(page) + offset));
3034  
3035         buffer = (u8 *) page_address(page) + offset;
3036 -       offset += nfs_page_offset(page);
3037 +       base = nfs_page_offset(page) + offset;
3038  
3039         flags = ((IS_SWAPFILE(inode)) ? NFS_RW_SWAP : 0) | NFS_RW_SYNC;
3040  
3041 @@ -170,7 +171,7 @@
3042                         wsize = count;
3043  
3044                 result = NFS_PROTO(inode)->write(inode, cred, &fattr, flags,
3045 -                                                offset, wsize, buffer,
3046 +                                                base, wsize, buffer,
3047                                                  &verifier);
3048                 nfs_write_attributes(inode, &fattr);
3049  
3050 @@ -184,15 +185,15 @@
3051                         wsize, result);
3052                 refresh = 1;
3053                 buffer  += wsize;
3054 -               offset  += wsize;
3055 +               base    += wsize;
3056                 written += wsize;
3057                 count   -= wsize;
3058                 /*
3059                  * If we've extended the file, update the inode
3060                  * now so we don't invalidate the cache.
3061                  */
3062 -               if (offset > inode->i_size)
3063 -                       inode->i_size = offset;
3064 +               if (base > inode->i_size)
3065 +                       inode->i_size = base;
3066         } while (count);
3067  
3068  io_error:
3069 @@ -213,9 +214,9 @@
3070                 inode = page->inode;
3071         else
3072                 inode = file->f_dentry->d_inode;
3073 -       if (page->offset >= inode->i_size)
3074 +       if (nfs_page_offset(page) >= inode->i_size)
3075                 return -EIO;
3076 -       if (page->offset + offset > inode->i_size)
3077 +       if (nfs_page_offset(page) + offset > inode->i_size)
3078                 offset = inode->i_size & (PAGE_CACHE_SIZE-1);
3079         return nfs_writepage_sync(file, inode, page, 0, offset);
3080  }
3081 @@ -228,7 +229,7 @@
3082  region_locked(struct inode *inode, struct nfs_page *req)
3083  {
3084         struct file_lock        *fl;
3085 -       unsigned long           rqstart, rqend;
3086 +       loff_t                  rqstart, rqend;
3087  
3088         /* Don't optimize writes if we don't use NLM */
3089         if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)
3090 @@ -895,9 +896,9 @@
3091         struct nfs_page *req;
3092         int             status = 0;
3093  
3094 -       dprintk("NFS:      nfs_updatepage(%s/%s %d@%ld, sync=%d)\n",
3095 +       dprintk("NFS:      nfs_updatepage(%s/%s %d@%Ld, sync=%d)\n",
3096                 dentry->d_parent->d_name.name, dentry->d_name.name,
3097 -               count, nfs_page_offset(page)+offset, sync);
3098 +               count, (long long) (nfs_page_offset(page)+offset), sync);
3099  
3100         /*
3101          * If wsize is smaller than page size, update and write
3102 @@ -947,8 +948,8 @@
3103         }
3104         nfs_release_request(req);
3105  done:
3106 -        dprintk("NFS:      nfs_updatepage returns %d (isize %ld)\n",
3107 -                                                status, inode->i_size);
3108 +        dprintk("NFS:      nfs_updatepage returns %d (isize %Ld)\n",
3109 +                                                status, (long long) inode->i_size);
3110         if (status < 0)
3111                 clear_bit(PG_uptodate, &page->flags);
3112         return status;
3113 @@ -1193,18 +1194,18 @@
3114  {
3115         struct nfs_page         *req;
3116         struct inode            *inode;
3117 -       unsigned long           start, end, len;
3118 +       loff_t                  start, end, len;
3119  
3120         /* Set up the RPC argument and reply structs
3121          * NB: take care not to mess about with data->commit et al. */
3122  
3123         end = 0;
3124 -       start = ~0;
3125 +       start = NFS_OFFSET_MAX;
3126         req = nfs_list_entry(head->next);
3127         inode = req->wb_inode;
3128         while (!list_empty(head)) {
3129                 struct nfs_page *req;
3130 -               unsigned long   rqstart, rqend;
3131 +               loff_t  rqstart, rqend;
3132                 req = nfs_list_entry(head->next);
3133                 nfs_list_remove_request(req);
3134                 nfs_list_add_request(req, &data->pages);
3135 @@ -1220,7 +1221,7 @@
3136         data->args.fh     = NFS_FH(inode);
3137         data->args.offset = start;
3138         len = end - start;
3139 -       if (end >= inode->i_size || len > (~((u32)0) >> 1))
3140 +       if (end >= inode->i_size || len < 0 || len > (~((u32)0) >> 1))
3141                 len = 0;
3142         data->res.count   = data->args.count = (u32)len;
3143         data->res.fattr   = &data->fattr;
3144 @@ -1298,11 +1299,11 @@
3145                 req = nfs_list_entry(data->pages.next);
3146                 nfs_list_remove_request(req);
3147  
3148 -               dprintk("NFS: commit (%x/%Ld %d@%ld)",
3149 +               dprintk("NFS: commit (%x/%Ld %d@%Ld)",
3150                         req->wb_inode->i_dev,
3151                         (long long)NFS_FILEID(req->wb_inode),
3152                         req->wb_bytes,
3153 -                       nfs_page_offset(req->wb_page) + req->wb_offset);
3154 +                       (long long) (nfs_page_offset(req->wb_page) + req->wb_offset));
3155                 if (task->tk_status < 0) {
3156                         if (req->wb_file)
3157                                 req->wb_file->f_error = task->tk_status;
3158 diff -urN lfs-ref/fs/nfsd/nfs3xdr.c lfs/fs/nfsd/nfs3xdr.c
3159 --- lfs-ref/fs/nfsd/nfs3xdr.c   Fri Apr 20 22:31:20 2001
3160 +++ lfs/fs/nfsd/nfs3xdr.c       Wed Sep 12 02:42:15 2001
3161 @@ -131,9 +131,9 @@
3162                 iap->ia_valid |= ATTR_SIZE;
3163                 p = xdr_decode_hyper(p, &newsize);
3164                 if (newsize <= NFS_OFFSET_MAX)
3165 -                       iap->ia_size = (u32) newsize;
3166 +                       iap->ia_size = newsize;
3167                 else
3168 -                       iap->ia_size = ~(size_t) 0;
3169 +                       iap->ia_size = NFS_OFFSET_MAX;
3170         }
3171         if ((tmp = ntohl(*p++)) == 1) { /* set to server time */
3172                 iap->ia_valid |= ATTR_ATIME;
3173 @@ -678,11 +678,6 @@
3174         if (name == 0)
3175                 return 0;
3176  
3177 -       /*
3178 -       dprintk("encode_entry(%.*s @%ld%s)\n",
3179 -               namlen, name, (long) offset, plus? " plus" : "");
3180 -        */
3181 -
3182         /* truncate filename if too long */
3183         if (namlen > NFS3_MAXNAMLEN)
3184                 namlen = NFS3_MAXNAMLEN;
3185 @@ -727,14 +722,14 @@
3186  
3187  int
3188  nfs3svc_encode_entry(struct readdir_cd *cd, const char *name,
3189 -                               int namlen, off_t offset, ino_t ino)
3190 +                               int namlen, off_t offset, ino_t ino, unsigned int d_type)
3191  {
3192         return encode_entry(cd, name, namlen, offset, ino, 0);
3193  }
3194  
3195  int
3196  nfs3svc_encode_entry_plus(struct readdir_cd *cd, const char *name,
3197 -                               int namlen, off_t offset, ino_t ino)
3198 +                               int namlen, off_t offset, ino_t ino, unsigned int d_type)
3199  {
3200         return encode_entry(cd, name, namlen, offset, ino, 1);
3201  }
3202 diff -urN lfs-ref/fs/nfsd/nfsfh.c lfs/fs/nfsd/nfsfh.c
3203 --- lfs-ref/fs/nfsd/nfsfh.c     Fri Apr 20 22:31:20 2001
3204 +++ lfs/fs/nfsd/nfsfh.c Wed Sep 12 02:42:15 2001
3205 @@ -41,7 +41,7 @@
3206   * the name matching the specified inode number.
3207   */
3208  static int filldir_one(void * __buf, const char * name, int len,
3209 -                       off_t pos, ino_t ino)
3210 +                       off_t pos, ino_t ino, unsigned int d_type)
3211  {
3212         struct nfsd_getdents_callback *buf = __buf;
3213         struct qstr *qs = buf->name;
3214 diff -urN lfs-ref/fs/nfsd/nfssvc.c lfs/fs/nfsd/nfssvc.c
3215 --- lfs-ref/fs/nfsd/nfssvc.c    Wed Sep 12 02:05:57 2001
3216 +++ lfs/fs/nfsd/nfssvc.c        Wed Sep 12 02:42:15 2001
3217 @@ -123,6 +123,7 @@
3218         current->session = 1;
3219         current->pgrp = 1;
3220         current->fs->umask = 0;
3221 +       current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
3222  
3223         /* Count active threads */
3224         atomic_inc(&nfsd_active);
3225 diff -urN lfs-ref/fs/nfsd/nfsxdr.c lfs/fs/nfsd/nfsxdr.c
3226 --- lfs-ref/fs/nfsd/nfsxdr.c    Fri Apr 20 22:31:20 2001
3227 +++ lfs/fs/nfsd/nfsxdr.c        Wed Sep 12 02:42:15 2001
3228 @@ -394,7 +394,7 @@
3229  
3230  int
3231  nfssvc_encode_entry(struct readdir_cd *cd, const char *name,
3232 -                                       int namlen, off_t offset, ino_t ino)
3233 +                   int namlen, off_t offset, ino_t ino, unsigned int d_type)
3234  {
3235         u32     *p = cd->buffer;
3236         int     buflen, slen;
3237 diff -urN lfs-ref/fs/nfsd/vfs.c lfs/fs/nfsd/vfs.c
3238 --- lfs-ref/fs/nfsd/vfs.c       Fri Apr 20 22:31:20 2001
3239 +++ lfs/fs/nfsd/vfs.c   Wed Sep 12 02:42:15 2001
3240 @@ -513,11 +513,11 @@
3241         filp->f_count = 1;
3242         filp->f_dentry = dentry;
3243         if (access & MAY_WRITE) {
3244 -               filp->f_flags = O_WRONLY;
3245 +               filp->f_flags = O_WRONLY | O_LARGEFILE;
3246                 filp->f_mode  = FMODE_WRITE;
3247                 DQUOT_INIT(inode);
3248         } else {
3249 -               filp->f_flags = O_RDONLY;
3250 +               filp->f_flags = O_RDONLY | O_LARGEFILE;
3251                 filp->f_mode  = FMODE_READ;
3252         }
3253  
3254 @@ -658,8 +658,9 @@
3255         /* Write back readahead params */
3256         if (ra != NULL) {
3257                 dprintk("nfsd: raparms %ld %ld %ld %ld %ld\n",
3258 -                       file.f_reada, file.f_ramax, file.f_raend,
3259 -                       file.f_ralen, file.f_rawin);
3260 +                       (u_long)file.f_reada, (u_long)file.f_ramax,
3261 +                       (u_long)file.f_raend, (u_long)file.f_ralen,
3262 +                       (u_long)file.f_rawin);
3263                 ra->p_reada = file.f_reada;
3264                 ra->p_ramax = file.f_ramax;
3265                 ra->p_raend = file.f_raend;
3266 diff -urN lfs-ref/fs/ntfs/fs.c lfs/fs/ntfs/fs.c
3267 --- lfs-ref/fs/ntfs/fs.c        Wed Sep 12 02:05:57 2001
3268 +++ lfs/fs/ntfs/fs.c    Wed Sep 12 02:42:15 2001
3269 @@ -200,7 +200,7 @@
3270         /* filldir expects an off_t rather than an loff_t.
3271            Hope we don't have more than 65535 index records */
3272         error=nf->filldir(nf->dirent,nf->name,nf->namelen,
3273 -                       (nf->ph<<16)|nf->pl,inum);
3274 +                       (nf->ph<<16)|nf->pl,inum,DT_UNKNOWN);
3275         ntfs_free(nf->name);
3276         /* Linux filldir errors are negative, other errors positive */
3277         return error;
3278 @@ -226,11 +226,11 @@
3279         if(cb.ph==0xFFFF){
3280                 /* FIXME: Maybe we can return those with the previous call */
3281                 switch(cb.pl){
3282 -               case 0: filldir(dirent,".",1,filp->f_pos,dir->i_ino);
3283 +               case 0: filldir(dirent,".",1,filp->f_pos,dir->i_ino,DT_DIR);
3284                         filp->f_pos=0xFFFF0001;
3285                         return 0;
3286                         /* FIXME: parent directory */
3287 -               case 1: filldir(dirent,"..",2,filp->f_pos,0);
3288 +               case 1: filldir(dirent,"..",2,filp->f_pos,0,DT_DIR);
3289                         filp->f_pos=0xFFFF0002;
3290                         return 0;
3291                 }
3292 @@ -823,6 +823,7 @@
3293         struct statfs fs;
3294         struct inode *mft;
3295         ntfs_volume *vol;
3296 +       ntfs_u64 size;
3297         int error;
3298  
3299         ntfs_debug(DEBUG_OTHER, "ntfs_statfs\n");
3300 @@ -831,16 +832,17 @@
3301         fs.f_type=NTFS_SUPER_MAGIC;
3302         fs.f_bsize=vol->clustersize;
3303  
3304 -       error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &fs.f_blocks );
3305 +       error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &size );
3306         if( error )
3307                 return -error;
3308 +       fs.f_blocks = size;
3309         fs.f_bfree=ntfs_get_free_cluster_count(vol->bitmap);
3310         fs.f_bavail=fs.f_bfree;
3311  
3312         /* Number of files is limited by free space only, so we lie here */
3313         fs.f_ffree=0;
3314         mft=iget(sb,FILE_MFT);
3315 -       fs.f_files=mft->i_size/vol->mft_recordsize;
3316 +       fs.f_files = (long)mft->i_size / vol->mft_recordsize;
3317         iput(mft);
3318  
3319         /* should be read from volume */
3320 diff -urN lfs-ref/fs/ntfs/super.c lfs/fs/ntfs/super.c
3321 --- lfs-ref/fs/ntfs/super.c     Mon Dec 11 16:58:03 2000
3322 +++ lfs/fs/ntfs/super.c Wed Sep 12 02:42:15 2001
3323 @@ -304,7 +304,7 @@
3324   * Writes the volume size into vol_size. Returns 0 if successful
3325   * or error.
3326   */
3327 -int ntfs_get_volumesize(ntfs_volume *vol, long *vol_size )
3328 +int ntfs_get_volumesize(ntfs_volume *vol, ntfs_u64 *vol_size )
3329  {
3330         ntfs_io io;
3331         ntfs_u64 size;
3332 @@ -325,9 +325,7 @@
3333         ntfs_getput_clusters(vol,0,0,&io);
3334         size=NTFS_GETU64(cluster0+0x28);
3335         ntfs_free(cluster0);
3336 -       /* FIXME: more than 2**32 cluster */
3337 -       /* FIXME: gcc will emit udivdi3 if we don't truncate it */
3338 -       *vol_size = ((unsigned long)size)/vol->clusterfactor;
3339 +       *vol_size = size;
3340         return 0;
3341  }
3342  
3343 diff -urN lfs-ref/fs/ntfs/super.h lfs/fs/ntfs/super.h
3344 --- lfs-ref/fs/ntfs/super.h     Mon Jan 17 16:44:42 2000
3345 +++ lfs/fs/ntfs/super.h Wed Sep 12 02:42:15 2001
3346 @@ -10,7 +10,7 @@
3347  #define ALLOC_REQUIRE_SIZE     2
3348  
3349  int ntfs_get_free_cluster_count(ntfs_inode *bitmap);
3350 -int ntfs_get_volumesize(ntfs_volume *vol, long *vol_size );
3351 +int ntfs_get_volumesize(ntfs_volume *vol, ntfs_u64 *vol_size );
3352  int ntfs_init_volume(ntfs_volume *vol,char *boot);
3353  int ntfs_load_special_files(ntfs_volume *vol);
3354  int ntfs_release_volume(ntfs_volume *vol);
3355 diff -urN lfs-ref/fs/open.c lfs/fs/open.c
3356 --- lfs-ref/fs/open.c   Wed Sep 12 02:05:57 2001
3357 +++ lfs/fs/open.c       Wed Sep 12 02:42:15 2001
3358 @@ -12,7 +12,7 @@
3359  
3360  #include <asm/uaccess.h>
3361  
3362 -asmlinkage int sys_statfs(const char * path, struct statfs * buf)
3363 +asmlinkage long sys_statfs(const char * path, struct statfs * buf)
3364  {
3365         struct dentry * dentry;
3366         int error;
3367 @@ -34,7 +34,7 @@
3368         return error;
3369  }
3370  
3371 -asmlinkage int sys_fstatfs(unsigned int fd, struct statfs * buf)
3372 +asmlinkage long sys_fstatfs(unsigned int fd, struct statfs * buf)
3373  {
3374         struct file * file;
3375         struct inode * inode;
3376 @@ -63,15 +63,16 @@
3377         return error;
3378  }
3379  
3380 -int do_truncate(struct dentry *dentry, unsigned long length)
3381 +int do_truncate(struct dentry *dentry, loff_t length)
3382  {
3383         struct inode *inode = dentry->d_inode;
3384         int error;
3385         struct iattr newattrs;
3386  
3387 -       /* Not pretty: "inode->i_size" shouldn't really be "off_t". But it is. */
3388 -       if ((off_t) length < 0)
3389 -               return -EINVAL;
3390 +       /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
3391 +       error = -EINVAL;
3392 +       if (length < 0)
3393 +               goto out;
3394  
3395         fs_down(&inode->i_sem);
3396         newattrs.ia_size = length;
3397 @@ -84,10 +85,11 @@
3398                         inode->i_op->truncate(inode);
3399         }
3400         fs_up(&inode->i_sem);
3401 +out:
3402         return error;
3403  }
3404  
3405 -asmlinkage int sys_truncate(const char * path, unsigned long length)
3406 +static inline long do_sys_truncate(const char * path, loff_t length)
3407  {
3408         struct dentry * dentry;
3409         struct inode * inode;
3410 @@ -136,7 +138,12 @@
3411         return error;
3412  }
3413  
3414 -asmlinkage int sys_ftruncate(unsigned int fd, unsigned long length)
3415 +asmlinkage long sys_truncate(const char * path, unsigned long length)
3416 +{
3417 +       return do_sys_truncate(path, length);
3418 +}
3419 +
3420 +static inline long do_sys_ftruncate(unsigned int fd, loff_t length)
3421  {
3422         struct inode * inode;
3423         struct dentry *dentry;
3424 @@ -171,6 +178,24 @@
3425         return error;
3426  }
3427  
3428 +asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
3429 +{
3430 +       return do_sys_ftruncate(fd, length);
3431 +}
3432 +
3433 +/* LFS versions of truncate are only needed on 32 bit machines */
3434 +#if BITS_PER_LONG == 32
3435 +asmlinkage long sys_truncate64(const char * path, loff_t length)
3436 +{
3437 +       return do_sys_truncate(path, length);
3438 +}
3439 +
3440 +asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
3441 +{
3442 +       return do_sys_ftruncate(fd, length);
3443 +}
3444 +#endif
3445 +
3446  #ifndef __alpha__
3447  
3448  /*
3449 @@ -184,7 +209,7 @@
3450   * must be owner or have write permission.
3451   * Else, update from *times, must be owner or super user.
3452   */
3453 -asmlinkage int sys_utime(char * filename, struct utimbuf * times)
3454 +asmlinkage long sys_utime(char * filename, struct utimbuf * times)
3455  {
3456         int error;
3457         struct dentry * dentry;
3458 @@ -232,7 +257,7 @@
3459   * must be owner or have write permission.
3460   * Else, update from *times, must be owner or super user.
3461   */
3462 -asmlinkage int sys_utimes(char * filename, struct timeval * utimes)
3463 +asmlinkage long sys_utimes(char * filename, struct timeval * utimes)
3464  {
3465         int error;
3466         struct dentry * dentry;
3467 @@ -278,7 +303,7 @@
3468   * We do this by temporarily clearing all FS-related capabilities and
3469   * switching the fsuid/fsgid around to the real ones.
3470   */
3471 -asmlinkage int sys_access(const char * filename, int mode)
3472 +asmlinkage long sys_access(const char * filename, int mode)
3473  {
3474         struct dentry * dentry;
3475         int old_fsuid, old_fsgid;
3476 @@ -325,7 +350,7 @@
3477         return res;
3478  }
3479  
3480 -asmlinkage int sys_chdir(const char * filename)
3481 +asmlinkage long sys_chdir(const char * filename)
3482  {
3483         int error;
3484         struct inode *inode;
3485 @@ -360,7 +385,7 @@
3486         return error;
3487  }
3488  
3489 -asmlinkage int sys_fchdir(unsigned int fd)
3490 +asmlinkage long sys_fchdir(unsigned int fd)
3491  {
3492         struct file *file;
3493         struct dentry *dentry;
3494 @@ -397,7 +422,7 @@
3495         return error;
3496  }
3497  
3498 -asmlinkage int sys_chroot(const char * filename)
3499 +asmlinkage long sys_chroot(const char * filename)
3500  {
3501         int error;
3502         struct inode *inode;
3503 @@ -437,7 +462,7 @@
3504         return error;
3505  }
3506  
3507 -asmlinkage int sys_fchmod(unsigned int fd, mode_t mode)
3508 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
3509  {
3510         struct inode * inode;
3511         struct dentry * dentry;
3512 @@ -475,7 +500,7 @@
3513         return err;
3514  }
3515  
3516 -asmlinkage int sys_chmod(const char * filename, mode_t mode)
3517 +asmlinkage long sys_chmod(const char * filename, mode_t mode)
3518  {
3519         struct dentry * dentry;
3520         struct inode * inode;
3521 @@ -571,7 +596,7 @@
3522         return error;
3523  }
3524  
3525 -asmlinkage int sys_chown(const char * filename, uid_t user, gid_t group)
3526 +asmlinkage long sys_chown(const char * filename, uid_t user, gid_t group)
3527  {
3528         struct dentry * dentry;
3529         int error;
3530 @@ -588,7 +613,7 @@
3531         return error;
3532  }
3533  
3534 -asmlinkage int sys_lchown(const char * filename, uid_t user, gid_t group)
3535 +asmlinkage long sys_lchown(const char * filename, uid_t user, gid_t group)
3536  {
3537         struct dentry * dentry;
3538         int error;
3539 @@ -606,7 +631,7 @@
3540  }
3541  
3542  
3543 -asmlinkage int sys_fchown(unsigned int fd, uid_t user, gid_t group)
3544 +asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
3545  {
3546         struct dentry * dentry;
3547         struct file * file;
3548 @@ -651,6 +676,9 @@
3549         f = get_empty_filp();
3550         if (!f)
3551                 goto out;
3552 +#if BITS_PER_LONG != 32
3553 +       flags |= O_LARGEFILE;
3554 +#endif
3555         f->f_flags = flag = flags;
3556         f->f_mode = (flag+1) & O_ACCMODE;
3557         if (f->f_mode)
3558 @@ -789,7 +817,7 @@
3559   * For backward compatibility?  Maybe this should be moved
3560   * into arch/i386 instead?
3561   */
3562 -asmlinkage int sys_creat(const char * pathname, int mode)
3563 +asmlinkage long sys_creat(const char * pathname, int mode)
3564  {
3565         return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
3566  }
3567 @@ -862,7 +890,7 @@
3568   * This routine simulates a hangup on the tty, to arrange that users
3569   * are given clean terminals at login time.
3570   */
3571 -asmlinkage int sys_vhangup(void)
3572 +asmlinkage long sys_vhangup(void)
3573  {
3574         int ret = -EPERM;
3575  
3576 diff -urN lfs-ref/fs/proc/array.c lfs/fs/proc/array.c
3577 --- lfs-ref/fs/proc/array.c     Wed Sep 12 02:39:57 2001
3578 +++ lfs/fs/proc/array.c Wed Sep 12 02:42:15 2001
3579 @@ -1173,11 +1173,11 @@
3580   *         + (index into the line)
3581   */
3582  /* for systems with sizeof(void*) == 4: */
3583 -#define MAPS_LINE_FORMAT4        "%08lx-%08lx %s %08lx %s %lu"
3584 -#define MAPS_LINE_MAX4 49 /* sum of 8  1  8  1 4 1 8 1 5 1 10 1 */
3585 +#define MAPS_LINE_FORMAT4        "%08lx-%08lx %s %016Lx %s %lu"
3586 +#define MAPS_LINE_MAX4 57 /* sum of 8  1  8  1 4 1 16 1 5 1 10 1 */
3587  
3588  /* for systems with sizeof(void*) == 8: */
3589 -#define MAPS_LINE_FORMAT8        "%016lx-%016lx %s %016lx %s %lu"
3590 +#define MAPS_LINE_FORMAT8        "%016lx-%016lx %s %016Lx %s %lu"
3591  #define MAPS_LINE_MAX8 73 /* sum of 16  1  16  1 4 1 16 1 5 1 10 1 */
3592  
3593  #define MAPS_LINE_MAX  MAPS_LINE_MAX8
3594 diff -urN lfs-ref/fs/proc/fd.c lfs/fs/proc/fd.c
3595 --- lfs-ref/fs/proc/fd.c        Wed Sep 12 02:39:56 2001
3596 +++ lfs/fs/proc/fd.c    Wed Sep 12 02:42:15 2001
3597 @@ -146,7 +146,7 @@
3598                 ino = inode->i_ino;
3599                 if (fd)
3600                         ino = (ino & 0xffff0000) | PROC_PID_INO;
3601 -               if (filldir(dirent, "..", fd+1, fd, ino) < 0)
3602 +               if (filldir(dirent, "..", fd+1, fd, ino, DT_DIR) < 0)
3603                         goto out;
3604         }
3605  
3606 @@ -176,7 +176,7 @@
3607                 read_unlock(&tasklist_lock);
3608  
3609                 ino = (pid << 16) + PROC_PID_FD_DIR + fd;
3610 -               if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino) < 0)
3611 +               if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0)
3612                         goto out;
3613  
3614                 read_lock(&tasklist_lock);
3615 diff -urN lfs-ref/fs/proc/openpromfs.c lfs/fs/proc/openpromfs.c
3616 --- lfs-ref/fs/proc/openpromfs.c        Mon Jan 17 16:44:43 2000
3617 +++ lfs/fs/proc/openpromfs.c    Wed Sep 12 02:42:15 2001
3618 @@ -846,14 +846,14 @@
3619         i = filp->f_pos;
3620         switch (i) {
3621         case 0:
3622 -               if (filldir(dirent, ".", 1, i, ino) < 0) return 0;
3623 +               if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0) return 0;
3624                 i++;
3625                 filp->f_pos++;
3626                 /* fall thru */
3627         case 1:
3628                 if (filldir(dirent, "..", 2, i, 
3629                         (NODE(ino).parent == 0xffff) ? 
3630 -                       PROC_ROOT_INO : NODE2INO(NODE(ino).parent)) < 0) 
3631 +                       PROC_ROOT_INO : NODE2INO(NODE(ino).parent), DT_DIR) < 0) 
3632                         return 0;
3633                 i++;
3634                 filp->f_pos++;
3635 @@ -869,14 +869,14 @@
3636                         if (prom_getname (nodes[node].node, buffer, 128) < 0)
3637                                 return 0;
3638                         if (filldir(dirent, buffer, strlen(buffer),
3639 -                                   filp->f_pos, NODE2INO(node)) < 0)
3640 +                                   filp->f_pos, NODE2INO(node), DT_DIR) < 0)
3641                                 return 0;
3642                         filp->f_pos++;
3643                         node = nodes[node].next;
3644                 }
3645                 j = NODEP2INO(NODE(ino).first_prop);
3646                 if (!i) {
3647 -                       if (filldir(dirent, ".node", 5, filp->f_pos, j) < 0)
3648 +                       if (filldir(dirent, ".node", 5, filp->f_pos, j, DT_REG) < 0)
3649                                 return 0;
3650                         filp->f_pos++;
3651                 } else
3652 @@ -887,7 +887,7 @@
3653                                 if (alias_names [i]) {
3654                                         if (filldir (dirent, alias_names [i], 
3655                                                 strlen (alias_names [i]), 
3656 -                                               filp->f_pos, j) < 0) return 0;
3657 +                                               filp->f_pos, j, DT_REG) < 0) return 0;
3658                                         filp->f_pos++;
3659                                 }
3660                         }
3661 @@ -899,7 +899,7 @@
3662                                 if (i) i--;
3663                                 else {
3664                                         if (filldir(dirent, p, strlen(p),
3665 -                                                   filp->f_pos, j) < 0)
3666 +                                                   filp->f_pos, j, DT_REG) < 0)
3667                                                 return 0;
3668                                         filp->f_pos++;
3669                                 }
3670 @@ -911,7 +911,7 @@
3671                                 else {
3672                                         if (filldir(dirent, d->name,
3673                                                     strlen(d->name),
3674 -                                                   filp->f_pos, d->inode) < 0)
3675 +                                                   filp->f_pos, d->inode, d->mode >> 12) < 0)
3676                                                 return 0;
3677                                         filp->f_pos++;
3678                                 }
3679 diff -urN lfs-ref/fs/proc/root.c lfs/fs/proc/root.c
3680 --- lfs-ref/fs/proc/root.c      Wed Sep 12 02:39:56 2001
3681 +++ lfs/fs/proc/root.c  Wed Sep 12 02:42:15 2001
3682 @@ -890,13 +890,13 @@
3683         i = filp->f_pos;
3684         switch (i) {
3685                 case 0:
3686 -                       if (filldir(dirent, ".", 1, i, ino) < 0)
3687 +                       if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
3688                                 return 0;
3689                         i++;
3690                         filp->f_pos++;
3691                         /* fall through */
3692                 case 1:
3693 -                       if (filldir(dirent, "..", 2, i, de->parent->low_ino) < 0)
3694 +                       if (filldir(dirent, "..", 2, i, de->parent->low_ino, DT_DIR) < 0)
3695                                 return 0;
3696                         i++;
3697                         filp->f_pos++;
3698 @@ -915,7 +915,7 @@
3699                         }
3700  
3701                         do {
3702 -                               if (filldir(dirent, de->name, de->namelen, filp->f_pos, ino | de->low_ino) < 0)
3703 +                               if (filldir(dirent, de->name, de->namelen, filp->f_pos, ino | de->low_ino, de->mode >> 12) < 0)
3704                                         return 0;
3705                                 filp->f_pos++;
3706                                 de = de->next;
3707 @@ -982,7 +982,7 @@
3708                         pid /= 10;
3709                 } while (pid);
3710  
3711 -               if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, ino) < 0)
3712 +               if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, ino, DT_DIR) < 0)
3713                         break;
3714                 filp->f_pos++;
3715         }
3716 diff -urN lfs-ref/fs/qnx4/dir.c lfs/fs/qnx4/dir.c
3717 --- lfs-ref/fs/qnx4/dir.c       Thu May  4 13:00:40 2000
3718 +++ lfs/fs/qnx4/dir.c   Wed Sep 12 02:42:15 2001
3719 @@ -61,7 +61,7 @@
3720                                                         QNX4_INODES_PER_BLOCK +
3721                                                         le->dl_inode_ndx;
3722                                         }
3723 -                                       if (filldir(dirent, de->di_fname, size, filp->f_pos, ino) < 0) {
3724 +                                       if (filldir(dirent, de->di_fname, size, filp->f_pos, ino, DT_UNKNOWN) < 0) {
3725                                                 brelse(bh);
3726                                                 return 0;
3727                                         }
3728 diff -urN lfs-ref/fs/read_write.c lfs/fs/read_write.c
3729 --- lfs-ref/fs/read_write.c     Fri Apr 20 22:31:20 2001
3730 +++ lfs/fs/read_write.c Wed Sep 12 02:42:15 2001
3731 @@ -48,7 +48,7 @@
3732  
3733  asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
3734  {
3735 -       off_t retval;
3736 +       off_t retval, oldpos;
3737         struct file * file;
3738         struct dentry * dentry;
3739         struct inode * inode;
3740 @@ -62,9 +62,19 @@
3741         if (!(dentry = file->f_dentry) ||
3742             !(inode = dentry->d_inode))
3743                 goto out_putf;
3744 +       oldpos = file->f_pos;
3745         retval = -EINVAL;
3746         if (origin <= 2)
3747                 retval = llseek(file, offset, origin);
3748 +
3749 +       /* Demand L-F-S compliance only from normal files,
3750 +          thus raw devices can do whatever they please.. */
3751 +       if (!(file->f_flags & O_LARGEFILE) &&
3752 +           retval >= 0 && S_ISREG(inode->i_mode) &&
3753 +           file->f_pos > 0x7fffffff) {
3754 +               file->f_pos = oldpos;
3755 +               retval = -EOVERFLOW;
3756 +       }
3757  out_putf:
3758         fput(file);
3759  bad:
3760 @@ -81,7 +91,7 @@
3761         struct file * file;
3762         struct dentry * dentry;
3763         struct inode * inode;
3764 -       loff_t offset;
3765 +       loff_t offset, oldpos;
3766  
3767         lock_kernel();
3768         retval = -EBADF;
3769 @@ -96,6 +106,7 @@
3770         if (origin > 2)
3771                 goto out_putf;
3772  
3773 +       oldpos = file->f_pos;
3774         offset = llseek(file, ((loff_t) offset_high << 32) | offset_low,
3775                         origin);
3776  
3777 @@ -105,6 +116,14 @@
3778                 if (!copy_to_user(result, &offset, sizeof(offset)))
3779                         retval = 0;
3780         }
3781 +       if (!(file->f_flags & O_LARGEFILE) && S_ISREG(inode->i_mode) &&
3782 +           file->f_pos > 0x7fffffff) {
3783 +               /* The target position isn't presentable without
3784 +                  O_LARGEFILE flag being set --> yield error, and
3785 +                  restore the file position. */
3786 +               file->f_pos = oldpos;
3787 +               retval = -EOVERFLOW;
3788 +       }
3789  out_putf:
3790         fput(file);
3791  bad:
3792 @@ -335,6 +354,7 @@
3793         ssize_t ret;
3794         struct file * file;
3795         ssize_t (*read)(struct file *, char *, size_t, loff_t *);
3796 +       struct inode * inode;
3797  
3798         lock_kernel();
3799  
3800 @@ -342,10 +362,13 @@
3801         file = fget(fd);
3802         if (!file)
3803                 goto bad_file;
3804 +
3805 +       inode = file->f_dentry->d_inode;
3806 +
3807         if (!(file->f_mode & FMODE_READ))
3808                 goto out;
3809 -       ret = locks_verify_area(FLOCK_VERIFY_READ, file->f_dentry->d_inode,
3810 -                               file, pos, count);
3811 +
3812 +       ret = locks_verify_area(FLOCK_VERIFY_READ, inode, file, pos, count);
3813         if (ret)
3814                 goto out;
3815         ret = -EINVAL;
3816 @@ -367,6 +390,7 @@
3817         ssize_t ret;
3818         struct file * file;
3819         ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
3820 +       struct inode * inode;
3821  
3822         lock_kernel();
3823  
3824 @@ -376,8 +400,10 @@
3825                 goto bad_file;
3826         if (!(file->f_mode & FMODE_WRITE))
3827                 goto out;
3828 -       ret = locks_verify_area(FLOCK_VERIFY_WRITE, file->f_dentry->d_inode,
3829 -                               file, pos, count);
3830 +
3831 +       inode = file->f_dentry->d_inode;
3832 +
3833 +       ret = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file, pos, count);
3834         if (ret)
3835                 goto out;
3836         ret = -EINVAL;
3837 @@ -386,9 +412,9 @@
3838         if (pos < 0)
3839                 goto out;
3840  
3841 -       fs_down(&file->f_dentry->d_inode->i_sem);
3842 +       fs_down(&inode->i_sem);
3843         ret = write(file, buf, count, &pos);
3844 -       fs_up(&file->f_dentry->d_inode->i_sem);
3845 +       fs_up(&inode->i_sem);
3846  
3847  out:
3848         fput(file);
3849 diff -urN lfs-ref/fs/readdir.c lfs/fs/readdir.c
3850 --- lfs-ref/fs/readdir.c        Mon Jan 17 16:44:43 2000
3851 +++ lfs/fs/readdir.c    Wed Sep 12 02:42:15 2001
3852 @@ -36,7 +36,7 @@
3853         int count;
3854  };
3855  
3856 -static int fillonedir(void * __buf, const char * name, int namlen, off_t offset, ino_t ino)
3857 +static int fillonedir(void * __buf, const char * name, int namlen, off_t offset, ino_t ino, unsigned int d_type)
3858  {
3859         struct readdir_callback * buf = (struct readdir_callback *) __buf;
3860         struct old_linux_dirent * dirent;
3861 @@ -118,7 +118,7 @@
3862         int error;
3863  };
3864  
3865 -static int filldir(void * __buf, const char * name, int namlen, off_t offset, ino_t ino)
3866 +static int filldir(void * __buf, const char * name, int namlen, off_t offset, ino_t ino, unsigned int d_type)
3867  {
3868         struct linux_dirent * dirent;
3869         struct getdents_callback * buf = (struct getdents_callback *) __buf;
3870 @@ -187,6 +187,123 @@
3871         lastdirent = buf.previous;
3872         if (lastdirent) {
3873                 put_user(file->f_pos, &lastdirent->d_off);
3874 +               error = count - buf.count;
3875 +       }
3876 +
3877 +out_putf:
3878 +       fput(file);
3879 +out:
3880 +       unlock_kernel();
3881 +       return error;
3882 +}
3883 +
3884 +
3885 +/*
3886 + * And even better one including d_type field and 64bit d_ino and d_off.
3887 + */
3888 +struct linux_dirent64 {
3889 +       u64             d_ino;
3890 +       s64             d_off;
3891 +       unsigned short  d_reclen;
3892 +       unsigned char   d_type;
3893 +       char            d_name[0];
3894 +};
3895 +
3896 +#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
3897 +
3898 +struct getdents_callback64 {
3899 +       struct linux_dirent64 * current_dir;
3900 +       struct linux_dirent64 * previous;
3901 +       int count;
3902 +       int error;
3903 +};
3904 +
3905 +static int filldir64(void * __buf, const char * name, int namlen, off_t offset,
3906 +                    ino_t ino, unsigned int d_type)
3907 +{
3908 +       struct linux_dirent64 * dirent, d;
3909 +       struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf;
3910 +       int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namlen + 1);
3911 +
3912 +       buf->error = -EINVAL;   /* only used if we fail.. */
3913 +       if (reclen > buf->count)
3914 +               return -EINVAL;
3915 +       dirent = buf->previous;
3916 +       if (dirent) {
3917 +#if BITS_PER_LONG < 64
3918 +               d.d_off = offset;
3919 +               copy_to_user(&dirent->d_off, &d.d_off, sizeof(d.d_off));
3920 +#else
3921 +               put_user(offset, &dirent->d_off);
3922 +#endif
3923 +       }
3924 +       dirent = buf->current_dir;
3925 +       buf->previous = dirent;
3926 +       memset(&d, 0, NAME_OFFSET(&d));
3927 +       d.d_ino = ino;
3928 +       d.d_reclen = reclen;
3929 +       d.d_type = d_type;
3930 +       copy_to_user(dirent, &d, NAME_OFFSET(&d));
3931 +       copy_to_user(dirent->d_name, name, namlen);
3932 +       put_user(0, dirent->d_name + namlen);
3933 +       ((char *) dirent) += reclen;
3934 +       buf->current_dir = dirent;
3935 +       buf->count -= reclen;
3936 +       return 0;
3937 +}
3938 +
3939 +asmlinkage int sys_getdents64(unsigned int fd, void * dirent, unsigned int count)
3940 +{
3941 +       struct file * file;
3942 +       struct dentry * dentry;
3943 +       struct inode * inode;
3944 +       struct linux_dirent64 * lastdirent;
3945 +       struct getdents_callback64 buf;
3946 +       int error;
3947 +
3948 +       lock_kernel();
3949 +       error = -EBADF;
3950 +       file = fget(fd);
3951 +       if (!file)
3952 +               goto out;
3953 +
3954 +       dentry = file->f_dentry;
3955 +       if (!dentry)
3956 +               goto out_putf;
3957 +
3958 +       inode = dentry->d_inode;
3959 +       if (!inode)
3960 +               goto out_putf;
3961 +
3962 +       buf.current_dir = (struct linux_dirent64 *) dirent;
3963 +       buf.previous = NULL;
3964 +       buf.count = count;
3965 +       buf.error = 0;
3966 +
3967 +       error = -ENOTDIR;
3968 +       if (!file->f_op || !file->f_op->readdir)
3969 +               goto out_putf;
3970 +
3971 +
3972 +       /*
3973 +        * Get the inode's semaphore to prevent changes
3974 +        * to the directory while we read it.
3975 +        */
3976 +       down(&inode->i_sem);
3977 +       error = file->f_op->readdir(file, &buf, filldir64);
3978 +       up(&inode->i_sem);
3979 +       if (error < 0)
3980 +               goto out_putf;
3981 +       error = buf.error;
3982 +       lastdirent = buf.previous;
3983 +       if (lastdirent) {
3984 +#if BITS_PER_LONG < 64
3985 +               s64 d_off;
3986 +               d_off = file->f_pos;
3987 +               copy_to_user(&lastdirent->d_off, &d_off, sizeof(d_off));
3988 +#else
3989 +               put_user(file->f_pos, &lastdirent->d_off);
3990 +#endif
3991                 error = count - buf.count;
3992         }
3993  
3994 diff -urN lfs-ref/fs/romfs/inode.c lfs/fs/romfs/inode.c
3995 --- lfs-ref/fs/romfs/inode.c    Thu May  4 13:00:40 2000
3996 +++ lfs/fs/romfs/inode.c        Wed Sep 12 02:42:15 2001
3997 @@ -258,6 +258,10 @@
3998         return res;
3999  }
4000  
4001 +static unsigned char romfs_dtype_table[] = {
4002 +       DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_SOCK, DT_FIFO
4003 +};
4004 +
4005  static int
4006  romfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
4007  {
4008 @@ -302,7 +306,8 @@
4009                 nextfh = ntohl(ri.next);
4010                 if ((nextfh & ROMFH_TYPE) == ROMFH_HRD)
4011                         ino = ntohl(ri.spec);
4012 -               if (filldir(dirent, fsname, j, offset, ino) < 0) {
4013 +               if (filldir(dirent, fsname, j, offset, ino,
4014 +                           romfs_dtype_table[nextfh & ROMFH_TYPE]) < 0) {
4015                         return stored;
4016                 }
4017                 stored++;
4018 @@ -396,7 +401,7 @@
4019         buf = page_address(page);
4020         clear_bit(PG_uptodate, &page->flags);
4021         clear_bit(PG_error, &page->flags);
4022 -       offset = page->offset;
4023 +       offset = pgoff2loff(page->index);
4024         if (offset < inode->i_size) {
4025                 avail = inode->i_size-offset;
4026                 readlen = min(avail, PAGE_SIZE);
4027 diff -urN lfs-ref/fs/smbfs/cache.c lfs/fs/smbfs/cache.c
4028 --- lfs-ref/fs/smbfs/cache.c    Tue Sep  5 02:28:49 2000
4029 +++ lfs/fs/smbfs/cache.c        Wed Sep 12 02:42:15 2001
4030 @@ -40,7 +40,7 @@
4031         struct cache_head * cachep;
4032  
4033         VERBOSE("finding cache for %s/%s\n", DENTRY_PATH(dentry));
4034 -       cachep = (struct cache_head *) get_cached_page(inode, 0, 1);
4035 +       cachep = (struct cache_head *) get_cached_page(inode, ulong2pgoff(0), 1);
4036         if (!cachep)
4037                 goto out;
4038         if (cachep->valid)
4039 @@ -61,9 +61,10 @@
4040                                 PARANOIA("cache %s/%s has existing block!\n",
4041                                          DENTRY_PATH(dentry));
4042  #endif
4043 -                       offset = PAGE_SIZE + (i << PAGE_SHIFT);
4044 -                       block = (struct cache_block *) get_cached_page(inode,
4045 -                                                               offset, 0);
4046 +                       /* byte_offset = PAGE_SIZE + (i << PAGE_SHIFT); */
4047 +                       /*    --> page_offset = 1 + i  */ 
4048 +                       block = (struct cache_block *)
4049 +                               get_cached_page(inode, ulong2pgoff(i+1), 0);
4050                         if (!block)
4051                                 goto out;
4052                         index->block = block;
4053 @@ -128,7 +129,7 @@
4054         struct inode * inode = get_cache_inode(cachep);
4055         struct cache_index * index;
4056         struct cache_block * block;
4057 -       unsigned long page_off;
4058 +       pgoff_t page_off;
4059         unsigned int nent, offset, len = entry->len;
4060         unsigned int needed = len + sizeof(struct cache_entry);
4061  
4062 @@ -180,14 +181,15 @@
4063          */
4064  get_block:
4065         cachep->pages++;
4066 -       page_off = PAGE_SIZE + (cachep->idx << PAGE_SHIFT);
4067 +       /* page_byte_off = PAGE_SIZE + (cachep->idx << PAGE_SHIFT); */
4068 +       page_off = ulong2pgoff(1 + cachep->idx);
4069         block = (struct cache_block *) get_cached_page(inode, page_off, 1);
4070         if (block)
4071         {
4072                 index->block = block;
4073                 index->space = PAGE_SIZE;
4074                 VERBOSE("inode=%p, pages=%d, block at %ld\n",
4075 -                       inode, cachep->pages, page_off);
4076 +                       inode, cachep->pages, (u_long)pgoff2loff(page_off));
4077                 goto add_entry;
4078         }
4079         /*
4080 diff -urN lfs-ref/fs/smbfs/dir.c lfs/fs/smbfs/dir.c
4081 --- lfs-ref/fs/smbfs/dir.c      Mon Dec 11 16:58:03 2000
4082 +++ lfs/fs/smbfs/dir.c  Wed Sep 12 02:42:15 2001
4083 @@ -91,12 +91,12 @@
4084         switch ((unsigned int) filp->f_pos)
4085         {
4086         case 0:
4087 -               if (filldir(dirent, ".", 1, 0, dir->i_ino) < 0)
4088 +               if (filldir(dirent, ".", 1, 0, dir->i_ino, DT_DIR) < 0)
4089                         goto out;
4090                 filp->f_pos = 1;
4091         case 1:
4092                 if (filldir(dirent, "..", 2, 1,
4093 -                               dentry->d_parent->d_inode->i_ino) < 0)
4094 +                               dentry->d_parent->d_inode->i_ino, DT_DIR) < 0)
4095                         goto out;
4096                 filp->f_pos = 2;
4097         }
4098 @@ -151,7 +151,7 @@
4099                 }
4100  
4101                 if (filldir(dirent, entry->name, entry->len, 
4102 -                                   filp->f_pos, entry->ino) < 0)
4103 +                                   filp->f_pos, entry->ino, DT_UNKNOWN) < 0)
4104                         break;
4105                 filp->f_pos += 1;
4106         }
4107 diff -urN lfs-ref/fs/smbfs/file.c lfs/fs/smbfs/file.c
4108 --- lfs-ref/fs/smbfs/file.c     Tue Sep  5 02:28:49 2000
4109 +++ lfs/fs/smbfs/file.c Wed Sep 12 02:42:15 2001
4110 @@ -15,6 +15,7 @@
4111  #include <linux/mm.h>
4112  #include <linux/malloc.h>
4113  #include <linux/pagemap.h>
4114 +#include <linux/unistd.h>
4115  
4116  #include <asm/uaccess.h>
4117  #include <asm/system.h>
4118 @@ -47,15 +48,15 @@
4119  smb_readpage_sync(struct dentry *dentry, struct page *page)
4120  {
4121         char *buffer = (char *) page_address(page);
4122 -       unsigned long offset = page->offset;
4123 +       loff_t loffset = pgoff2loff(page->index);
4124         int rsize = smb_get_rsize(server_from_dentry(dentry));
4125         int count = PAGE_SIZE;
4126         int result;
4127  
4128         clear_bit(PG_error, &page->flags);
4129  
4130 -       VERBOSE("file %s/%s, count=%d@%ld, rsize=%d\n",
4131 -               DENTRY_PATH(dentry), count, offset, rsize);
4132 +       VERBOSE("file %s/%s, count=%d@%Ld, rsize=%d\n",
4133 +               DENTRY_PATH(dentry), count, loffset, rsize);
4134         result = smb_open(dentry, SMB_O_RDONLY);
4135         if (result < 0)
4136         {
4137 @@ -68,12 +69,12 @@
4138                 if (count < rsize)
4139                         rsize = count;
4140  
4141 -               result = smb_proc_read(dentry, offset, rsize, buffer);
4142 +               result = smb_proc_read(dentry, loffset, rsize, buffer);
4143                 if (result < 0)
4144                         goto io_error;
4145  
4146                 count -= result;
4147 -               offset += result;
4148 +               loffset += result;
4149                 buffer += result;
4150                 dentry->d_inode->i_atime = CURRENT_TIME;
4151                 if (result < rsize)
4152 @@ -113,23 +114,36 @@
4153   * Offset is the data offset within the page.
4154   */
4155  static int
4156 -smb_writepage_sync(struct dentry *dentry, struct page *page,
4157 +smb_writepage_sync(struct file *file, struct page *page,
4158                    unsigned long offset, unsigned int count)
4159  {
4160 +       struct dentry * dentry = file->f_dentry;
4161         struct inode *inode = dentry->d_inode;
4162         u8 *buffer = (u8 *) page_address(page) + offset;
4163         int wsize = smb_get_wsize(server_from_dentry(dentry));
4164         int result, written = 0;
4165 +       loff_t loffset = pgoff2loff(page->index) + offset;
4166 +
4167 +       VERBOSE("file %s/%s, count=%d@%Ld, wsize=%d\n",
4168 +               DENTRY_PATH(dentry), count, loffset, wsize);
4169  
4170 -       offset += page->offset;
4171 -       VERBOSE("file %s/%s, count=%d@%ld, wsize=%d\n",
4172 -               DENTRY_PATH(dentry), count, offset, wsize);
4173 +       if (!(file->f_flags & O_LARGEFILE)) {
4174 +               if (loffset >= 0x7fffffffULL)
4175 +                       return -EFBIG;
4176 +               if (loffset + count > 0x7fffffffULL)
4177 +                       count = 0x7fffffff - loffset;
4178 +       }
4179 +
4180 +       if (loffset >= 0xffffffffULL) /* 4G-1 ???  Or 2G-1 ??? */
4181 +               return -EFBIG;
4182 +       if ((loffset + count) > 0xffffffffULL)
4183 +               count = 0xffffffffULL - loffset;
4184  
4185         do {
4186                 if (count < wsize)
4187                         wsize = count;
4188  
4189 -               result = smb_proc_write(dentry, offset, wsize, buffer);
4190 +               result = smb_proc_write(dentry, loffset, wsize, buffer);
4191                 if (result < 0)
4192                         break;
4193                 /* N.B. what if result < wsize?? */
4194 @@ -138,29 +152,27 @@
4195                         printk(KERN_DEBUG "short write, wsize=%d, result=%d\n",
4196                                wsize, result);
4197  #endif
4198 -               buffer += wsize;
4199 -               offset += wsize;
4200 +               buffer  += wsize;
4201 +               loffset += wsize;
4202                 written += wsize;
4203 -               count -= wsize;
4204 +               count   -= wsize;
4205                 /*
4206                  * Update the inode now rather than waiting for a refresh.
4207                  */
4208                 inode->i_mtime = inode->i_atime = CURRENT_TIME;
4209 -               if (offset > inode->i_size)
4210 -                       inode->i_size = offset;
4211 +               if (loffset > inode->i_size)
4212 +                       inode->i_size = loffset;
4213                 inode->u.smbfs_i.cache_valid |= SMB_F_LOCALWRITE;
4214         } while (count);
4215         return written ? written : result;
4216  }
4217  
4218  /*
4219 - * Write a page to the server. This will be used for NFS swapping only
4220 - * (for now), and we currently do this synchronously only.
4221 + * Write a page to the server.
4222   */
4223  static int
4224  smb_writepage(struct file *file, struct page *page)
4225  {
4226 -       struct dentry *dentry = file->f_dentry;
4227         int     result;
4228  
4229  #ifdef SMBFS_PARANOIA
4230 @@ -169,7 +181,7 @@
4231  #endif
4232         set_bit(PG_locked, &page->flags);
4233         atomic_inc(&page->count);
4234 -       result = smb_writepage_sync(dentry, page, 0, PAGE_SIZE);
4235 +       result = smb_writepage_sync(file, page, 0, PAGE_SIZE);
4236         smb_unlock_page(page);
4237         free_page(page_address(page));
4238         return result;
4239 @@ -180,10 +192,10 @@
4240  {
4241         struct dentry *dentry = file->f_dentry;
4242  
4243 -       DEBUG1("(%s/%s %d@%ld, sync=%d)\n",
4244 -              DENTRY_PATH(dentry), count, page->offset+offset, sync);
4245 +       DEBUG1("(%s/%s %d@%Ld, sync=%d)\n",
4246 +              DENTRY_PATH(dentry), count, pgoff2loff(page->index)+offset, sync);
4247  
4248 -       return smb_writepage_sync(dentry, page, offset, count);
4249 +       return smb_writepage_sync(file, page, offset, count);
4250  }
4251  
4252  static ssize_t
4253 @@ -192,8 +204,8 @@
4254         struct dentry * dentry = file->f_dentry;
4255         ssize_t status;
4256  
4257 -       VERBOSE("file %s/%s, count=%lu@%lu\n", DENTRY_PATH(dentry),
4258 -               (unsigned long) count, (unsigned long) *ppos);
4259 +       VERBOSE("file %s/%s, count=%lu@%Lu\n", DENTRY_PATH(dentry),
4260 +               (unsigned long) count, *ppos);
4261  
4262         status = smb_revalidate_inode(dentry);
4263         if (status)
4264 @@ -242,8 +254,8 @@
4265         struct dentry * dentry = file->f_dentry;
4266         ssize_t result;
4267  
4268 -       VERBOSE("file %s/%s, count=%lu@%lu, pages=%ld\n", DENTRY_PATH(dentry),
4269 -               (unsigned long) count, (unsigned long) *ppos,
4270 +       VERBOSE("file %s/%s, count=%lu@%Lu, pages=%ld\n", DENTRY_PATH(dentry),
4271 +               (unsigned long) count, *ppos,
4272                 dentry->d_inode->i_nrpages);
4273  
4274         result = smb_revalidate_inode(dentry);
4275 @@ -261,8 +273,8 @@
4276         if (count > 0)
4277         {
4278                 result = generic_file_write(file, buf, count, ppos);
4279 -               VERBOSE("pos=%ld, size=%ld, mtime=%ld, atime=%ld\n",
4280 -                       (long) file->f_pos, dentry->d_inode->i_size,
4281 +               VERBOSE("pos=%Ld, size=%Ld, mtime=%ld, atime=%ld\n",
4282 +                       file->f_pos, dentry->d_inode->i_size,
4283                         dentry->d_inode->i_mtime, dentry->d_inode->i_atime);
4284         }
4285  out:
4286 diff -urN lfs-ref/fs/smbfs/proc.c lfs/fs/smbfs/proc.c
4287 --- lfs-ref/fs/smbfs/proc.c     Wed Sep 12 02:05:57 2001
4288 +++ lfs/fs/smbfs/proc.c Wed Sep 12 02:42:15 2001
4289 @@ -1084,13 +1084,16 @@
4290     file-id would not be valid after a reconnection. */
4291  
4292  int
4293 -smb_proc_read(struct dentry *dentry, off_t offset, int count, char *data)
4294 +smb_proc_read(struct dentry *dentry, loff_t offset, int count, char *data)
4295  {
4296         struct smb_sb_info *server = server_from_dentry(dentry);
4297         __u16 returned_count, data_len;
4298         unsigned char *buf;
4299         int result;
4300  
4301 +       if (offset > 0xffffffff)
4302 +               return -EIO;
4303 +
4304         smb_lock_server(server);
4305         smb_setup_header(server, SMBread, 5, 0);
4306         buf = server->packet;
4307 @@ -1133,13 +1136,16 @@
4308  }
4309  
4310  int
4311 -smb_proc_write(struct dentry *dentry, off_t offset, int count, const char *data)
4312 +smb_proc_write(struct dentry *dentry, loff_t offset, int count, const char *data)
4313  {
4314         struct smb_sb_info *server = server_from_dentry(dentry);
4315         int result;
4316         __u8 *p;
4317  
4318 -       VERBOSE("file %s/%s, count=%d@%ld, packet_size=%d\n",
4319 +       if (offset > 0xffffffff)
4320 +               return -EIO;
4321 +
4322 +       VERBOSE("file %s/%s, count=%d@%Ld, packet_size=%d\n",
4323                 DENTRY_PATH(dentry), count, offset, server->packet_size);
4324  
4325         smb_lock_server(server);
4326 diff -urN lfs-ref/fs/stat.c lfs/fs/stat.c
4327 --- lfs-ref/fs/stat.c   Mon Jan 17 16:44:43 2000
4328 +++ lfs/fs/stat.c       Wed Sep 12 02:42:15 2001
4329 @@ -48,6 +48,10 @@
4330         tmp.st_uid = inode->i_uid;
4331         tmp.st_gid = inode->i_gid;
4332         tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
4333 +#if BITS_PER_LONG == 32
4334 +       if (inode->i_size > 0x7fffffff)
4335 +               return -EOVERFLOW;
4336 +#endif 
4337         tmp.st_size = inode->i_size;
4338         tmp.st_atime = inode->i_atime;
4339         tmp.st_mtime = inode->i_mtime;
4340 @@ -70,6 +74,10 @@
4341         tmp.st_uid = inode->i_uid;
4342         tmp.st_gid = inode->i_gid;
4343         tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
4344 +#if BITS_PER_LONG == 32
4345 +       if (inode->i_size > 0x7fffffff)
4346 +               return -EOVERFLOW;
4347 +#endif 
4348         tmp.st_size = inode->i_size;
4349         tmp.st_atime = inode->i_atime;
4350         tmp.st_mtime = inode->i_mtime;
4351 @@ -280,3 +288,127 @@
4352         unlock_kernel();
4353         return error;
4354  }
4355 +
4356 +
4357 +/* ---------- LFS-64 ----------- */
4358 +#if !defined(__alpha__)
4359 +
4360 +static long cp_new_stat64(struct inode * inode, struct stat64 * statbuf)
4361 +{
4362 +       struct stat64 tmp;
4363 +       unsigned int blocks, indirect;
4364 +
4365 +       memset(&tmp, 0, sizeof(tmp));
4366 +       tmp.st_dev = kdev_t_to_nr(inode->i_dev);
4367 +       tmp.st_ino = inode->i_ino;
4368 +#ifdef STAT64_HAS_BROKEN_ST_INO
4369 +       tmp.__st_ino = inode->i_ino;
4370 +#endif
4371 +       tmp.st_mode = inode->i_mode;
4372 +       tmp.st_nlink = inode->i_nlink;
4373 +       tmp.st_uid = inode->i_uid;
4374 +       tmp.st_gid = inode->i_gid;
4375 +       tmp.st_rdev = kdev_t_to_nr(inode->i_rdev);
4376 +       tmp.st_atime = inode->i_atime;
4377 +       tmp.st_mtime = inode->i_mtime;
4378 +       tmp.st_ctime = inode->i_ctime;
4379 +       tmp.st_size = inode->i_size;
4380 +/*
4381 + * st_blocks and st_blksize are approximated with a simple algorithm if
4382 + * they aren't supported directly by the filesystem. The minix and msdos
4383 + * filesystems don't keep track of blocks, so they would either have to
4384 + * be counted explicitly (by delving into the file itself), or by using
4385 + * this simple algorithm to get a reasonable (although not 100% accurate)
4386 + * value.
4387 + */
4388 +
4389 +/*
4390 + * Use minix fs values for the number of direct and indirect blocks.  The
4391 + * count is now exact for the minix fs except that it counts zero blocks.
4392 + * Everything is in units of BLOCK_SIZE until the assignment to
4393 + * tmp.st_blksize.
4394 + */
4395 +#define D_B   7
4396 +#define I_B   (BLOCK_SIZE / sizeof(unsigned short))
4397 +
4398 +       if (!inode->i_blksize) {
4399 +               blocks = (tmp.st_size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS;
4400 +               if (blocks > D_B) {
4401 +                       indirect = (blocks - D_B + I_B - 1) / I_B;
4402 +                       blocks += indirect;
4403 +                       if (indirect > 1) {
4404 +                               indirect = (indirect - 1 + I_B - 1) / I_B;
4405 +                               blocks += indirect;
4406 +                               if (indirect > 1)
4407 +                                       blocks++;
4408 +                       }
4409 +               }
4410 +               tmp.st_blocks = (BLOCK_SIZE / 512) * blocks;
4411 +               tmp.st_blksize = BLOCK_SIZE;
4412 +       } else {
4413 +               tmp.st_blocks = inode->i_blocks;
4414 +               tmp.st_blksize = inode->i_blksize;
4415 +       }
4416 +       return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
4417 +}
4418 +
4419 +asmlinkage long sys_stat64(char * filename, struct stat64 * statbuf, long flags)
4420 +{
4421 +       struct dentry * dentry;
4422 +       int error;
4423 +
4424 +       lock_kernel();
4425 +       dentry = namei(filename);
4426 +
4427 +       error = PTR_ERR(dentry);
4428 +       if (!IS_ERR(dentry)) {
4429 +               error = do_revalidate(dentry);
4430 +               if (!error)
4431 +                       error = cp_new_stat64(dentry->d_inode, statbuf);
4432 +
4433 +               dput(dentry);
4434 +       }
4435 +       unlock_kernel();
4436 +       return error;
4437 +}
4438 +
4439 +asmlinkage long sys_lstat64(char * filename, struct stat64 * statbuf, long flags)
4440 +{
4441 +       struct dentry * dentry;
4442 +       int error;
4443 +
4444 +       lock_kernel();
4445 +       dentry = lnamei(filename);
4446 +
4447 +       error = PTR_ERR(dentry);
4448 +       if (!IS_ERR(dentry)) {
4449 +               error = do_revalidate(dentry);
4450 +               if (!error)
4451 +                       error = cp_new_stat64(dentry->d_inode, statbuf);
4452 +
4453 +               dput(dentry);
4454 +       }
4455 +       unlock_kernel();
4456 +       return error;
4457 +}
4458 +
4459 +asmlinkage long sys_fstat64(unsigned long fd, struct stat64 * statbuf, long flags)
4460 +{
4461 +       struct file * f;
4462 +       int err = -EBADF;
4463 +
4464 +       lock_kernel();
4465 +       f = fget(fd);
4466 +       if (f) {
4467 +               struct dentry * dentry = f->f_dentry;
4468 +
4469 +               err = do_revalidate(dentry);
4470 +               if (!err)
4471 +                       err = cp_new_stat64(dentry->d_inode, statbuf);
4472 +               fput(f);
4473 +       }
4474 +       unlock_kernel();
4475 +       return err;
4476 +}
4477 +
4478 +#endif /* LFS-64 */
4479 diff -urN lfs-ref/fs/sysv/dir.c lfs/fs/sysv/dir.c
4480 --- lfs-ref/fs/sysv/dir.c       Mon Jan 17 16:44:43 2000
4481 +++ lfs/fs/sysv/dir.c   Wed Sep 12 02:42:15 2001
4482 @@ -100,7 +100,7 @@
4483                                                inode->i_ino, (off_t) filp->f_pos, sde.inode);
4484  
4485                                 i = strnlen(sde.name, SYSV_NAMELEN);
4486 -                               if (filldir(dirent, sde.name, i, filp->f_pos, sde.inode) < 0) {
4487 +                               if (filldir(dirent, sde.name, i, filp->f_pos, sde.inode, DT_UNKNOWN) < 0) {
4488                                         brelse(bh);
4489                                         return 0;
4490                                 }
4491 diff -urN lfs-ref/fs/sysv/file.c lfs/fs/sysv/file.c
4492 --- lfs-ref/fs/sysv/file.c      Mon Jan 17 16:44:43 2000
4493 +++ lfs/fs/sysv/file.c  Wed Sep 12 02:42:15 2001
4494 @@ -207,7 +207,7 @@
4495  {
4496         struct inode * inode = filp->f_dentry->d_inode;
4497         struct super_block * sb = inode->i_sb;
4498 -       off_t pos;
4499 +       loff_t pos;
4500         ssize_t written, c;
4501         struct buffer_head * bh;
4502         char * p;
4503 @@ -232,6 +232,21 @@
4504         else
4505                 pos = *ppos;
4506         written = 0;
4507 +
4508 +       /* L-F-S spec 2.2.1.27: */
4509 +       if (!(filp->f_flags & O_LARGEFILE)) {
4510 +               if (pos >= 0x7fffffffULL) /* pos@2G forbidden */
4511 +                       return -EFBIG;
4512 +
4513 +               if (pos + count > 0x7fffffffULL)
4514 +                       /* Write only until end of allowed region */
4515 +                       count = 0x7fffffffULL - pos;
4516 +       }
4517 +       if (pos >= 0xffffffffULL)
4518 +               return -EFBIG; /* Only up to 4G-1! */
4519 +       if ((pos + count) > 0xffffffffULL)
4520 +               count = 0xffffffffULL - pos;
4521 +
4522         while (written<count) {
4523                 bh = sysv_getblk (inode, pos >> sb->sv_block_size_bits, 1);
4524                 if (!bh) {
4525 diff -urN lfs-ref/fs/ufs/balloc.c lfs/fs/ufs/balloc.c
4526 --- lfs-ref/fs/ufs/balloc.c     Mon Jan 17 16:44:43 2000
4527 +++ lfs/fs/ufs/balloc.c Wed Sep 12 02:42:15 2001
4528 @@ -660,9 +660,9 @@
4529         struct ufs_sb_private_info * uspi;
4530         struct ufs_super_block_first * usb1;
4531         struct ufs_cylinder_group * ucg;
4532 -       unsigned start, length, location, result;
4533 -       unsigned possition, fragsize, blockmap, mask;
4534 -       unsigned swab;
4535 +       unsigned int start, length, location, result;
4536 +       unsigned int possition, fragsize, blockmap, mask;
4537 +       unsigned int swab;
4538         
4539         UFSD(("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count))
4540  
4541 @@ -676,7 +676,7 @@
4542         else
4543                 start = ucpi->c_frotor >> 3;
4544                 
4545 -       length = howmany(uspi->s_fpg, 8) - start;
4546 +       length = ((uspi->s_fpg + 7) >> 3) - start;
4547         location = ubh_scanc(UCPI_UBH, ucpi->c_freeoff + start, length,
4548                 (uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other,
4549                 1 << (count - 1 + (uspi->s_fpb & 7))); 
4550 diff -urN lfs-ref/fs/ufs/dir.c lfs/fs/ufs/dir.c
4551 --- lfs-ref/fs/ufs/dir.c        Thu May  4 13:00:40 2000
4552 +++ lfs/fs/ufs/dir.c    Wed Sep 12 02:42:15 2001
4553 @@ -15,6 +15,7 @@
4554  
4555  #include <linux/fs.h>
4556  #include <linux/ufs_fs.h>
4557 +#include <linux/unistd.h>
4558  
4559  #include "swab.h"
4560  #include "util.h"
4561 @@ -124,11 +125,14 @@
4562                                  * not the directory has been modified
4563                                  * during the copy operation. */
4564                                 unsigned long version = inode->i_version;
4565 +                               unsigned char d_type = DT_UNKNOWN;
4566  
4567                                 UFSD(("filldir(%s,%u)\n", de->d_name, SWAB32(de->d_ino)))
4568                                 UFSD(("namlen %u\n", ufs_get_de_namlen(de)))
4569 +                               if ((flags & UFS_DE_MASK) == UFS_DE_44BSD)
4570 +                                       d_type = de->d_u.d_44.d_type;
4571                                 error = filldir(dirent, de->d_name, ufs_get_de_namlen(de),
4572 -                                               filp->f_pos, SWAB32(de->d_ino));
4573 +                                               filp->f_pos, SWAB32(de->d_ino), d_type);
4574                                 if (error)
4575                                         break;
4576                                 if (version != inode->i_version)
4577 @@ -170,7 +174,7 @@
4578                 error_msg = "inode out of bounds";
4579  
4580         if (error_msg != NULL)
4581 -               ufs_error (sb, function, "bad entry in directory #%lu, size %lu: %s - "
4582 +               ufs_error (sb, function, "bad entry in directory #%lu, size %Lu: %s - "
4583                             "offset=%lu, inode=%lu, reclen=%d, namlen=%d",
4584                             dir->i_ino, dir->i_size, error_msg, offset,
4585                             (unsigned long) SWAB32(de->d_ino),
4586 diff -urN lfs-ref/fs/ufs/file.c lfs/fs/ufs/file.c
4587 --- lfs-ref/fs/ufs/file.c       Sun Apr  2 21:07:49 2000
4588 +++ lfs/fs/ufs/file.c   Wed Sep 12 02:42:15 2001
4589 @@ -140,7 +140,7 @@
4590         loff_t *ppos )
4591  {
4592         struct inode * inode = filp->f_dentry->d_inode;
4593 -       __u32 pos;
4594 +       loff_t pos;
4595         long block;
4596         int offset;
4597         int written, c;
4598 @@ -177,11 +177,14 @@
4599                         return -EINVAL;
4600         }
4601  
4602 -       /* Check for overflow.. */
4603 -       if (pos > (__u32) (pos + count)) {
4604 -               count = ~pos; /* == 0xFFFFFFFF - pos */
4605 -               if (!count)
4606 +       /* L-F-S spec 2.2.1.27: */
4607 +       if (!(filp->f_flags & O_LARGEFILE)) {
4608 +               if (pos >= 0x7fffffffULL) /* pos@2G forbidden */
4609                         return -EFBIG;
4610 +
4611 +               if (pos + count > 0x7fffffffULL)
4612 +                       /* Write only until end of allowed region */
4613 +                       count = 0x7fffffffULL - pos;
4614         }
4615  
4616         /*
4617 diff -urN lfs-ref/fs/ufs/inode.c lfs/fs/ufs/inode.c
4618 --- lfs-ref/fs/ufs/inode.c      Tue Jun 13 03:48:15 2000
4619 +++ lfs/fs/ufs/inode.c  Wed Sep 12 02:42:15 2001
4620 @@ -54,7 +54,7 @@
4621  {
4622         unsigned swab = inode->i_sb->u.ufs_sb.s_swab;
4623         printk("ino %lu  mode 0%6.6o  nlink %d  uid %d  uid32 %u"
4624 -              "  gid %d  gid32 %u  size %lu blocks %lu\n",
4625 +              "  gid %d  gid32 %u  size %Lu blocks %lu\n",
4626                inode->i_ino, inode->i_mode, inode->i_nlink,
4627                inode->i_uid, inode->u.ufs_i.i_uid, inode->i_gid, 
4628                inode->u.ufs_i.i_gid, inode->i_size, inode->i_blocks);
4629 @@ -213,13 +213,14 @@
4630         if (!create)
4631                 return NULL;
4632         limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
4633 -       if (limit < RLIM_INFINITY) {
4634 +       if (limit != RLIM_INFINITY) {
4635                 limit >>= sb->s_blocksize_bits;
4636                 if (new_fragment >= limit) {
4637                         send_sig(SIGXFSZ, current, 0);
4638                         return NULL;
4639                 }
4640         }
4641 +
4642         lastblock = ufs_fragstoblks (lastfrag);
4643         lastblockoff = ufs_fragnum (lastfrag);
4644         /*
4645 @@ -321,7 +322,8 @@
4646                 brelse (result);
4647                 goto repeat;
4648         }
4649 -       if (!create || new_fragment >= (current->rlim[RLIMIT_FSIZE].rlim_cur >> sb->s_blocksize)) {
4650 +       if (!create || (current->rlim[RLIMIT_FSIZE].rlim_cur != RLIM_INFINITY &&
4651 +                       new_fragment >= (current->rlim[RLIMIT_FSIZE].rlim_cur >> sb->s_blocksize))) {
4652                 brelse (bh);
4653                 *err = -EFBIG;
4654                 return NULL;
4655 @@ -497,13 +499,10 @@
4656         }
4657         
4658         /*
4659 -        * Linux i_size can be 32 on some architectures. We will mark 
4660 -        * big files as read only and let user access first 32 bits.
4661 +        * Linux i_size used to be 32 bits on some architectures.
4662 +        * These days we allow access to the entire file as is..
4663          */
4664 -       inode->u.ufs_i.i_size = SWAB64(ufs_inode->ui_size);
4665 -       inode->i_size = (off_t) inode->u.ufs_i.i_size;
4666 -       if (sizeof(off_t) == 4 && (inode->u.ufs_i.i_size >> 32))
4667 -               inode->i_size = (__u32)-1;
4668 +       inode->i_size = SWAB64(ufs_inode->ui_size);
4669  
4670         inode->i_atime = SWAB32(ufs_inode->ui_atime.tv_sec);
4671         inode->i_ctime = SWAB32(ufs_inode->ui_ctime.tv_sec);
4672 @@ -516,7 +515,7 @@
4673         inode->u.ufs_i.i_gen = SWAB32(ufs_inode->ui_gen);
4674         inode->u.ufs_i.i_shadow = SWAB32(ufs_inode->ui_u3.ui_sun.ui_shadow);
4675         inode->u.ufs_i.i_oeftflag = SWAB32(ufs_inode->ui_u3.ui_sun.ui_oeftflag);
4676 -       inode->u.ufs_i.i_lastfrag = howmany (inode->i_size, uspi->s_fsize);
4677 +       inode->u.ufs_i.i_lastfrag = (inode->i_size + uspi->s_fsize -1) >> uspi->s_fshift;
4678         
4679         if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
4680                 inode->i_rdev = to_kdev_t(SWAB32(ufs_inode->ui_u2.ui_addr.ui_db[0]));
4681 diff -urN lfs-ref/fs/ufs/super.c lfs/fs/ufs/super.c
4682 --- lfs-ref/fs/ufs/super.c      Mon Jan 17 16:44:43 2000
4683 +++ lfs/fs/ufs/super.c  Wed Sep 12 02:42:15 2001
4684 @@ -328,7 +328,7 @@
4685          * on the device. 
4686          */
4687         size = uspi->s_cssize;
4688 -       blks = howmany(size, uspi->s_fsize);
4689 +       blks = (size + uspi->s_fsize-1) >> uspi->s_fshift;
4690         base = space = kmalloc(size, GFP_KERNEL);
4691         if (!base)
4692                 goto failed; 
4693 @@ -405,7 +405,7 @@
4694         uspi = sb->u.ufs_sb.s_uspi;
4695  
4696         size = uspi->s_cssize;
4697 -       blks = howmany(size, uspi->s_fsize);
4698 +       blks = (size + uspi->s_fsize-1) >> uspi->s_fshift;
4699         base = space = (char*) sb->u.ufs_sb.s_csp[0];
4700         for (i = 0; i < blks; i += uspi->s_fpb) {
4701                 size = uspi->s_bsize;
4702 diff -urN lfs-ref/fs/ufs/truncate.c lfs/fs/ufs/truncate.c
4703 --- lfs-ref/fs/ufs/truncate.c   Mon Jan 17 16:44:43 2000
4704 +++ lfs/fs/ufs/truncate.c       Wed Sep 12 02:42:15 2001
4705 @@ -59,8 +59,8 @@
4706   *             Linus
4707   */
4708  
4709 -#define DIRECT_BLOCK howmany (inode->i_size, uspi->s_bsize)
4710 -#define DIRECT_FRAGMENT howmany (inode->i_size, uspi->s_fsize)
4711 +#define DIRECT_BLOCK ((inode->i_size + uspi->s_bsize -1) >> uspi->s_bshift)
4712 +#define DIRECT_FRAGMENT ((inode->i_size + uspi->s_fsize -1) >> uspi->s_fshift)
4713  
4714  static int ufs_trunc_direct (struct inode * inode)
4715  {
4716 @@ -194,7 +194,7 @@
4717  }
4718  
4719  
4720 -static int ufs_trunc_indirect (struct inode * inode, unsigned offset, u32 * p)
4721 +static int ufs_trunc_indirect (struct inode * inode, u_long offset, u32 * p)
4722  {
4723         struct super_block * sb;
4724         struct ufs_sb_private_info * uspi;
4725 @@ -297,7 +297,7 @@
4726         struct super_block * sb;
4727         struct ufs_sb_private_info * uspi;
4728         struct ufs_buffer_head * dind_bh;
4729 -       unsigned i, tmp, dindirect_block;
4730 +       unsigned int i, tmp, dindirect_block;
4731         u32 * dind;
4732         int retry = 0;
4733         unsigned swab;
4734 @@ -308,8 +308,8 @@
4735         swab = sb->u.ufs_sb.s_swab;
4736         uspi = sb->u.ufs_sb.s_uspi;
4737  
4738 -       dindirect_block = (DIRECT_BLOCK > offset) 
4739 -               ? ((DIRECT_BLOCK - offset) / uspi->s_apb) : 0;
4740 +       dindirect_block = ((DIRECT_BLOCK > offset) ?
4741 +                          ((DIRECT_BLOCK - offset) >> uspi->s_apbshift) : 0);
4742         retry = 0;
4743         
4744         tmp = SWAB32(*p);
4745 @@ -379,7 +379,7 @@
4746         retry = 0;
4747         
4748         tindirect_block = (DIRECT_BLOCK > (UFS_NDADDR + uspi->s_apb + uspi->s_2apb))
4749 -               ? ((DIRECT_BLOCK - UFS_NDADDR - uspi->s_apb - uspi->s_2apb) / uspi->s_2apb) : 0;
4750 +               ? ((DIRECT_BLOCK - UFS_NDADDR - uspi->s_apb - uspi->s_2apb) >> uspi->s_2apbshift) : 0;
4751         p = inode->u.ufs_i.i_u1.i_data + UFS_TIND_BLOCK;
4752         if (!(tmp = SWAB32(*p)))
4753                 return 0;
4754 @@ -467,7 +467,8 @@
4755                 }
4756         }
4757         inode->i_mtime = inode->i_ctime = CURRENT_TIME;
4758 -       inode->u.ufs_i.i_lastfrag = howmany (inode->i_size, uspi->s_fsize);
4759 +       inode->u.ufs_i.i_lastfrag =
4760 +         (inode->i_size + uspi->s_fsize -1) >> uspi->s_fshift;
4761         mark_inode_dirty(inode);
4762         UFSD(("EXIT\n"))
4763  }
4764 diff -urN lfs-ref/fs/ufs/util.h lfs/fs/ufs/util.h
4765 --- lfs-ref/fs/ufs/util.h       Sat May 20 00:06:21 2000
4766 +++ lfs/fs/ufs/util.h   Wed Sep 12 02:42:15 2001
4767 @@ -14,7 +14,6 @@
4768   * some useful macros
4769   */
4770  #define in_range(b,first,len)  ((b)>=(first)&&(b)<(first)+(len))
4771 -#define howmany(x,y)           (((x)+(y)-1)/(y))
4772  #define min(x,y)               ((x)<(y)?(x):(y))
4773  #define max(x,y)               ((x)>(y)?(x):(y))
4774  
4775 diff -urN lfs-ref/fs/umsdos/dir.c lfs/fs/umsdos/dir.c
4776 --- lfs-ref/fs/umsdos/dir.c     Thu May  4 13:00:40 2000
4777 +++ lfs/fs/umsdos/dir.c Wed Sep 12 02:42:15 2001
4778 @@ -90,7 +90,7 @@
4779         if (d->count == 0) {
4780                 PRINTK ((KERN_DEBUG "dir_once :%.*s: offset %Ld\n", 
4781                         len, name, offset));
4782 -               ret = d->filldir (d->dirbuf, name, len, offset, ino);
4783 +               ret = d->filldir (d->dirbuf, name, len, offset, ino, DT_UNKNOWN);
4784                 d->stop = ret < 0;
4785                 d->count = 1;
4786         }
4787 @@ -136,7 +136,7 @@
4788  
4789                 Printk ((KERN_WARNING "umsdos_readdir_x: pseudo_root thing UMSDOS_SPECIAL_DIRFPOS\n"));
4790                 if (filldir (dirbuf, "DOS", 3, 
4791 -                               UMSDOS_SPECIAL_DIRFPOS, UMSDOS_ROOT_INO) == 0) {
4792 +                               UMSDOS_SPECIAL_DIRFPOS, UMSDOS_ROOT_INO, DT_DIR) == 0) {
4793                         filp->f_pos++;
4794                 }
4795                 goto out_end;
4796 @@ -255,7 +255,7 @@
4797                 if (inode != pseudo_root &&
4798                     (internal_read || !(entry.flags & UMSDOS_HIDDEN))) {
4799                         if (filldir (dirbuf, entry.name, entry.name_len,
4800 -                                cur_f_pos, inode->i_ino) < 0) {
4801 +                                cur_f_pos, inode->i_ino, DT_UNKNOWN) < 0) {
4802                                 new_filp.f_pos = cur_f_pos;
4803                         }
4804  Printk(("umsdos_readdir_x: got %s/%s, ino=%ld\n",
4805 diff -urN lfs-ref/fs/umsdos/rdir.c lfs/fs/umsdos/rdir.c
4806 --- lfs-ref/fs/umsdos/rdir.c    Thu May  4 13:00:40 2000
4807 +++ lfs/fs/umsdos/rdir.c        Wed Sep 12 02:42:15 2001
4808 @@ -33,7 +33,8 @@
4809                                 const char *name,
4810                                 int name_len,
4811                                 off_t offset,
4812 -                               ino_t ino)
4813 +                               ino_t ino,
4814 +                               unsigned int d_type)
4815  {
4816         int ret = 0;
4817         struct RDIR_FILLDIR *d = (struct RDIR_FILLDIR *) buf;
4818 @@ -48,11 +49,11 @@
4819                                 /* Make sure the .. entry points back to the pseudo_root */
4820                                 ino = pseudo_root->i_ino;
4821                         }
4822 -                       ret = d->filldir (d->dirbuf, name, name_len, offset, ino);
4823 +                       ret = d->filldir (d->dirbuf, name, name_len, offset, ino, DT_UNKNOWN);
4824                 }
4825         } else {
4826                 /* Any DOS directory */
4827 -               ret = d->filldir (d->dirbuf, name, name_len, offset, ino);
4828 +               ret = d->filldir (d->dirbuf, name, name_len, offset, ino, DT_UNKNOWN);
4829         }
4830         return ret;
4831  }
4832 diff -urN lfs-ref/include/asm-alpha/fcntl.h lfs/include/asm-alpha/fcntl.h
4833 --- lfs-ref/include/asm-alpha/fcntl.h   Mon Jan 17 16:44:43 2000
4834 +++ lfs/include/asm-alpha/fcntl.h       Wed Sep 12 02:42:15 2001
4835 @@ -20,6 +20,7 @@
4836  #define O_DIRECT       040000  /* direct disk access - should check with OSF/1 */
4837  #define O_DIRECTORY    0100000 /* must be a directory */
4838  #define O_NOFOLLOW     0200000 /* don't follow links */
4839 +#define O_LARGEFILE    0400000 /* will be set by the kernel on every open */
4840  
4841  #define F_DUPFD                0       /* dup */
4842  #define F_GETFD                1       /* get f_flags */
4843 @@ -61,5 +62,9 @@
4844         __kernel_off_t l_len;
4845         __kernel_pid_t l_pid;
4846  };
4847 +
4848 +#ifdef __KERNEL__
4849 +#define flock64        flock
4850 +#endif
4851  
4852  #endif
4853 diff -urN lfs-ref/include/asm-alpha/unistd.h lfs/include/asm-alpha/unistd.h
4854 --- lfs-ref/include/asm-alpha/unistd.h  Mon Dec 11 16:58:03 2000
4855 +++ lfs/include/asm-alpha/unistd.h      Wed Sep 12 02:42:15 2001
4856 @@ -314,6 +314,7 @@
4857  #define __NR_pivot_root                        374     /* implemented in 2.3 */
4858  #define __NR_mincore                   375     /* implemented in 2.3 */
4859  #define __NR_pciconfig_iobase          376
4860 +#define __NR_getdents64                        377
4861  
4862  #if defined(__GNUC__)
4863  
4864 diff -urN lfs-ref/include/asm-arm/fcntl.h lfs/include/asm-arm/fcntl.h
4865 --- lfs-ref/include/asm-arm/fcntl.h     Mon Jan 17 16:44:44 2000
4866 +++ lfs/include/asm-arm/fcntl.h Wed Sep 12 02:42:15 2001
4867 @@ -18,6 +18,8 @@
4868  #define FASYNC         020000  /* fcntl, for BSD compatibility */
4869  #define O_DIRECTORY    040000  /* must be a directory */
4870  #define O_NOFOLLOW     0100000 /* don't follow links */
4871 +#define O_DIRECT       0200000 /* direct disk access hint - currently ignored */
4872 +#define O_LARGEFILE    0400000
4873  
4874  #define F_DUPFD                0       /* dup */
4875  #define F_GETFD                1       /* get f_flags */
4876 @@ -33,6 +35,10 @@
4877  #define F_SETSIG       10      /*  for sockets. */
4878  #define F_GETSIG       11      /*  for sockets. */
4879  
4880 +#define F_GETLK64      12      /*  using 'struct flock64' */
4881 +#define F_SETLK64      13
4882 +#define F_SETLKW64     14
4883 +
4884  /* for F_[GET|SET]FL */
4885  #define FD_CLOEXEC     1       /* actually anything with low bit set goes */
4886  
4887 @@ -58,6 +64,14 @@
4888         off_t l_start;
4889         off_t l_len;
4890         pid_t l_pid;
4891 +};
4892 +
4893 +struct flock64 {
4894 +       short  l_type;
4895 +       short  l_whence;
4896 +       loff_t l_start;
4897 +       loff_t l_len;
4898 +       pid_t  l_pid;
4899  };
4900  
4901  #endif
4902 diff -urN lfs-ref/include/asm-arm/stat.h lfs/include/asm-arm/stat.h
4903 --- lfs-ref/include/asm-arm/stat.h      Mon Jan 17 16:44:44 2000
4904 +++ lfs/include/asm-arm/stat.h  Wed Sep 12 02:42:15 2001
4905 @@ -38,4 +38,5 @@
4906         unsigned long  __unused5;
4907  };
4908  
4909 +/* Someone please add a glibc/arm compatible stat64 struct here. */
4910  #endif
4911 diff -urN lfs-ref/include/asm-arm/unistd.h lfs/include/asm-arm/unistd.h
4912 --- lfs-ref/include/asm-arm/unistd.h    Mon Dec 11 16:58:04 2000
4913 +++ lfs/include/asm-arm/unistd.h        Wed Sep 12 02:42:15 2001
4914 @@ -198,6 +198,13 @@
4915                                         /* 188 reserved */
4916                                         /* 189 reserved */
4917  #define __NR_vfork                     (__NR_SYSCALL_BASE+190)
4918 +/* #define __NR_getrlimit                      (__NR_SYSCALL_BASE+191) */
4919 +#define __NR_mmap2                     (__NR_SYSCALL_BASE+192)
4920 +#define __NR_truncate64                        (__NR_SYSCALL_BASE+193)
4921 +#define __NR_ftruncate64               (__NR_SYSCALL_BASE+194)
4922 +#define __NR_stat64                    (__NR_SYSCALL_BASE+195)
4923 +#define __NR_lstat64                   (__NR_SYSCALL_BASE+196)
4924 +#define __NR_fstat64                   (__NR_SYSCALL_BASE+197)
4925  
4926  #define __sys2(x) #x
4927  #define __sys1(x) __sys2(x)
4928 diff -urN lfs-ref/include/asm-i386/fcntl.h lfs/include/asm-i386/fcntl.h
4929 --- lfs-ref/include/asm-i386/fcntl.h    Mon Jan 17 16:44:44 2000
4930 +++ lfs/include/asm-i386/fcntl.h        Wed Sep 12 02:42:15 2001
4931 @@ -35,6 +35,10 @@
4932  #define F_SETSIG       10      /*  for sockets. */
4933  #define F_GETSIG       11      /*  for sockets. */
4934  
4935 +#define F_GETLK64      12      /*  using 'struct flock64' */
4936 +#define F_SETLK64      13
4937 +#define F_SETLKW64     14
4938 +
4939  /* for F_[GET|SET]FL */
4940  #define FD_CLOEXEC     1       /* actually anything with low bit set goes */
4941  
4942 @@ -60,6 +64,14 @@
4943         off_t l_start;
4944         off_t l_len;
4945         pid_t l_pid;
4946 +};
4947 +
4948 +struct flock64 {
4949 +       short  l_type;
4950 +       short  l_whence;
4951 +       loff_t l_start;
4952 +       loff_t l_len;
4953 +       pid_t  l_pid;
4954  };
4955  
4956  #endif
4957 diff -urN lfs-ref/include/asm-i386/stat.h lfs/include/asm-i386/stat.h
4958 --- lfs-ref/include/asm-i386/stat.h     Mon Jan 17 16:44:44 2000
4959 +++ lfs/include/asm-i386/stat.h Wed Sep 12 02:42:15 2001
4960 @@ -38,4 +38,41 @@
4961         unsigned long  __unused5;
4962  };
4963  
4964 +/* This matches struct stat64 in glibc2.1, hence the absolutely
4965 + * insane amounts of padding around dev_t's.
4966 + */
4967 +struct stat64 {
4968 +       unsigned short  st_dev;
4969 +       unsigned char   __pad0[10];
4970 +
4971 +#define STAT64_HAS_BROKEN_ST_INO       1
4972 +       unsigned long   __st_ino;
4973 +
4974 +       unsigned int    st_mode;
4975 +       unsigned int    st_nlink;
4976 +
4977 +       unsigned long   st_uid;
4978 +       unsigned long   st_gid;
4979 +
4980 +       unsigned short  st_rdev;
4981 +       unsigned char   __pad3[10];
4982 +
4983 +       long long       st_size;
4984 +       unsigned long   st_blksize;
4985 +
4986 +       unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
4987 +       unsigned long   __pad4;         /* future possible st_blocks high bits */
4988 +
4989 +       unsigned long   st_atime;
4990 +       unsigned long   __pad5;
4991 +
4992 +       unsigned long   st_mtime;
4993 +       unsigned long   __pad6;
4994 +
4995 +       unsigned long   st_ctime;
4996 +       unsigned long   __pad7;         /* will be high 32 bits of ctime someday */
4997 +
4998 +       unsigned long long      st_ino;
4999 +};
5000 +
5001  #endif
5002 diff -urN lfs-ref/include/asm-i386/unistd.h lfs/include/asm-i386/unistd.h
5003 --- lfs-ref/include/asm-i386/unistd.h   Mon Jan 17 16:44:44 2000
5004 +++ lfs/include/asm-i386/unistd.h       Wed Sep 12 02:42:15 2001
5005 @@ -80,7 +80,7 @@
5006  #define __NR_sigpending                 73
5007  #define __NR_sethostname        74
5008  #define __NR_setrlimit          75
5009 -#define __NR_getrlimit          76
5010 +#define __NR_getrlimit          76     /* Back compatible 2Gig limited rlimit */
5011  #define __NR_getrusage          77
5012  #define __NR_gettimeofday       78
5013  #define __NR_settimeofday       79
5014 @@ -195,8 +195,42 @@
5015  #define __NR_getpmsg           188     /* some people actually want streams */
5016  #define __NR_putpmsg           189     /* some people actually want streams */
5017  #define __NR_vfork             190
5018 +/* #define __NR_ugetrlimit             191     SuS compliant getrlimit */
5019 +#define __NR_mmap2             192
5020 +#define __NR_truncate64                193
5021 +#define __NR_ftruncate64       194
5022 +#define __NR_stat64            195
5023 +#define __NR_lstat64           196
5024 +#define __NR_fstat64           197
5025 +#if 0 /* 2.3.x */
5026 +#define __NR_lchown32          198
5027 +#define __NR_getuid32          199
5028 +#define __NR_getgid32          200
5029 +#define __NR_geteuid32         201
5030 +#define __NR_getegid32         202
5031 +#define __NR_setreuid32                203
5032 +#define __NR_setregid32                204
5033 +#define __NR_getgroups32       205
5034 +#define __NR_setgroups32       206
5035 +#define __NR_fchown32          207
5036 +#define __NR_setresuid32       208
5037 +#define __NR_getresuid32       209
5038 +#define __NR_setresgid32       210
5039 +#define __NR_getresgid32       211
5040 +#define __NR_chown32           212
5041 +#define __NR_setuid32          213
5042 +#define __NR_setgid32          214
5043 +#define __NR_setfsuid32                215
5044 +#define __NR_setfsgid32                216
5045 +#define __NR_pivot_root                217
5046 +#define __NR_mincore           218
5047 +#define __NR_madvise           219
5048 +#define __NR_madvise1          219     /* delete when C lib stub is removed */
5049 +#endif
5050 +#define __NR_getdents64                220
5051 +#define __NR_fcntl64           221
5052  
5053 -/* user-visible error numbers are in the range -1 - -122: see <asm-i386/errno.h> */
5054 +/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
5055  
5056  #define __syscall_return(type, res) \
5057  do { \
5058 @@ -269,6 +303,19 @@
5059         : "=a" (__res) \
5060         : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
5061           "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
5062 +__syscall_return(type,__res); \
5063 +}
5064 +
5065 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
5066 +         type5,arg5,type6,arg6) \
5067 +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
5068 +{ \
5069 +long __res; \
5070 +__asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; int $0x80 ; pop %%ebp" \
5071 +       : "=a" (__res) \
5072 +       : "i" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
5073 +         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
5074 +         "0" ((long)(arg6))); \
5075  __syscall_return(type,__res); \
5076  }
5077  
5078 diff -urN lfs-ref/include/asm-m68k/fcntl.h lfs/include/asm-m68k/fcntl.h
5079 --- lfs-ref/include/asm-m68k/fcntl.h    Mon Jan 17 16:44:44 2000
5080 +++ lfs/include/asm-m68k/fcntl.h        Wed Sep 12 02:42:15 2001
5081 @@ -33,6 +33,10 @@
5082  #define F_SETSIG       10      /*  for sockets. */
5083  #define F_GETSIG       11      /*  for sockets. */
5084  
5085 +#define F_GETLK64      12      /*  using 'struct flock64' */
5086 +#define F_SETLK64      13
5087 +#define F_SETLKW64     14
5088 +
5089  /* for F_[GET|SET]FL */
5090  #define FD_CLOEXEC     1       /* actually anything with low bit set goes */
5091  
5092 @@ -58,6 +62,14 @@
5093         off_t l_start;
5094         off_t l_len;
5095         pid_t l_pid;
5096 +};
5097 +
5098 +struct flock64 {
5099 +       short  l_type;
5100 +       short  l_whence;
5101 +       loff_t l_start;
5102 +       loff_t l_len;
5103 +       pid_t  l_pid;
5104  };
5105  
5106  #endif /* _M68K_FCNTL_H */
5107 diff -urN lfs-ref/include/asm-m68k/stat.h lfs/include/asm-m68k/stat.h
5108 --- lfs-ref/include/asm-m68k/stat.h     Mon Jan 17 16:44:45 2000
5109 +++ lfs/include/asm-m68k/stat.h Wed Sep 12 02:42:15 2001
5110 @@ -38,4 +38,8 @@
5111         unsigned long  __unused5;
5112  };
5113  
5114 +/* stat64 struct goes here -- someone please make
5115 + * it mesh with whatever glibc does in userland on
5116 + * m68k's.
5117 + */
5118  #endif /* _M68K_STAT_H */
5119 diff -urN lfs-ref/include/asm-m68k/unistd.h lfs/include/asm-m68k/unistd.h
5120 --- lfs-ref/include/asm-m68k/unistd.h   Mon Jan 17 16:44:45 2000
5121 +++ lfs/include/asm-m68k/unistd.h       Wed Sep 12 02:42:15 2001
5122 @@ -80,7 +80,7 @@
5123  #define __NR_sigpending                 73
5124  #define __NR_sethostname        74
5125  #define __NR_setrlimit          75
5126 -#define __NR_getrlimit          76
5127 +#define __NR_getrlimit          76
5128  #define __NR_getrusage          77
5129  #define __NR_gettimeofday       78
5130  #define __NR_settimeofday       79
5131 @@ -194,6 +194,13 @@
5132  #define __NR_getpmsg           188     /* some people actually want streams */
5133  #define __NR_putpmsg           189     /* some people actually want streams */
5134  #define __NR_vfork             190
5135 +/* #define __NR_getrlimit              191 */
5136 +#define __NR_mmap2             192
5137 +#define __NR_truncate64                193
5138 +#define __NR_ftruncate64       194
5139 +#define __NR_stat64            195
5140 +#define __NR_lstat64           196
5141 +#define __NR_fstat64           197
5142  
5143  /* user-visible error numbers are in the range -1 - -122: see
5144     <asm-m68k/errno.h> */
5145 diff -urN lfs-ref/include/asm-mips/fcntl.h lfs/include/asm-mips/fcntl.h
5146 --- lfs-ref/include/asm-mips/fcntl.h    Mon Jan 17 16:44:45 2000
5147 +++ lfs/include/asm-mips/fcntl.h        Wed Sep 12 02:42:15 2001
5148 @@ -44,6 +44,10 @@
5149  #define F_SETSIG       10      /*  for sockets. */
5150  #define F_GETSIG       11      /*  for sockets. */
5151  
5152 +#define F_GETLK64      33      /*  using 'struct flock64' */
5153 +#define F_SETLK64      34
5154 +#define F_SETLKW64     35
5155 +
5156  /* for F_[GET|SET]FL */
5157  #define FD_CLOEXEC     1       /* actually anything with low bit set goes */
5158  
5159 @@ -72,5 +76,13 @@
5160         __kernel_pid_t l_pid;
5161         long  pad[4];                   /* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
5162  } flock_t;
5163 +
5164 +typedef struct flock64 {
5165 +       short  l_type;
5166 +       short  l_whence;
5167 +       loff_t l_start;
5168 +       loff_t l_len;
5169 +       pid_t  l_pid;
5170 +} flock64_t;
5171  
5172  #endif /* __ASM_MIPS_FCNTL_H */
5173 diff -urN lfs-ref/include/asm-ppc/fcntl.h lfs/include/asm-ppc/fcntl.h
5174 --- lfs-ref/include/asm-ppc/fcntl.h     Mon Jan 17 16:44:45 2000
5175 +++ lfs/include/asm-ppc/fcntl.h Wed Sep 12 02:42:15 2001
5176 @@ -18,6 +18,8 @@
5177  #define FASYNC         020000  /* fcntl, for BSD compatibility */
5178  #define O_DIRECTORY    040000  /* must be a directory */
5179  #define O_NOFOLLOW     0100000 /* don't follow links */
5180 +#define O_LARGEFILE     0200000
5181 +#define O_DIRECT       0400000 /* direct disk access hint - currently ignored */
5182  
5183  #define F_DUPFD                0       /* dup */
5184  #define F_GETFD                1       /* get f_flags */
5185 @@ -33,6 +35,10 @@
5186  #define F_SETSIG       10      /*  for sockets. */
5187  #define F_GETSIG       11      /*  for sockets. */
5188  
5189 +#define F_GETLK64      12      /*  using 'struct flock64' */
5190 +#define F_SETLK64      13
5191 +#define F_SETLKW64     14
5192 +
5193  /* for F_[GET|SET]FL */
5194  #define FD_CLOEXEC     1       /* actually anything with low bit set goes */
5195  
5196 @@ -64,6 +70,14 @@
5197         off_t l_start;
5198         off_t l_len;
5199         pid_t l_pid;
5200 +};
5201 +
5202 +struct flock64 {
5203 +       short  l_type;
5204 +       short  l_whence;
5205 +       loff_t l_start;
5206 +       loff_t l_len;
5207 +       pid_t  l_pid;
5208  };
5209  
5210  #endif
5211 diff -urN lfs-ref/include/asm-ppc/stat.h lfs/include/asm-ppc/stat.h
5212 --- lfs-ref/include/asm-ppc/stat.h      Mon Jan 17 16:44:45 2000
5213 +++ lfs/include/asm-ppc/stat.h  Wed Sep 12 02:42:15 2001
5214 @@ -37,4 +37,29 @@
5215         unsigned long   __unused5;
5216  };
5217  
5218 +/* This matches struct stat64 in glibc2.1.
5219 + */
5220 +struct stat64 {
5221 +       unsigned long long st_dev;      /* Device.  */
5222 +       unsigned long long st_ino;      /* File serial number.  */
5223 +       unsigned int st_mode;           /* File mode.  */
5224 +       unsigned int st_nlink;          /* Link count.  */
5225 +       unsigned int st_uid;            /* User ID of the file's owner.  */
5226 +       unsigned int st_gid;            /* Group ID of the file's group. */
5227 +       unsigned long long st_rdev;     /* Device number, if device.  */
5228 +       unsigned short int __pad2;
5229 +       long long st_size;              /* Size of file, in bytes.  */
5230 +       long st_blksize;                /* Optimal block size for I/O.  */
5231 +
5232 +       long long st_blocks;            /* Number 512-byte blocks allocated. */
5233 +       long st_atime;                  /* Time of last access.  */
5234 +       unsigned long int __unused1;
5235 +       long st_mtime;                  /* Time of last modification.  */
5236 +       unsigned long int __unused2;
5237 +       long st_ctime;                  /* Time of last status change.  */
5238 +       unsigned long int __unused3;
5239 +       unsigned long int __unused4;
5240 +       unsigned long int __unused5;
5241 +};
5242 +
5243  #endif
5244 diff -urN lfs-ref/include/asm-ppc/unistd.h lfs/include/asm-ppc/unistd.h
5245 --- lfs-ref/include/asm-ppc/unistd.h    Mon Dec 11 16:58:05 2000
5246 +++ lfs/include/asm-ppc/unistd.h        Wed Sep 12 02:42:15 2001
5247 @@ -194,11 +194,18 @@
5248  #define __NR_getpmsg           187     /* some people actually want streams */
5249  #define __NR_putpmsg           188     /* some people actually want streams */
5250  #define __NR_vfork             189
5251 -
5252 +#define __NR_mmap2             192
5253 +#define __NR_truncate64                193
5254 +#define __NR_ftruncate64       194
5255 +#define __NR_stat64            195
5256 +#define __NR_lstat64           196
5257 +#define __NR_fstat64           197
5258  #define __NR_pciconfig_read     198
5259  #define __NR_pciconfig_write    199
5260  #define __NR_pciconfig_iobase   200
5261  #define __NR_multiplexer        201
5262 +#define __NR_getdents64                202
5263 +#define __NR_fcntl64           203
5264  
5265  #define __NR(n)        #n
5266  
5267 diff -urN lfs-ref/include/asm-sparc/fcntl.h lfs/include/asm-sparc/fcntl.h
5268 --- lfs-ref/include/asm-sparc/fcntl.h   Mon Jan 17 16:44:46 2000
5269 +++ lfs/include/asm-sparc/fcntl.h       Wed Sep 12 02:42:15 2001
5270 @@ -19,6 +19,7 @@
5271  #define O_NOCTTY       0x8000  /* not fcntl */
5272  #define O_DIRECTORY    0x10000 /* must be a directory */
5273  #define O_NOFOLLOW     0x20000 /* don't follow links */
5274 +#define O_LARGEFILE    0x40000 /* LFS */
5275  
5276  #define F_DUPFD                0       /* dup */
5277  #define F_GETFD                1       /* get f_flags */
5278 @@ -32,6 +33,9 @@
5279  #define F_SETLKW       9
5280  #define F_SETSIG       10      /*  for sockets. */
5281  #define F_GETSIG       11      /*  for sockets. */
5282 +#define F_GETLK64      12
5283 +#define F_SETLK64      13
5284 +#define F_SETLKW64     14
5285  
5286  /* for F_[GET|SET]FL */
5287  #define FD_CLOEXEC     1       /* actually anything with low bit set goes */
5288 @@ -57,6 +61,15 @@
5289         short l_whence;
5290         off_t l_start;
5291         off_t l_len;
5292 +       pid_t l_pid;
5293 +       short __unused;
5294 +};
5295 +
5296 +struct flock64 {
5297 +       short l_type;
5298 +       short l_whence;
5299 +       loff_t l_start;
5300 +       loff_t l_len;
5301         pid_t l_pid;
5302         short __unused;
5303  };
5304 diff -urN lfs-ref/include/asm-sparc/stat.h lfs/include/asm-sparc/stat.h
5305 --- lfs-ref/include/asm-sparc/stat.h    Mon Jan 17 16:44:46 2000
5306 +++ lfs/include/asm-sparc/stat.h        Wed Sep 12 02:42:15 2001
5307 @@ -1,4 +1,4 @@
5308 -/* $Id$ */
5309 +/* $Id$ */
5310  #ifndef _SPARC_STAT_H
5311  #define _SPARC_STAT_H
5312  
5313 @@ -36,6 +36,42 @@
5314         off_t   st_blksize;
5315         off_t   st_blocks;
5316         unsigned long  __unused4[2];
5317 +};
5318 +
5319 +struct stat64 {
5320 +       unsigned char   __pad0[6];
5321 +       unsigned short  st_dev;
5322 +
5323 +       unsigned long long      st_ino;
5324 +
5325 +       unsigned int    st_mode;
5326 +       unsigned int    st_nlink;
5327 +
5328 +       unsigned int    st_uid;
5329 +       unsigned int    st_gid;
5330 +
5331 +       unsigned char   __pad2[6];
5332 +       unsigned short  st_rdev;
5333 +
5334 +       unsigned char   __pad3[8];
5335 +
5336 +       long long       st_size;
5337 +       unsigned int    st_blksize;
5338 +
5339 +       unsigned char   __pad4[8];
5340 +       unsigned int    st_blocks;
5341 +
5342 +       unsigned int    st_atime;
5343 +       unsigned int    __unused1;
5344 +
5345 +       unsigned int    st_mtime;
5346 +       unsigned int    __unused2;
5347 +
5348 +       unsigned int    st_ctime;
5349 +       unsigned int    __unused3;
5350 +
5351 +       unsigned int    __unused4;
5352 +       unsigned int    __unused5;
5353  };
5354  
5355  #endif
5356 diff -urN lfs-ref/include/asm-sparc/unistd.h lfs/include/asm-sparc/unistd.h
5357 --- lfs-ref/include/asm-sparc/unistd.h  Fri Apr 20 22:31:20 2001
5358 +++ lfs/include/asm-sparc/unistd.h      Wed Sep 12 02:42:15 2001
5359 @@ -71,14 +71,14 @@
5360  /* #define __NR_mctl             53    SunOS specific                              */
5361  #define __NR_ioctl               54 /* Common                                      */
5362  #define __NR_reboot              55 /* Common                                      */
5363 -/* #define __NR_ni_syscall       56    ENOSYS under SunOS                          */
5364 +#define __NR_mmap2              56 /* Linux sparc32 Specific                      */
5365  #define __NR_symlink             57 /* Common                                      */
5366  #define __NR_readlink            58 /* Common                                      */
5367  #define __NR_execve              59 /* Common                                      */
5368  #define __NR_umask               60 /* Common                                      */
5369  #define __NR_chroot              61 /* Common                                      */
5370  #define __NR_fstat               62 /* Common                                      */
5371 -/* #define __NR_ni_syscall       63    ENOSYS under SunOS                          */
5372 +#define __NR_fstat64            63 /* Linux sparc32 Specific                      */
5373  #define __NR_getpagesize         64 /* Common                                      */
5374  #define __NR_msync               65 /* Common in newer 1.3.x revs...               */
5375  #define __NR_vfork               66 /* Common                                      */
5376 @@ -92,14 +92,14 @@
5377  #define __NR_mprotect            74 /* Common                                      */
5378  /* #define __NR_madvise          75    SunOS Specific                              */
5379  #define __NR_vhangup             76 /* Common                                      */
5380 -/* #define __NR_ni_syscall       77    ENOSYS under SunOS                          */
5381 +#define __NR_truncate64                 77 /* Linux sparc32 Specific                      */
5382  /* #define __NR_mincore          78    SunOS Specific                              */
5383  #define __NR_getgroups           79 /* Common                                      */
5384  #define __NR_setgroups           80 /* Common                                      */
5385  #define __NR_getpgrp             81 /* Common                                      */
5386  /* #define __NR_setpgrp          82    setpgid, same difference...                 */
5387  #define __NR_setitimer           83 /* Common                                      */
5388 -/* #define __NR_ni_syscall       84    ENOSYS under SunOS                          */
5389 +#define __NR_ftruncate64        84 /* Linux sparc32 Specific                      */
5390  #define __NR_swapon              85 /* Common                                      */
5391  #define __NR_getitimer           86 /* Common                                      */
5392  /* #define __NR_gethostname      87    SunOS Specific                              */
5393 @@ -147,14 +147,14 @@
5394  #define __NR_truncate           129 /* Common                                      */
5395  #define __NR_ftruncate          130 /* Common                                      */
5396  #define __NR_flock              131 /* Common                                      */
5397 -/* #define __NR_ni_syscall      132    ENOSYS under SunOS                          */
5398 +#define __NR_lstat64           132 /* Linux sparc32 Specific                      */
5399  #define __NR_sendto             133 /* Common                                      */
5400  #define __NR_shutdown           134 /* Common                                      */
5401  #define __NR_socketpair         135 /* Common                                      */
5402  #define __NR_mkdir              136 /* Common                                      */
5403  #define __NR_rmdir              137 /* Common                                      */
5404  #define __NR_utimes             138 /* SunOS Specific                              */
5405 -/* #define __NR_ni_syscall      139    ENOSYS under SunOS                          */
5406 +#define __NR_stat64            139 /* Linux sparc32 Specific                      */
5407  /* #define __NR_adjtime         140    SunOS Specific                              */
5408  #define __NR_getpeername        141 /* Common                                      */
5409  /* #define __NR_gethostid       142    SunOS Specific                              */
5410 @@ -169,8 +169,8 @@
5411  /* #define __NR_getmsg          151    SunOS Specific                              */
5412  /* #define __NR_putmsg          152    SunOS Specific                              */
5413  #define __NR_poll               153 /* Common                                      */
5414 -/* #define __NR_getdents64      154    Linux Sparc32 Specific                      */
5415 -/* #define __NR_fcntl64         155    Linux Sparc32 Specific                      */
5416 +#define __NR_getdents64         154 /* Linux Sparc32 Specific                     */
5417 +#define __NR_fcntl64            155 /* Linux Sparc32 Specific                      */
5418  /* #define __NR_getdirentries   156    SunOS Specific                              */
5419  #define __NR_statfs             157 /* Common                                      */
5420  #define __NR_fstatfs            158 /* Common                                      */
5421 diff -urN lfs-ref/include/asm-sparc64/fcntl.h lfs/include/asm-sparc64/fcntl.h
5422 --- lfs-ref/include/asm-sparc64/fcntl.h Mon Jan 17 16:44:46 2000
5423 +++ lfs/include/asm-sparc64/fcntl.h     Wed Sep 12 02:42:15 2001
5424 @@ -19,6 +19,7 @@
5425  #define O_NOCTTY       0x8000  /* not fcntl */
5426  #define O_DIRECTORY    0x10000 /* must be a directory */
5427  #define O_NOFOLLOW     0x20000 /* don't follow links */
5428 +#define O_LARGEFILE    0x40000
5429  
5430  #define F_DUPFD                0       /* dup */
5431  #define F_GETFD                1       /* get f_flags */
5432 @@ -32,6 +33,11 @@
5433  #define F_SETLKW       9
5434  #define F_SETSIG       10      /*  for sockets. */
5435  #define F_GETSIG       11      /*  for sockets. */
5436 +#ifdef __KERNEL__
5437 +#define F_GETLK64      12
5438 +#define F_SETLK64      13
5439 +#define F_SETLKW64     14
5440 +#endif
5441  
5442  /* for F_[GET|SET]FL */
5443  #define FD_CLOEXEC     1       /* actually anything with low bit set goes */
5444 @@ -58,7 +64,6 @@
5445         off_t l_start;
5446         off_t l_len;
5447         pid_t l_pid;
5448 -       short __unused;
5449  };
5450  
5451  #ifdef __KERNEL__
5452 @@ -70,6 +75,17 @@
5453         __kernel_pid_t32 l_pid;
5454         short __unused;
5455  };
5456 +
5457 +struct flock32_64 {
5458 +       short l_type;
5459 +       short l_whence;
5460 +       __kernel_loff_t32 l_start;
5461 +       __kernel_loff_t32 l_len;
5462 +       __kernel_pid_t32 l_pid;
5463 +       short __unused;
5464 +};
5465 +
5466 +#define flock64 flock
5467  #endif
5468  
5469  #endif /* !(_SPARC64_FCNTL_H) */
5470 diff -urN lfs-ref/include/asm-sparc64/stat.h lfs/include/asm-sparc64/stat.h
5471 --- lfs-ref/include/asm-sparc64/stat.h  Fri Dec 22 17:22:30 2000
5472 +++ lfs/include/asm-sparc64/stat.h      Wed Sep 12 02:42:15 2001
5473 @@ -1,4 +1,4 @@
5474 -/* $Id$ */
5475 +/* $Id$ */
5476  #ifndef _SPARC64_STAT_H
5477  #define _SPARC64_STAT_H
5478  
5479 @@ -41,5 +41,46 @@
5480         off_t   st_blocks;
5481         unsigned long  __unused4[2];
5482  };
5483 +
5484 +#ifdef __KERNEL__
5485 +/* This is sparc32 stat64 structure. */
5486 +
5487 +struct stat64 {
5488 +       unsigned char   __pad0[6];
5489 +       unsigned short  st_dev;
5490 +
5491 +       unsigned long long      st_ino;
5492 +
5493 +       unsigned int    st_mode;
5494 +       unsigned int    st_nlink;
5495 +
5496 +       unsigned int    st_uid;
5497 +       unsigned int    st_gid;
5498 +
5499 +       unsigned char   __pad2[6];
5500 +       unsigned short  st_rdev;
5501 +
5502 +       unsigned char   __pad3[8];
5503 +
5504 +       long long       st_size;
5505 +       unsigned int    st_blksize;
5506 +
5507 +       unsigned char   __pad4[8];
5508 +       unsigned int    st_blocks;
5509 +
5510 +       unsigned int    st_atime;
5511 +       unsigned int    __unused1;
5512 +
5513 +       unsigned int    st_mtime;
5514 +       unsigned int    __unused2;
5515 +
5516 +       unsigned int    st_ctime;
5517 +       unsigned int    __unused3;
5518 +
5519 +       unsigned int    __unused4;
5520 +       unsigned int    __unused5;
5521 +};
5522 +
5523 +#endif
5524  
5525  #endif
5526 diff -urN lfs-ref/include/asm-sparc64/unistd.h lfs/include/asm-sparc64/unistd.h
5527 --- lfs-ref/include/asm-sparc64/unistd.h        Fri Apr 20 22:31:20 2001
5528 +++ lfs/include/asm-sparc64/unistd.h    Wed Sep 12 02:42:15 2001
5529 @@ -71,14 +71,14 @@
5530  /* #define __NR_mctl             53    SunOS specific                              */
5531  #define __NR_ioctl               54 /* Common                                      */
5532  #define __NR_reboot              55 /* Common                                      */
5533 -/* #define __NR_ni_syscall       56    ENOSYS under SunOS                          */
5534 +/* #define __NR_mmap2           56    Linux sparc32 Specific                      */
5535  #define __NR_symlink             57 /* Common                                      */
5536  #define __NR_readlink            58 /* Common                                      */
5537  #define __NR_execve              59 /* Common                                      */
5538  #define __NR_umask               60 /* Common                                      */
5539  #define __NR_chroot              61 /* Common                                      */
5540  #define __NR_fstat               62 /* Common                                      */
5541 -/* #define __NR_ni_syscall       63    ENOSYS under SunOS                          */
5542 +/* #define __NR_fstat64          63    Linux sparc32 Specific                      */
5543  #define __NR_getpagesize         64 /* Common                                      */
5544  #define __NR_msync               65 /* Common in newer 1.3.x revs...               */
5545  #define __NR_vfork               66 /* Common                                      */
5546 @@ -92,14 +92,14 @@
5547  #define __NR_mprotect            74 /* Common                                      */
5548  /* #define __NR_madvise          75    SunOS Specific                              */
5549  #define __NR_vhangup             76 /* Common                                      */
5550 -/* #define __NR_ni_syscall       77    ENOSYS under SunOS                          */
5551 +/* #define __NR_truncate64       77    Linux sparc32 Specific                     */
5552  /* #define __NR_mincore          78    SunOS Specific                              */
5553  #define __NR_getgroups           79 /* Common                                      */
5554  #define __NR_setgroups           80 /* Common                                      */
5555  #define __NR_getpgrp             81 /* Common                                      */
5556  /* #define __NR_setpgrp          82    setpgid, same difference...                 */
5557  #define __NR_setitimer           83 /* Common                                      */
5558 -/* #define __NR_ni_syscall       84    ENOSYS under SunOS                          */
5559 +/* #define __NR_ftruncate64      84    Linux sparc32 Specific                     */
5560  #define __NR_swapon              85 /* Common                                      */
5561  #define __NR_getitimer           86 /* Common                                      */
5562  /* #define __NR_gethostname      87    SunOS Specific                              */
5563 @@ -147,19 +147,19 @@
5564  #define __NR_truncate           129 /* Common                                      */
5565  #define __NR_ftruncate          130 /* Common                                      */
5566  #define __NR_flock              131 /* Common                                      */
5567 -/* #define __NR_ni_syscall      132    ENOSYS under SunOS                          */
5568 +/* #define __NR_lstat64                132    Linux sparc32 Specific                      */
5569  #define __NR_sendto             133 /* Common                                      */
5570  #define __NR_shutdown           134 /* Common                                      */
5571  #define __NR_socketpair         135 /* Common                                      */
5572  #define __NR_mkdir              136 /* Common                                      */
5573  #define __NR_rmdir              137 /* Common                                      */
5574  #define __NR_utimes             138 /* SunOS Specific                              */
5575 -/* #define __NR_ni_syscall      139    ENOSYS under SunOS                          */
5576 +/* #define __NR_stat64         139    Linux sparc32 Specific                      */
5577  /* #define __NR_adjtime         140    SunOS Specific                              */
5578  #define __NR_getpeername        141 /* Common                                      */
5579  /* #define __NR_gethostid       142    SunOS Specific                              */
5580  /* #define __NR_ni_syscall      143    ENOSYS under SunOS                          */
5581 -#define __NR_getrlimit          144 /* Common                                      */
5582 +#define __NR_getrlimit         144 /* Common                                      */
5583  #define __NR_setrlimit          145 /* Common                                      */
5584  /* #define __NR_killpg          146    SunOS Specific                              */
5585  #define __NR_prctl             147 /* ENOSYS under SunOS                          */
5586 diff -urN lfs-ref/include/linux/dirent.h lfs/include/linux/dirent.h
5587 --- lfs-ref/include/linux/dirent.h      Tue May 25 00:49:30 1999
5588 +++ lfs/include/linux/dirent.h  Wed Sep 12 02:42:15 2001
5589 @@ -8,4 +8,12 @@
5590         char            d_name[256]; /* We must not include limits.h! */
5591  };
5592  
5593 +struct dirent64 {
5594 +       __u64           d_ino;
5595 +       __s64           d_off;
5596 +       unsigned short  d_reclen;
5597 +       unsigned char   d_type;
5598 +       char            d_name[256];
5599 +};
5600 +
5601  #endif
5602 diff -urN lfs-ref/include/linux/ext2_fs_i.h lfs/include/linux/ext2_fs_i.h
5603 --- lfs-ref/include/linux/ext2_fs_i.h   Mon Dec 11 16:58:05 2000
5604 +++ lfs/include/linux/ext2_fs_i.h       Wed Sep 12 02:42:15 2001
5605 @@ -35,7 +35,6 @@
5606         __u32   i_next_alloc_goal;
5607         __u32   i_prealloc_block;
5608         __u32   i_prealloc_count;
5609 -       __u32   i_high_size;
5610         int     i_new_inode:1;  /* Is a freshly allocated inode */
5611  };
5612  
5613 diff -urN lfs-ref/include/linux/fs.h lfs/include/linux/fs.h
5614 --- lfs-ref/include/linux/fs.h  Wed Sep 12 02:39:58 2001
5615 +++ lfs/include/linux/fs.h      Wed Sep 12 02:42:15 2001
5616 @@ -266,6 +266,25 @@
5617  #define buffer_page(bh)                (mem_map + MAP_NR((bh)->b_data))
5618  #define touch_buffer(bh)       set_bit(PG_referenced, &buffer_page(bh)->flags)
5619  
5620 +/* log of base-2 for filesystem uses, in case their super-blocks
5621 +   don't have the shift counts readily calculated.. -- presuming
5622 +   the divisors in question are power-of-two values! */
5623 +static int fslog2(unsigned long val) __attribute__ ((const));
5624 +static __inline__ int fslog2(unsigned long val)
5625 +{
5626 +       int i;
5627 +       for (i = 0; val != 0; ++i, val >>= 1) {
5628 +         if (val & 1) return i;
5629 +       }
5630 +       return 0;
5631 +}
5632 +
5633 +static int off_t_presentable(loff_t) __attribute((const));
5634 +static __inline__ int off_t_presentable(loff_t loff)
5635 +{
5636 +       return loff >= 0 && loff <= (~0UL >> 1);
5637 +}
5638 +
5639  #include <linux/pipe_fs_i.h>
5640  #include <linux/minix_fs_i.h>
5641  #include <linux/ext2_fs_i.h>
5642 @@ -317,7 +336,7 @@
5643         umode_t         ia_mode;
5644         uid_t           ia_uid;
5645         gid_t           ia_gid;
5646 -       off_t           ia_size;
5647 +       loff_t          ia_size;
5648         time_t          ia_atime;
5649         time_t          ia_mtime;
5650         time_t          ia_ctime;
5651 @@ -352,7 +371,7 @@
5652         uid_t                   i_uid;
5653         gid_t                   i_gid;
5654         kdev_t                  i_rdev;
5655 -       off_t                   i_size;
5656 +       loff_t                  i_size;
5657         time_t                  i_atime;
5658         time_t                  i_mtime;
5659         time_t                  i_ctime;
5660 @@ -431,7 +450,7 @@
5661         mode_t                  f_mode;
5662         loff_t                  f_pos;
5663         unsigned int            f_count, f_flags;
5664 -       unsigned long           f_reada, f_ramax, f_raend, f_ralen, f_rawin;
5665 +       loff_t                  f_reada, f_ramax, f_raend, f_ralen, f_rawin;
5666         struct fown_struct      f_owner;
5667         unsigned int            f_uid, f_gid;
5668         int                     f_error;
5669 @@ -471,8 +490,8 @@
5670         struct file *fl_file;
5671         unsigned char fl_flags;
5672         unsigned char fl_type;
5673 -       off_t fl_start;
5674 -       off_t fl_end;
5675 +       loff_t fl_start;
5676 +       loff_t fl_end;
5677  
5678         void (*fl_notify)(struct file_lock *);  /* unblock callback */
5679         void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
5680 @@ -483,6 +502,9 @@
5681         } fl_u;
5682  };
5683  
5684 +#define OFFSET_MAX     ((loff_t)((~0ULL)>>1))
5685 +#define OFFT_OFFSET_MAX        ((off_t)((~0UL)>>1))
5686 +
5687  extern struct file_lock                        *file_lock_table;
5688  
5689  #include <linux/fcntl.h>
5690 @@ -490,6 +512,9 @@
5691  extern int fcntl_getlk(unsigned int fd, struct flock *l);
5692  extern int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l);
5693  
5694 +extern int fcntl_getlk64(unsigned int fd, struct flock64 *l);
5695 +extern int fcntl_setlk64(unsigned int fd, unsigned int cmd, struct flock64 *l);
5696 +
5697  /* fs/locks.c */
5698  extern void locks_remove_posix(struct file *, fl_owner_t id);
5699  extern void locks_remove_flock(struct file *);
5700 @@ -596,12 +621,25 @@
5701  extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
5702  
5703  /*
5704 + * File types
5705 + */
5706 +#define DT_UNKNOWN     0
5707 +#define DT_FIFO                1
5708 +#define DT_CHR         2
5709 +#define DT_DIR         4
5710 +#define DT_BLK         6
5711 +#define DT_REG         8
5712 +#define DT_LNK         10
5713 +#define DT_SOCK                12
5714 +#define DT_WHT         14
5715 +
5716 +/*
5717   * This is the "filldir" function type, used by readdir() to let
5718   * the kernel specify what kind of dirent layout it wants to have.
5719   * This allows the kernel to read directories into kernel space or
5720   * to have different dirent layouts depending on the binary type.
5721   */
5722 -typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
5723 +typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t, unsigned);
5724         
5725  struct file_operations {
5726         loff_t (*llseek) (struct file *, loff_t, int);
5727 @@ -733,7 +771,7 @@
5728  
5729  asmlinkage int sys_open(const char *, int, int);
5730  asmlinkage int sys_close(unsigned int);                /* yes, it's really unsigned */
5731 -extern int do_truncate(struct dentry *, unsigned long);
5732 +extern int do_truncate(struct dentry *, loff_t);
5733  
5734  extern struct file *filp_open(const char *, int, int);
5735  extern int filp_close(struct file *, fl_owner_t id);
5736 diff -urN lfs-ref/include/linux/mm.h lfs/include/linux/mm.h
5737 --- lfs-ref/include/linux/mm.h  Wed Sep 12 02:39:57 2001
5738 +++ lfs/include/linux/mm.h      Wed Sep 12 02:42:15 2001
5739 @@ -54,7 +54,7 @@
5740         struct vm_area_struct **vm_pprev_share;
5741  
5742         struct vm_operations_struct * vm_ops;
5743 -       unsigned long vm_offset;
5744 +       loff_t vm_offset;
5745         struct file * vm_file;
5746         unsigned long vm_pte;                   /* shared mem */
5747  };
5748 @@ -108,9 +108,46 @@
5749         unsigned long (*wppage)(struct vm_area_struct * area, unsigned long address,
5750                 unsigned long page);
5751         int (*swapout)(struct vm_area_struct *, struct page *);
5752 -       pte_t (*swapin)(struct vm_area_struct *, unsigned long, unsigned long);
5753 +       pte_t (*swapin)(struct vm_area_struct *, loff_t, unsigned long);
5754  };
5755  
5756 +
5757 +/*
5758 + *  pgoff_t  type -- a complex one, and its simple alternate.
5759 + *  The complex one has type that compiler can trap at compile
5760 + *  time, but the simple one does simpler code (?)
5761 + */
5762 +
5763 +#if 0
5764 +typedef struct pgoff_t {
5765 +  unsigned long pgoff;
5766 +} pgoff_t;
5767 +
5768 +#define pgoff2ulong(pgof) ((pgof).pgoff)
5769 +extern __inline__ pgoff_t ulong2pgoff(unsigned long ul) {
5770 +  pgoff_t up;
5771 +  up.pgoff = ul;
5772 +  return up;
5773 +}
5774 +
5775 +#define pgoff2loff(pgof) (((loff_t)(pgof).pgoff) << PAGE_SHIFT)
5776 +#define loff2pgoff(loff) ulong2pgoff((loff) >> PAGE_SHIFT)
5777 +
5778 +#else /* Integer scalars -- simpler code.. */
5779 +
5780 +typedef unsigned long pgoff_t;
5781 +
5782 +#define pgoff2ulong(pgof) (pgof)
5783 +#define ulong2pgoff(pgof) (pgof)
5784 +
5785 +#define pgoff2loff(pgof) (((loff_t)(pgof)) << PAGE_SHIFT)
5786 +#define loff2pgoff(loff) ulong2pgoff((loff) >> PAGE_SHIFT)
5787 +
5788 +#endif
5789 +
5790 +#define PAGE_MASK_loff ((loff_t)(long)(PAGE_MASK))
5791 +
5792 +
5793  /*
5794   * Try to keep the most commonly accessed fields in single cache lines
5795   * here (16 bytes or greater).  This ordering should be particularly
5796 @@ -119,12 +156,13 @@
5797   * The first line is data used in page cache lookup, the second line
5798   * is used for linear searches (eg. clock algorithm scans). 
5799   */
5800 +
5801  typedef struct page {
5802         /* these must be first (free area handling) */
5803         struct page *next;
5804         struct page *prev;
5805 +       pgoff_t index;
5806         struct inode *inode;
5807 -       unsigned long offset;
5808         struct page *next_hash;
5809         atomic_t count;
5810         unsigned long flags;    /* atomic flags, some possibly updated asynchronously */
5811 @@ -299,7 +337,7 @@
5812  extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot);
5813  extern int zeromap_page_range(unsigned long from, unsigned long size, pgprot_t prot);
5814  
5815 -extern void vmtruncate(struct inode * inode, unsigned long offset);
5816 +extern void vmtruncate(struct inode * inode, loff_t offset);
5817  extern int handle_mm_fault(struct task_struct *tsk,struct vm_area_struct *vma, unsigned long address, int write_access);
5818  extern int make_pages_present(unsigned long addr, unsigned long end);
5819  
5820 @@ -319,16 +357,22 @@
5821  extern void exit_mmap(struct mm_struct *);
5822  extern unsigned long get_unmapped_area(unsigned long, unsigned long);
5823  
5824 -extern unsigned long do_mmap(struct file *, unsigned long, unsigned long,
5825 -       unsigned long, unsigned long, unsigned long);
5826 +extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
5827 +       unsigned long len, unsigned long prot,
5828 +       unsigned long flag, unsigned long pgoff);
5829 +
5830 +extern unsigned long do_mmap(struct file *, unsigned long,
5831 +                            unsigned long, unsigned long,
5832 +                            unsigned long, unsigned long);
5833 +
5834  extern int do_munmap(unsigned long, size_t);
5835  
5836  /* filemap.c */
5837  extern void remove_inode_page(struct page *);
5838  extern unsigned long page_unuse(struct page *);
5839  extern int shrink_mmap(int, int);
5840 -extern void truncate_inode_pages(struct inode *, unsigned long);
5841 -extern unsigned long get_cached_page(struct inode *, unsigned long, int);
5842 +extern void truncate_inode_pages(struct inode *, loff_t);
5843 +extern unsigned long get_cached_page(struct inode *, pgoff_t, int);
5844  extern void put_cached_page(unsigned long);
5845  
5846  /*
5847 diff -urN lfs-ref/include/linux/nfs.h lfs/include/linux/nfs.h
5848 --- lfs-ref/include/linux/nfs.h Fri Apr 20 22:31:21 2001
5849 +++ lfs/include/linux/nfs.h     Wed Sep 12 02:42:15 2001
5850 @@ -78,11 +78,7 @@
5851  #define NFS_MNTPROC_MNT                1
5852  #define NFS_MNTPROC_UMNT       3
5853  
5854 -/*
5855 - * This is really a general kernel constant, but since nothing like
5856 - * this is defined in the kernel headers, I have to do it here.
5857 - */
5858 -#define NFS_OFFSET_MAX         LONG_MAX
5859 +#define NFS_OFFSET_MAX         ((__s64)((~(__u64)0) >> 1))
5860  
5861  /*
5862   * These data types are used exlusively by the NFS client implementation.
5863 diff -urN lfs-ref/include/linux/nfs_fs.h lfs/include/linux/nfs_fs.h
5864 --- lfs-ref/include/linux/nfs_fs.h      Wed Sep 12 02:05:58 2001
5865 +++ lfs/include/linux/nfs_fs.h  Wed Sep 12 02:42:15 2001
5866 @@ -113,15 +113,15 @@
5867  
5868  
5869  static inline
5870 -unsigned long nfs_page_offset(struct page *page)
5871 +loff_t nfs_page_offset(struct page *page)
5872  {
5873 -        return page->offset;
5874 +       return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
5875  }
5876  
5877  static inline
5878  unsigned long page_index(struct page *page)
5879  {
5880 -       return page->offset >> PAGE_CACHE_SHIFT;
5881 +       return page->index;
5882  }
5883  
5884  /*
5885 @@ -284,6 +284,15 @@
5886  nfs_size_to_off_t(__u64 size)
5887  {
5888         return (size > (__u64)LONG_MAX) ? (off_t)LONG_MAX : (off_t) size;
5889 +}
5890 +
5891 +static inline loff_t
5892 +nfs_size_to_loff_t(__u64 size)
5893 +{
5894 +       loff_t maxsz = (((loff_t) ULONG_MAX) << PAGE_CACHE_SHIFT) + PAGE_CACHE_SIZE - 1;
5895 +       if (size > maxsz)
5896 +               return maxsz;
5897 +       return (loff_t) size;
5898  }
5899  
5900  static inline ino_t
5901 diff -urN lfs-ref/include/linux/nfs_xdr.h lfs/include/linux/nfs_xdr.h
5902 --- lfs-ref/include/linux/nfs_xdr.h     Wed Sep 12 02:05:59 2001
5903 +++ lfs/include/linux/nfs_xdr.h Wed Sep 12 02:42:15 2001
5904 @@ -329,11 +329,11 @@
5905         int     (*readlink)(struct inode *, void *buffer, unsigned int buflen);
5906         int     (*read)(struct inode *, struct rpc_cred *,
5907                         struct nfs_fattr *,
5908 -                       int flags, unsigned long offset,
5909 +                       int flags, loff_t offset,
5910                         unsigned int count, void *buffer, int *eofp);
5911         int     (*write)(struct inode *, struct rpc_cred *,
5912                         struct nfs_fattr *,
5913 -                       int flags, unsigned long offset,
5914 +                       int flags, loff_t offset,
5915                         unsigned int count, void *buffer,
5916                         struct nfs_writeverf *verfp);
5917         int     (*commit)(struct inode *, struct nfs_fattr *,
5918 @@ -361,6 +361,7 @@
5919         int     (*statfs)(struct nfs_server *, struct nfs_fh *,
5920                         struct nfs_fsinfo *);
5921         __u32 * (*decode_dirent)(__u32 *, struct nfs_entry *, int plus);
5922 +       int     bigfiles;
5923  };
5924  
5925  /*
5926 diff -urN lfs-ref/include/linux/nfsd/nfsd.h lfs/include/linux/nfsd/nfsd.h
5927 --- lfs-ref/include/linux/nfsd/nfsd.h   Sat Apr 21 18:21:21 2001
5928 +++ lfs/include/linux/nfsd/nfsd.h       Wed Sep 12 02:42:15 2001
5929 @@ -57,7 +57,7 @@
5930         char                    dotonly;
5931  };
5932  typedef int            (*encode_dent_fn)(struct readdir_cd *, const char *,
5933 -                                               int, off_t, ino_t);
5934 +                                               int, off_t, ino_t, unsigned int);
5935  typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
5936  
5937  /*
5938 diff -urN lfs-ref/include/linux/nfsd/xdr.h lfs/include/linux/nfsd/xdr.h
5939 --- lfs-ref/include/linux/nfsd/xdr.h    Sat Apr 21 18:21:21 2001
5940 +++ lfs/include/linux/nfsd/xdr.h        Wed Sep 12 02:42:15 2001
5941 @@ -152,7 +152,7 @@
5942  int nfssvc_encode_readdirres(struct svc_rqst *, u32 *, struct nfsd_readdirres *);
5943  
5944  int nfssvc_encode_entry(struct readdir_cd *, const char *name,
5945 -                               int namlen, off_t offset, ino_t ino);
5946 +                               int namlen, off_t offset, ino_t ino, unsigned int d_type);
5947  
5948  int nfssvc_release_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
5949  
5950 diff -urN lfs-ref/include/linux/nfsd/xdr3.h lfs/include/linux/nfsd/xdr3.h
5951 --- lfs-ref/include/linux/nfsd/xdr3.h   Sat Apr 21 18:21:24 2001
5952 +++ lfs/include/linux/nfsd/xdr3.h       Wed Sep 12 02:42:15 2001
5953 @@ -292,9 +292,9 @@
5954  int nfs3svc_release_fhandle2(struct svc_rqst *, u32 *,
5955                                 struct nfsd3_fhandle_pair *);
5956  int nfs3svc_encode_entry(struct readdir_cd *, const char *name,
5957 -                               int namlen, off_t offset, ino_t ino);
5958 +                               int namlen, off_t offset, ino_t ino, unsigned int d_type);
5959  int nfs3svc_encode_entry_plus(struct readdir_cd *, const char *name,
5960 -                               int namlen, off_t offset, ino_t ino);
5961 +                               int namlen, off_t offset, ino_t ino, unsigned int d_type);
5962  
5963  
5964  #endif /* _LINUX_NFSD_XDR3_H */
5965 diff -urN lfs-ref/include/linux/pagemap.h lfs/include/linux/pagemap.h
5966 --- lfs-ref/include/linux/pagemap.h     Sat Apr 21 18:19:44 2001
5967 +++ lfs/include/linux/pagemap.h Wed Sep 12 02:42:15 2001
5968 @@ -28,6 +28,7 @@
5969  #define PAGE_CACHE_SHIFT       PAGE_SHIFT
5970  #define PAGE_CACHE_SIZE                PAGE_SIZE
5971  #define PAGE_CACHE_MASK                PAGE_MASK
5972 +#define PAGE_CACHE_MASK_loff   PAGE_MASK_loff
5973  
5974  #define page_cache_alloc()     __get_free_page(GFP_USER)
5975  #define page_cache_free(x)     free_page(x)
5976 @@ -54,10 +55,10 @@
5977   * inode pointer and offsets are distributed (ie, we
5978   * roughly know which bits are "significant")
5979   */
5980 -static inline unsigned long _page_hashfn(struct inode * inode, unsigned long offset)
5981 +static inline unsigned long _page_hashfn(struct inode * inode, pgoff_t index)
5982  {
5983  #define i (((unsigned long) inode)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1)))
5984 -#define o ((offset >> PAGE_SHIFT) + (offset & ~PAGE_MASK))
5985 +#define o (index + (index >> PAGE_HASH_BITS))
5986         return ((i+o) & PAGE_HASH_MASK);
5987  #undef i
5988  #undef o
5989 @@ -65,7 +66,7 @@
5990  
5991  #define page_hash(inode,offset) (page_hash_table+_page_hashfn(inode,offset))
5992  
5993 -static inline struct page * __find_page(struct inode * inode, unsigned long offset, struct page *page)
5994 +static inline struct page * __find_page(struct inode * inode, pgoff_t index, struct page *page)
5995  {
5996         goto inside;
5997         for (;;) {
5998 @@ -75,7 +76,7 @@
5999                         goto not_found;
6000                 if (page->inode != inode)
6001                         continue;
6002 -               if (page->offset == offset)
6003 +               if (pgoff2ulong(page->index) == pgoff2ulong(index))
6004                         break;
6005         }
6006         /* Found the page. */
6007 @@ -85,9 +86,9 @@
6008         return page;
6009  }
6010  
6011 -static inline struct page *find_page(struct inode * inode, unsigned long offset)
6012 +static inline struct page *find_page(struct inode * inode, pgoff_t poffset)
6013  {
6014 -       return __find_page(inode, offset, *page_hash(inode, offset));
6015 +       return __find_page(inode, poffset, *page_hash(inode, poffset));
6016  }
6017  
6018  static inline void remove_page_from_hash_queue(struct page * page)
6019 @@ -110,9 +111,9 @@
6020         page->pprev_hash = p;
6021  }
6022  
6023 -static inline void add_page_to_hash_queue(struct page * page, struct inode * inode, unsigned long offset)
6024 +static inline void add_page_to_hash_queue(struct page * page, struct inode * inode, pgoff_t poffset)
6025  {
6026 -       __add_page_to_hash_queue(page, page_hash(inode,offset));
6027 +       __add_page_to_hash_queue(page, page_hash(inode,poffset));
6028  }
6029  
6030  static inline void remove_page_from_inode_queue(struct page * page)
6031 @@ -150,8 +151,8 @@
6032                 __wait_on_page(page);
6033  }
6034  
6035 -extern void update_vm_cache_conditional(struct inode *, unsigned long, const char *, int, unsigned long);
6036 -extern void update_vm_cache(struct inode *, unsigned long, const char *, int);
6037 +extern void update_vm_cache_conditional(struct inode *, loff_t, const char *, int, unsigned long);
6038 +extern void update_vm_cache(struct inode *, loff_t, const char *, int);
6039  
6040  typedef int filler_t(void *, struct page*);
6041  
6042 diff -urN lfs-ref/include/linux/sched.h lfs/include/linux/sched.h
6043 --- lfs-ref/include/linux/sched.h       Wed Sep 12 02:39:57 2001
6044 +++ lfs/include/linux/sched.h   Wed Sep 12 02:42:15 2001
6045 @@ -317,7 +317,7 @@
6046         int keep_capabilities:1;
6047         struct user_struct *user;
6048  /* limits */
6049 -       struct rlimit rlim[RLIM_NLIMITS];
6050 +       struct rlimit   rlim[RLIM_NLIMITS];
6051         unsigned short used_math;
6052         char comm[16];
6053  /* file system info */
6054 diff -urN lfs-ref/include/linux/smb_fs.h lfs/include/linux/smb_fs.h
6055 --- lfs-ref/include/linux/smb_fs.h      Sat Apr 21 18:48:37 2001
6056 +++ lfs/include/linux/smb_fs.h  Wed Sep 12 02:42:15 2001
6057 @@ -121,8 +121,8 @@
6058  void smb_close_dentry(struct dentry *);
6059  int smb_close_fileid(struct dentry *, __u16);
6060  int smb_open(struct dentry *, int);
6061 -int smb_proc_read(struct dentry *, off_t, int, char *);
6062 -int smb_proc_write(struct dentry *, off_t, int, const char *);
6063 +int smb_proc_read(struct dentry *, loff_t, int, char *);
6064 +int smb_proc_write(struct dentry *, loff_t, int, const char *);
6065  int smb_proc_create(struct dentry *, __u16, time_t, __u16 *);
6066  int smb_proc_mv(struct dentry *, struct dentry *);
6067  int smb_proc_mkdir(struct dentry *);
6068 diff -urN lfs-ref/include/linux/swap.h lfs/include/linux/swap.h
6069 --- lfs-ref/include/linux/swap.h        Sat Apr 21 18:19:44 2001
6070 +++ lfs/include/linux/swap.h    Wed Sep 12 02:42:15 2001
6071 @@ -114,7 +114,7 @@
6072  extern unsigned int nr_swapfiles;
6073  extern struct swap_info_struct swap_info[];
6074  void si_swapinfo(struct sysinfo *);
6075 -unsigned long get_swap_page(void);
6076 +extern unsigned long  get_swap_page(void);
6077  extern void FASTCALL(swap_free(unsigned long));
6078  struct swap_list_t {
6079         int head;       /* head of priority-ordered swapfile list */
6080 @@ -147,7 +147,7 @@
6081  extern inline unsigned long in_swap_cache(struct page *page)
6082  {
6083         if (PageSwapCache(page))
6084 -               return page->offset;
6085 +               return pgoff2ulong(page->index);
6086         return 0;
6087  }
6088  
6089 @@ -164,7 +164,7 @@
6090                 return 1;
6091         count = atomic_read(&page->count);
6092         if (PageSwapCache(page))
6093 -               count += swap_count(page->offset) - 2;
6094 +               count += swap_count(pgoff2ulong(page->index)) - 2;
6095         if (PageFreeAfter(page))
6096                 count--;
6097         return  count > 1;
6098 diff -urN lfs-ref/include/linux/ufs_fs_i.h lfs/include/linux/ufs_fs_i.h
6099 --- lfs-ref/include/linux/ufs_fs_i.h    Tue Feb  1 18:24:19 2000
6100 +++ lfs/include/linux/ufs_fs_i.h        Wed Sep 12 02:42:15 2001
6101 @@ -18,7 +18,6 @@
6102                 __u32   i_data[15];
6103                 __u8    i_symlink[4*15];
6104         } i_u1;
6105 -       __u64   i_size;
6106         __u32   i_flags;
6107         __u32   i_gen;
6108         __u32   i_shadow;
6109 diff -urN lfs-ref/kernel/ksyms.c lfs/kernel/ksyms.c
6110 --- lfs-ref/kernel/ksyms.c      Wed Sep 12 02:39:58 2001
6111 +++ lfs/kernel/ksyms.c  Wed Sep 12 02:42:15 2001
6112 @@ -96,6 +96,7 @@
6113  
6114  /* process memory management */
6115  EXPORT_SYMBOL(do_mmap);
6116 +EXPORT_SYMBOL(do_mmap_pgoff);
6117  EXPORT_SYMBOL(do_munmap);
6118  EXPORT_SYMBOL(exit_mm);
6119  EXPORT_SYMBOL(exit_files);
6120 diff -urN lfs-ref/lib/vsprintf.c lfs/lib/vsprintf.c
6121 --- lfs-ref/lib/vsprintf.c      Mon Jan 17 16:44:50 2000
6122 +++ lfs/lib/vsprintf.c  Wed Sep 12 02:42:15 2001
6123 @@ -67,10 +67,106 @@
6124  #define LARGE  64              /* use 'ABCDEF' instead of 'abcdef' */
6125  
6126  #define do_div(n,base) ({ \
6127 -int __res; \
6128 -__res = ((unsigned long) n) % (unsigned) base; \
6129 -n = ((unsigned long) n) / (unsigned) base; \
6130 -__res; })
6131 +  int __res; \
6132 +  __res = ((unsigned long) n) % (unsigned) base; \
6133 +  n = ((unsigned long) n) / (unsigned) base; \
6134 +  __res; })
6135 +
6136 +#if BITS_PER_LONG < 64
6137 +
6138 +/* Note: do_ldiv assumes that unsigned long long is a 64 bit long
6139 + * and unsigned long is at least a 32 bits long.
6140 + */
6141 +#define do_ldiv(n, base) \
6142 +({ \
6143 +       unsigned long long value = n; \
6144 +       unsigned long long leftover; \
6145 +       unsigned long temp; \
6146 +       unsigned long result_div1, result_div2, result_div3, result_mod; \
6147 +\
6148 +       temp = value >> 32; \
6149 +       result_div1 = temp/(base); \
6150 +       result_mod = temp%(base); \
6151 +\
6152 +       temp = (result_mod << 24) | ((value >> 8) & 0xFFFFFF); \
6153 +       result_div2 = temp/(base); \
6154 +       result_mod = temp%(base); \
6155 +\
6156 +       temp = (result_mod << 8) | (value & 0xFF); \
6157 +       result_div3 = temp/(base); \
6158 +       result_mod = temp%(base);\
6159 +\
6160 +       leftover = ((unsigned long long)result_div1 << 32) | \
6161 +               ((unsigned long long)result_div2 << 8) | (result_div3); \
6162 +\
6163 +       n = leftover; \
6164 +       result_mod; \
6165 +})
6166 +
6167 +
6168 +static char * lnumber(char * str, long long num, int base, int size,
6169 +                     int precision, int type)
6170 +{
6171 +       char c,sign,tmp[66];
6172 +       const char *digits="0123456789abcdef";
6173 +       int i;
6174 +
6175 +       if (type & LARGE)
6176 +               digits = "0123456789ABCDEF";
6177 +       if (type & LEFT)
6178 +               type &= ~ZEROPAD;
6179 +       if (base < 2 || base > 36)
6180 +               return 0;
6181 +       c = (type & ZEROPAD) ? '0' : ' ';
6182 +       sign = 0;
6183 +       if (type & SIGN) {
6184 +               if (num < 0) {
6185 +                       sign = '-';
6186 +                       num = -num;
6187 +                       size--;
6188 +               } else if (type & PLUS) {
6189 +                       sign = '+';
6190 +                       size--;
6191 +               } else if (type & SPACE) {
6192 +                       sign = ' ';
6193 +                       size--;
6194 +               }
6195 +       }
6196 +       if (type & SPECIAL) {
6197 +               if (base == 16)
6198 +                       size -= 2;
6199 +       }
6200 +       i = 0;
6201 +       if (num == 0)
6202 +               tmp[i++]='0';
6203 +       else while (num != 0)
6204 +               tmp[i++] = digits[do_ldiv(num,base)];
6205 +       if (i > precision)
6206 +               precision = i;
6207 +       size -= precision;
6208 +       if (!(type&(ZEROPAD+LEFT)))
6209 +               while(size-->0)
6210 +                       *str++ = ' ';
6211 +       if (sign)
6212 +               *str++ = sign;
6213 +       if (type & SPECIAL) {
6214 +               if (base==16) {
6215 +                       *str++ = '0';
6216 +                       *str++ = digits[33];
6217 +               }
6218 +       }
6219 +       if (!(type & LEFT))
6220 +               while (size-- > 0)
6221 +                       *str++ = c;
6222 +       while (i < precision--)
6223 +               *str++ = '0';
6224 +       while (i-- > 0)
6225 +               *str++ = tmp[i];
6226 +       while (size-- > 0)
6227 +               *str++ = ' ';
6228 +       return str;
6229 +}
6230 +#endif
6231  
6232  static char * number(char * str, long num, int base, int size, int precision
6233         ,int type)
6234 @@ -207,7 +303,10 @@
6235                 /* get the conversion qualifier */
6236                 qualifier = -1;
6237                 if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
6238 -                       qualifier = *fmt;
6239 +                       if (*fmt == 'l' && qualifier == 'l')
6240 +                               qualifier = 'L';
6241 +                       else
6242 +                               qualifier = *fmt;
6243                         ++fmt;
6244                 }
6245  
6246 @@ -290,7 +389,22 @@
6247                                 --fmt;
6248                         continue;
6249                 }
6250 -               if (qualifier == 'l')
6251 +               if (qualifier == 'L') {
6252 +
6253 +#if BITS_PER_LONG < 64
6254 +               /* 64-bit printout in 32-bit systems !!
6255 +                  Needed at some point for 64-bit file offsets and
6256 +                  mmap() reporting functions. */
6257 +
6258 +                       unsigned long long lnum;
6259 +                       lnum = va_arg(args, unsigned long long);
6260 +                       str = lnumber(str, lnum, base, field_width,
6261 +                                     precision, flags);
6262 +                       continue;
6263 +#else
6264 +                       num = va_arg(args, unsigned long); /* 64-bit longs..*/
6265 +#endif
6266 +               } else if (qualifier == 'l')
6267                         num = va_arg(args, unsigned long);
6268                 else if (qualifier == 'h') {
6269                         num = (unsigned short) va_arg(args, int);
6270 diff -urN lfs-ref/mm/filemap.c lfs/mm/filemap.c
6271 --- lfs-ref/mm/filemap.c        Wed Sep 12 02:39:57 2001
6272 +++ lfs/mm/filemap.c    Wed Sep 12 02:42:15 2001
6273 @@ -78,7 +78,7 @@
6274   * Truncate the page cache at a set offset, removing the pages
6275   * that are beyond that offset (and zeroing out partial pages).
6276   */
6277 -void truncate_inode_pages(struct inode * inode, unsigned long start)
6278 +void truncate_inode_pages(struct inode * inode, loff_t start)
6279  {
6280         struct page ** p;
6281         struct page * page;
6282 @@ -86,10 +86,10 @@
6283  repeat:
6284         p = &inode->i_pages;
6285         while ((page = *p) != NULL) {
6286 -               unsigned long offset = page->offset;
6287 +               loff_t loffset = pgoff2loff(page->index);
6288  
6289                 /* page wholly truncated - free it */
6290 -               if (offset >= start) {
6291 +               if (loffset >= start) {
6292                         if (PageLocked(page)) {
6293                                 wait_on_page(page);
6294                                 goto repeat;
6295 @@ -105,9 +105,10 @@
6296                         continue;
6297                 }
6298                 p = &page->next;
6299 -               offset = start - offset;
6300 +               loffset = start - loffset;
6301                 /* partial truncate, clear end of page */
6302 -               if (offset < PAGE_CACHE_SIZE) {
6303 +               if (loffset < PAGE_CACHE_SIZE) {
6304 +                       unsigned int  offset  = loffset; /* truncate ok */
6305                         unsigned long address = page_address(page);
6306                         memset((void *) (offset + address), 0, PAGE_CACHE_SIZE - offset);
6307                         flush_page_to_ram(address);
6308 @@ -195,7 +196,8 @@
6309                  * were to be marked referenced..
6310                  */
6311                 if (PageSwapCache(page)) {
6312 -                       if (referenced && swap_count(page->offset) != 1)
6313 +                       if (referenced &&
6314 +                           swap_count(pgoff2ulong(page->index)) != 1)
6315                                 continue;
6316                         delete_from_swap_cache(page);
6317                         return 1;
6318 @@ -250,11 +252,12 @@
6319   * memory maps.  --sct
6320   */
6321  
6322 -void update_vm_cache_conditional(struct inode * inode, unsigned long pos, const char * buf, int count, unsigned long source_address)
6323 +void update_vm_cache_conditional(struct inode * inode, loff_t pos, const char * buf, int count, unsigned long source_address)
6324  {
6325         unsigned long offset, len;
6326 +       pgoff_t pgoff = loff2pgoff(pos);
6327  
6328 -       offset = (pos & ~PAGE_CACHE_MASK);
6329 +       offset = ((unsigned long)pos & ~PAGE_CACHE_MASK);
6330         pos = pos & PAGE_CACHE_MASK;
6331         len = PAGE_CACHE_SIZE - offset;
6332         do {
6333 @@ -262,7 +265,7 @@
6334  
6335                 if (len > count)
6336                         len = count;
6337 -               page = find_page(inode, pos);
6338 +               page = find_page(inode, pgoff);
6339                 if (page) {
6340                         char *dest = (char*) (offset + page_address(page));
6341  
6342 @@ -282,19 +285,20 @@
6343         } while (count);
6344  }
6345  
6346 -void update_vm_cache(struct inode * inode, unsigned long pos, const char * buf, int count)
6347 +void update_vm_cache(struct inode * inode, loff_t pos, const char * buf, int count)
6348  {
6349         update_vm_cache_conditional(inode, pos, buf, count, 0);
6350  }
6351  
6352  
6353  static inline void add_to_page_cache(struct page * page,
6354 -       struct inode * inode, unsigned long offset,
6355 -       struct page **hash)
6356 +                                    struct inode * inode,
6357 +                                    pgoff_t pgoff,
6358 +                                    struct page **hash)
6359  {
6360         atomic_inc(&page->count);
6361         page->flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error) | (1 << PG_referenced));
6362 -       page->offset = offset;
6363 +       page->index = pgoff;
6364         add_page_to_inode_queue(inode, page);
6365         __add_page_to_hash_queue(page, hash);
6366  }
6367 @@ -305,29 +309,32 @@
6368   * this is all overlapped with the IO on the previous page finishing anyway)
6369   */
6370  static unsigned long try_to_read_ahead(struct file * file,
6371 -                               unsigned long offset, unsigned long page_cache)
6372 +                                      pgoff_t pgoff, unsigned long page_cache)
6373  {
6374         struct inode *inode = file->f_dentry->d_inode;
6375 -       struct page * page;
6376 -       struct page ** hash;
6377 +       pgoff_t pg_size;
6378  
6379 -       offset &= PAGE_CACHE_MASK;
6380 -       switch (page_cache) {
6381 -       case 0:
6382 +       /* Calculate file size in 'pages' -- if even one byte (according to
6383 +          the 'i_size') exceeds the final page-size block, round up. */
6384 +       pg_size = loff2pgoff(inode->i_size+(PAGE_SIZE-1));
6385 +
6386 +       if (!page_cache) {
6387                 page_cache = page_cache_alloc();
6388                 if (!page_cache)
6389 -                       break;
6390 -       default:
6391 -               if (offset >= inode->i_size)
6392 -                       break;
6393 -               hash = page_hash(inode, offset);
6394 -               page = __find_page(inode, offset, *hash);
6395 +                       return 0; /* Can't allocate! */
6396 +       }
6397 +       /* Ok, we have a page, make sure it is in the page cache */
6398 +       if (pgoff2ulong(pgoff) < pgoff2ulong(pg_size)) {
6399 +               struct page * page;
6400 +               struct page ** hash;
6401 +               hash = page_hash(inode, pgoff);
6402 +               page = __find_page(inode, pgoff, *hash);
6403                 if (!page) {
6404                         /*
6405                          * Ok, add the new page to the hash-queues...
6406                          */
6407                         page = page_cache_entry(page_cache);
6408 -                       add_to_page_cache(page, inode, offset, hash);
6409 +                       add_to_page_cache(page, inode, pgoff, hash);
6410                         inode->i_op->readpage(file, page);
6411                         page_cache = 0;
6412                 }
6413 @@ -381,11 +388,11 @@
6414  
6415  #define PROFILE_MAXREADCOUNT 1000
6416  
6417 -static unsigned long total_reada;
6418 -static unsigned long total_async;
6419 -static unsigned long total_ramax;
6420 -static unsigned long total_ralen;
6421 -static unsigned long total_rawin;
6422 +static u_long total_reada;
6423 +static u_long total_async;
6424 +static u_long total_ramax;
6425 +static u_long total_ralen;
6426 +static u_long total_rawin;
6427  
6428  static void profile_readahead(int async, struct file *filp)
6429  {
6430 @@ -493,13 +500,13 @@
6431  
6432  static inline unsigned long generic_file_readahead(int reada_ok,
6433         struct file * filp, struct inode * inode,
6434 -       unsigned long ppos, struct page * page, unsigned long page_cache)
6435 +       loff_t ppos, struct page * page, unsigned long page_cache)
6436  {
6437 -       unsigned long max_ahead, ahead;
6438 -       unsigned long raend;
6439 +       loff_t max_ahead, ahead;
6440 +       loff_t raend;
6441         int max_readahead = get_max_readahead(inode);
6442  
6443 -       raend = filp->f_raend & PAGE_CACHE_MASK;
6444 +       raend = filp->f_raend & PAGE_CACHE_MASK_loff;
6445         max_ahead = 0;
6446  
6447  /*
6448 @@ -557,7 +564,7 @@
6449         ahead = 0;
6450         while (ahead < max_ahead) {
6451                 ahead += PAGE_CACHE_SIZE;
6452 -               page_cache = try_to_read_ahead(filp, raend + ahead,
6453 +               page_cache = try_to_read_ahead(filp, loff2pgoff(raend + ahead),
6454                                                 page_cache);
6455         }
6456  /*
6457 @@ -626,14 +633,14 @@
6458         struct dentry *dentry = filp->f_dentry;
6459         struct inode *inode = dentry->d_inode;
6460         unsigned long page_cache;
6461 -       size_t pos, pgpos;
6462 +       loff_t pos, posp;
6463         int reada_ok;
6464         int max_readahead = get_max_readahead(inode);
6465  
6466         page_cache = 0;
6467  
6468         pos = *ppos;
6469 -       pgpos = pos & PAGE_CACHE_MASK;
6470 +       posp = pos & PAGE_CACHE_MASK_loff;
6471  /*
6472   * If the current position is outside the previous read-ahead window, 
6473   * we reset the current read-ahead context and set read ahead max to zero
6474 @@ -641,7 +648,7 @@
6475   * otherwise, we assume that the file accesses are sequential enough to
6476   * continue read-ahead.
6477   */
6478 -       if (pgpos > filp->f_raend || pgpos + filp->f_rawin < filp->f_raend) {
6479 +       if (posp > filp->f_raend || posp + filp->f_rawin < filp->f_raend) {
6480                 reada_ok = 0;
6481                 filp->f_raend = 0;
6482                 filp->f_ralen = 0;
6483 @@ -657,12 +664,12 @@
6484   * Then, at least MIN_READAHEAD if read ahead is ok,
6485   * and at most MAX_READAHEAD in all cases.
6486   */
6487 -       if (pos + desc->count <= (PAGE_CACHE_SIZE >> 1)) {
6488 +       if (pos + desc->count <= (loff_t)(PAGE_CACHE_SIZE >> 1)) {
6489                 filp->f_ramax = 0;
6490         } else {
6491 -               unsigned long needed;
6492 +               loff_t needed;
6493  
6494 -               needed = ((pos + desc->count) & PAGE_CACHE_MASK) - pgpos;
6495 +               needed = ((pos + desc->count) & PAGE_CACHE_MASK) - posp;
6496  
6497                 if (filp->f_ramax < needed)
6498                         filp->f_ramax = needed;
6499 @@ -675,6 +682,7 @@
6500  
6501         for (;;) {
6502                 struct page *page, **hash;
6503 +               pgoff_t pgoff;
6504  
6505                 if (pos >= inode->i_size)
6506                         break;
6507 @@ -682,8 +690,9 @@
6508                 /*
6509                  * Try to find the data in the page cache..
6510                  */
6511 -               hash = page_hash(inode, pos & PAGE_CACHE_MASK);
6512 -               page = __find_page(inode, pos & PAGE_CACHE_MASK, *hash);
6513 +               pgoff = loff2pgoff(pos);
6514 +               hash = page_hash(inode, pgoff);
6515 +               page = __find_page(inode, pgoff, *hash);
6516                 if (!page)
6517                         goto no_cached_page;
6518  
6519 @@ -696,7 +705,7 @@
6520   * the page has been rewritten.
6521   */
6522                 if (PageUptodate(page) || PageLocked(page))
6523 -                       page_cache = generic_file_readahead(reada_ok, filp, inode, pos & PAGE_CACHE_MASK, page, page_cache);
6524 +                       page_cache = generic_file_readahead(reada_ok, filp, inode, pos & PAGE_CACHE_MASK_loff, page, page_cache);
6525                 else if (reada_ok && filp->f_ramax > MIN_READAHEAD)
6526                                 filp->f_ramax = MIN_READAHEAD;
6527  
6528 @@ -721,8 +730,8 @@
6529                         flush_dcache_page(page_address(page));
6530  
6531                 offset = pos & ~PAGE_CACHE_MASK;
6532 -               nr = PAGE_CACHE_SIZE - offset;
6533 -               if (nr > inode->i_size - pos)
6534 +               nr = PAGE_CACHE_SIZE - offset; /* small value */
6535 +               if ((loff_t)nr > (inode->i_size - pos))
6536                         nr = inode->i_size - pos;
6537  
6538                 /*
6539 @@ -762,7 +771,7 @@
6540                  */
6541                 page = page_cache_entry(page_cache);
6542                 page_cache = 0;
6543 -               add_to_page_cache(page, inode, pos & PAGE_CACHE_MASK, hash);
6544 +               add_to_page_cache(page, inode, pgoff, hash);
6545  
6546                 /*
6547                  * Error handling is tricky. If we get a read error,
6548 @@ -843,10 +852,26 @@
6549  ssize_t generic_file_read(struct file * filp, char * buf, size_t count, loff_t *ppos)
6550  {
6551         ssize_t retval;
6552 +       struct inode *inode = filp->f_dentry->d_inode;
6553 +
6554 +       if (((ssize_t) count) < 0)
6555 +               return -EINVAL;
6556  
6557         retval = -EFAULT;
6558         if (access_ok(VERIFY_WRITE, buf, count)) {
6559                 retval = 0;
6560 +
6561 +               /* L-F-S spec 2.2.1.25: */
6562 +               if (!(filp->f_flags & O_LARGEFILE) &&
6563 +                   S_ISREG(inode->i_mode) &&
6564 +                   (*ppos < inode->i_size) && count) {
6565 +                       if (*ppos >= 0x7fffffff) /* pos@2G forbidden */
6566 +                               return -EOVERFLOW;
6567 +                       if (*ppos + count > 0x7fffffff)
6568 +                               /* Read only until end of allowed region */
6569 +                               count = 0x7fffffff - *ppos;
6570 +               }
6571 +
6572                 if (count) {
6573                         read_descriptor_t desc;
6574  
6575 @@ -895,6 +920,9 @@
6576         struct file * in_file, * out_file;
6577         struct inode * in_inode, * out_inode;
6578  
6579 +       if (((ssize_t) count) < 0)
6580 +               return -EINVAL;
6581 +
6582         lock_kernel();
6583  
6584         /*
6585 @@ -988,20 +1016,25 @@
6586         struct file * file = area->vm_file;
6587         struct dentry * dentry = file->f_dentry;
6588         struct inode * inode = dentry->d_inode;
6589 -       unsigned long offset, reada, i;
6590 +       loff_t offset;
6591 +       pgoff_t pgoff, reada;
6592 +       int i;
6593         struct page * page, **hash;
6594         unsigned long old_page, new_page;
6595  
6596         new_page = 0;
6597 -       offset = (address & PAGE_MASK) - area->vm_start + area->vm_offset;
6598 +       offset = ((loff_t)((address & PAGE_MASK) - area->vm_start) +
6599 +                 area->vm_offset);
6600 +
6601         if (offset >= inode->i_size && (area->vm_flags & VM_SHARED) && area->vm_mm == current->mm)
6602                 goto no_page;
6603  
6604         /*
6605          * Do we have something in the page cache already?
6606          */
6607 -       hash = page_hash(inode, offset);
6608 -       page = __find_page(inode, offset, *hash);
6609 +       pgoff = loff2pgoff(offset);
6610 +       hash = page_hash(inode, pgoff);
6611 +       page = __find_page(inode, pgoff, *hash);
6612         if (!page)
6613                 goto no_cached_page;
6614  
6615 @@ -1052,11 +1085,12 @@
6616         /*
6617          * Try to read in an entire cluster at once.
6618          */
6619 -       reada   = offset;
6620 -       reada >>= PAGE_CACHE_SHIFT + page_cluster;
6621 -       reada <<= PAGE_CACHE_SHIFT + page_cluster;
6622 +       reada   = loff2pgoff(offset);
6623 +       /* Mask lowest  'page_cluster'  worth of the lowest bits */
6624 +       reada   = ulong2pgoff(pgoff2ulong(reada) & ((~(0UL)) << page_cluster));
6625  
6626 -       for (i = 1 << page_cluster; i > 0; --i, reada += PAGE_CACHE_SIZE)
6627 +       for (i = 1 << page_cluster; i > 0;
6628 +            --i, reada = ulong2pgoff(pgoff2ulong(reada)+1))
6629                 new_page = try_to_read_ahead(file, reada, new_page);
6630  
6631         if (!new_page)
6632 @@ -1070,7 +1104,7 @@
6633          * cache.. The page we just got may be useful if we
6634          * can't share, so don't get rid of it here.
6635          */
6636 -       page = find_page(inode, offset);
6637 +       page = find_page(inode, pgoff);
6638         if (page)
6639                 goto found_page;
6640  
6641 @@ -1079,7 +1113,7 @@
6642          */
6643         page = page_cache_entry(new_page);
6644         new_page = 0;
6645 -       add_to_page_cache(page, inode, offset, hash);
6646 +       add_to_page_cache(page, inode, pgoff, hash);
6647  
6648         if (inode->i_op->readpage(file, page) != 0)
6649                 goto failure;
6650 @@ -1128,10 +1162,10 @@
6651   * if the disk is full.
6652   */
6653  static inline int do_write_page(struct inode * inode, struct file * file,
6654 -       const char * page, unsigned long offset)
6655 +                               const char * page, loff_t offset)
6656  {
6657         int retval;
6658 -       unsigned long size;
6659 +       loff_t size;
6660         loff_t loff = offset;
6661         mm_segment_t old_fs;
6662  
6663 @@ -1155,7 +1189,7 @@
6664  }
6665  
6666  static int filemap_write_page(struct vm_area_struct * vma,
6667 -                             unsigned long offset,
6668 +                             loff_t offset,
6669                               unsigned long page)
6670  {
6671         int result;
6672 @@ -1189,7 +1223,7 @@
6673   */
6674  int filemap_swapout(struct vm_area_struct * vma, struct page * page)
6675  {
6676 -       return filemap_write_page(vma, page->offset, page_address(page));
6677 +       return filemap_write_page(vma, pgoff2loff(page->index), page_address(page));
6678  }
6679  
6680  static inline int filemap_sync_pte(pte_t * ptep, struct vm_area_struct *vma,
6681 @@ -1553,7 +1587,7 @@
6682  {
6683         struct dentry   *dentry = file->f_dentry; 
6684         struct inode    *inode = dentry->d_inode; 
6685 -       unsigned long   pos = *ppos;
6686 +       loff_t          pos = *ppos;
6687         unsigned long   limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
6688         struct page     *page, **hash;
6689         unsigned long   page_cache = 0;
6690 @@ -1569,6 +1603,9 @@
6691                 return error;
6692         }
6693  
6694 +       if (((ssize_t) count) < 0)
6695 +               return -EINVAL;
6696 +
6697         sync    = file->f_flags & O_SYNC;
6698         written = 0;
6699  
6700 @@ -1579,31 +1616,39 @@
6701          * Check whether we've reached the file size limit.
6702          */
6703         status = -EFBIG;
6704 -       if (pos >= limit) {
6705 +       if (limit != RLIM_INFINITY && pos >= limit) {
6706                 send_sig(SIGXFSZ, current, 0);
6707                 goto out;
6708         }
6709  
6710 +       /* L-F-S */
6711 +       if (!(file->f_flags & O_LARGEFILE) &&
6712 +           S_ISREG(inode->i_mode) && count) {
6713 +               if (pos >= 0x7fffffff) /* pos@2G forbidden */
6714 +                       goto out;
6715 +
6716 +               if (pos + count > 0x7fffffff)
6717 +                       count = 0x7fffffff - pos;
6718 +       }
6719 +
6720         status  = 0;
6721         /*
6722          * Check whether to truncate the write,
6723          * and send the signal if we do.
6724          */
6725 -       if (count > limit - pos) {
6726 -               send_sig(SIGXFSZ, current, 0);
6727 +       if (limit != RLIM_INFINITY && count > limit - pos)
6728                 count = limit - pos;
6729 -       }
6730  
6731         while (count) {
6732 -               unsigned long bytes, pgpos, offset;
6733 +               unsigned long bytes, offset;
6734 +               pgoff_t pgpos = loff2pgoff(pos);
6735                 char * dest;
6736  
6737                 /*
6738                  * Try to find the page in the cache. If it isn't there,
6739                  * allocate a free page.
6740                  */
6741 -               offset = (pos & ~PAGE_CACHE_MASK);
6742 -               pgpos = pos & PAGE_CACHE_MASK;
6743 +               offset = ((unsigned long)pos & ~PAGE_CACHE_MASK);
6744                 bytes = PAGE_CACHE_SIZE - offset;
6745                 if (bytes > count)
6746                         bytes = count;
6747 @@ -1681,15 +1726,14 @@
6748   * Note: we don't have to worry about races here, as the caller
6749   * is holding the inode semaphore.
6750   */
6751 -unsigned long get_cached_page(struct inode * inode, unsigned long offset,
6752 -                               int new)
6753 +unsigned long get_cached_page(struct inode * inode, pgoff_t pgoff, int new)
6754  {
6755         struct page * page;
6756         struct page ** hash;
6757         unsigned long page_cache = 0;
6758  
6759 -       hash = page_hash(inode, offset);
6760 -       page = __find_page(inode, offset, *hash);
6761 +       hash = page_hash(inode, pgoff);
6762 +       page = __find_page(inode, pgoff, *hash);
6763         if (!page) {
6764                 if (!new)
6765                         goto out;
6766 @@ -1698,7 +1742,7 @@
6767                         goto out;
6768                 clear_page(page_cache);
6769                 page = page_cache_entry(page_cache);
6770 -               add_to_page_cache(page, inode, offset, hash);
6771 +               add_to_page_cache(page, inode, pgoff, hash);
6772         }
6773         if (atomic_read(&page->count) != 2)
6774                 printk(KERN_ERR "get_cached_page: page count=%d\n",
6775 diff -urN lfs-ref/mm/memory.c lfs/mm/memory.c
6776 --- lfs-ref/mm/memory.c Wed Sep 12 02:39:58 2001
6777 +++ lfs/mm/memory.c     Wed Sep 12 02:42:15 2001
6778 @@ -862,7 +862,7 @@
6779         case 2:
6780                 if (!PageSwapCache(page_map))
6781                         break;
6782 -               if (swap_count(page_map->offset) != 1)
6783 +               if (swap_count(pgoff2ulong(page_map->index)) != 1)
6784                         break;
6785                 delete_from_swap_cache(page_map);
6786                 /* FallThrough */
6787 @@ -986,7 +986,7 @@
6788   * between the file and the memory map for a potential last
6789   * incomplete page.  Ugly, but necessary.
6790   */
6791 -void vmtruncate(struct inode * inode, unsigned long offset)
6792 +void vmtruncate(struct inode * inode, loff_t offset)
6793  {
6794         truncate_inode_pages(inode, offset);
6795         if (inode->i_mmap)
6796 diff -urN lfs-ref/mm/mmap.c lfs/mm/mmap.c
6797 --- lfs-ref/mm/mmap.c   Wed Sep 12 02:39:57 2001
6798 +++ lfs/mm/mmap.c       Wed Sep 12 02:42:15 2001
6799 @@ -169,11 +169,25 @@
6800  #undef _trans
6801  }
6802  
6803 -unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
6804 -       unsigned long prot, unsigned long flags, unsigned long off)
6805 +unsigned long do_mmap(struct file *file, unsigned long addr,
6806 +                     unsigned long len, unsigned long prot,
6807 +                     unsigned long flag, unsigned long offset)
6808 +{
6809 +       unsigned long ret = -EINVAL;
6810 +       if ((offset + PAGE_ALIGN(len)) < offset)
6811 +               goto out;
6812 +       if (!(offset & ~PAGE_MASK))
6813 +               ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
6814 +out:
6815 +       return ret;
6816 +}
6817 +
6818 +unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, unsigned long len,
6819 +       unsigned long prot, unsigned long flags, unsigned long pg_off)
6820  {
6821         struct mm_struct * mm = current->mm;
6822         struct vm_area_struct * vma;
6823 +       loff_t off = (loff_t)pg_off << PAGE_SHIFT;
6824         int error;
6825  
6826         if (file && (!file->f_op || !file->f_op->mmap))
6827 @@ -847,7 +861,8 @@
6828                  * the offsets must be contiguous..
6829                  */
6830                 if ((mpnt->vm_file != NULL) || (mpnt->vm_flags & VM_SHM)) {
6831 -                       unsigned long off = prev->vm_offset+prev->vm_end-prev->vm_start;
6832 +                       loff_t off = (prev->vm_offset +
6833 +                                     (loff_t)(prev->vm_end - prev->vm_start));
6834                         if (off != mpnt->vm_offset)
6835                                 continue;
6836                 }
6837 diff -urN lfs-ref/mm/page_alloc.c lfs/mm/page_alloc.c
6838 --- lfs-ref/mm/page_alloc.c     Wed Sep 12 02:39:57 2001
6839 +++ lfs/mm/page_alloc.c Wed Sep 12 02:42:15 2001
6840 @@ -115,7 +115,7 @@
6841         add_mem_queue(area, list(map_nr));
6842  
6843  static void free_local_pages(struct page * page) {
6844 -       unsigned long order = page->offset;
6845 +       unsigned long order = page->index;
6846         unsigned int type = PageDMA(page) ? 1 : 0;
6847         struct free_area_struct *area;
6848         unsigned long map_nr = page - mem_map;
6849 @@ -172,7 +172,7 @@
6850  
6851         page = mem_map + map_nr;
6852         list_add((struct list_head *) page, &current->local_pages);
6853 -       page->offset = order;
6854 +       page->index = order;
6855         current->nr_local_pages++;
6856  }
6857  
6858 diff -urN lfs-ref/mm/page_io.c lfs/mm/page_io.c
6859 --- lfs-ref/mm/page_io.c        Tue Jun 13 03:48:15 2000
6860 +++ lfs/mm/page_io.c    Wed Sep 12 02:42:15 2001
6861 @@ -112,7 +112,7 @@
6862                  * as if it were: we are not allowed to manipulate the inode
6863                  * hashing for locked pages.
6864                  */
6865 -               if (page->offset != entry) {
6866 +               if (pgoff2ulong(page->index) != entry) {
6867                         printk ("swap entry mismatch");
6868                         return;
6869                 }
6870 @@ -265,8 +265,8 @@
6871                 printk("VM: swap page is not in swap cache\n");
6872                 return;
6873         }
6874 -       if (page->offset != entry) {
6875 -               printk ("swap entry mismatch");
6876 +       if (pgoff2ulong(page->index) != entry) {
6877 +               printk ("VM: swap entry mismatch");
6878                 return;
6879         }
6880         rw_swap_page_base(rw, entry, page, wait);
6881 @@ -291,12 +291,12 @@
6882                 printk ("VM: read_swap_page: page already in page cache!\n");
6883                 return;
6884         }
6885 -       page->inode = &swapper_inode;
6886 -       page->offset = entry;
6887 +       page->inode     = &swapper_inode;
6888 +       page->index = ulong2pgoff(entry);
6889         atomic_inc(&page->count);       /* Protect from shrink_mmap() */
6890         rw_swap_page(rw, entry, buffer, 1);
6891         atomic_dec(&page->count);
6892 -       page->inode = 0;
6893 +       page->inode     = 0;
6894         clear_bit(PG_swap_cache, &page->flags);
6895  }
6896  
6897 diff -urN lfs-ref/mm/swap_state.c lfs/mm/swap_state.c
6898 --- lfs-ref/mm/swap_state.c     Fri Apr 20 22:31:21 2001
6899 +++ lfs/mm/swap_state.c Wed Sep 12 02:42:15 2001
6900 @@ -54,7 +54,7 @@
6901         if (PageTestandSetSwapCache(page)) {
6902                 printk(KERN_ERR "swap_cache: replacing non-empty entry %08lx "
6903                        "on page %08lx\n",
6904 -                      page->offset, page_address(page));
6905 +                      pgoff2ulong(page->index), page_address(page));
6906                 return 0;
6907         }
6908         if (page->inode) {
6909 @@ -65,8 +65,8 @@
6910         atomic_inc(&page->count);
6911         page->flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error) | (1 << PG_referenced));
6912         page->inode = &swapper_inode;
6913 -       page->offset = entry;
6914 -       add_page_to_hash_queue(page, &swapper_inode, entry);
6915 +       page->index = ulong2pgoff(entry);
6916 +       add_page_to_hash_queue(page, &swapper_inode, ulong2pgoff(entry));
6917         add_page_to_inode_queue(&swapper_inode, page);
6918         return 1;
6919  }
6920 @@ -204,7 +204,7 @@
6921   */
6922  void delete_from_swap_cache(struct page *page)
6923  {
6924 -       long entry = page->offset;
6925 +       long entry = pgoff2ulong(page->index);
6926  
6927  #ifdef SWAP_CACHE_INFO
6928         swap_cache_del_total++;
6929 @@ -252,7 +252,7 @@
6930         swap_cache_find_total++;
6931  #endif
6932         while (1) {
6933 -               found = find_page(&swapper_inode, entry);
6934 +               found = find_page(&swapper_inode, ulong2pgoff(entry));
6935                 if (!found)
6936                         return 0;
6937                 if (found->inode != &swapper_inode || !PageSwapCache(found))
6938 diff -urN lfs-ref/mm/vmscan.c lfs/mm/vmscan.c
6939 --- lfs-ref/mm/vmscan.c Wed Sep 12 02:39:57 2001
6940 +++ lfs/mm/vmscan.c     Wed Sep 12 02:42:15 2001
6941 @@ -74,7 +74,7 @@
6942          * memory, and we should just continue our scan.
6943          */
6944         if (PageSwapCache(page_map)) {
6945 -               entry = page_map->offset;
6946 +               entry = pgoff2ulong(page_map->index);
6947                 swap_duplicate(entry);
6948                 set_pte(page_table, __pte(entry));
6949  drop_pte:
This page took 0.920632 seconds and 3 git commands to generate.