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
8 -#define NR_SYSCALLS 377
9 +#define NR_SYSCALLS 378
12 * These offsets must match with alpha_mv in <asm/machvec.h>.
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
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)
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
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 */
45 + .long SYMBOL_NAME(sys_ni_syscall)
47 + .long SYMBOL_NAME(sys_getdents64) /* 220 */
48 + .long SYMBOL_NAME(sys_fcntl64) /* 221 */
51 * NOTE!! This doesn't have to be exact - we just have
53 * entries. Don't panic if you notice that this hasn't
54 * been shrunk every time we add a new system call.
56 - .rept NR_syscalls-190
57 + .rept NR_syscalls-221
58 .long SYMBOL_NAME(sys_ni_syscall)
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
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)
74 + struct file * file = NULL;
76 + down(¤t->mm->mmap_sem);
79 + flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
80 + if (!(flags & MAP_ANONYMOUS)) {
86 + error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
92 + up(¤t->mm->mmap_sem);
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)
100 + return do_mmap2(addr, len, prot, flags, fd, pgoff);
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
108 asmlinkage int old_mmap(struct mmap_arg_struct *arg)
110 - int error = -EFAULT;
111 - struct file * file = NULL;
112 struct mmap_arg_struct a;
115 if (copy_from_user(&a, arg, sizeof(a)))
119 - down(¤t->mm->mmap_sem);
121 - if (!(a.flags & MAP_ANONYMOUS)) {
127 - a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
129 + if (a.offset & ~PAGE_MASK)
132 - error = do_mmap(file, a.addr, a.len, a.prot, a.flags, a.offset);
135 + err = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
138 - up(¤t->mm->mmap_sem);
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))
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)
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))
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)
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
172 - .long sys_mmap /* 90 */
173 + .long old_mmap /* 90 */
177 @@ -1058,18 +1058,20 @@
178 .long sys_ni_syscall /* streams1 */
179 .long sys_ni_syscall /* streams2 */
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
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
210 #include <linux/sys.h>
211 #include <linux/ipc.h>
212 #include <linux/utsname.h>
213 +#include <linux/file.h>
215 #include <asm/uaccess.h>
217 @@ -192,25 +193,55 @@
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)
230 struct file * file = NULL;
233 down(¤t->mm->mmap_sem);
236 if (!(flags & MAP_ANONYMOUS)) {
237 - if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
244 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
245 - ret = do_mmap(file, addr, len, prot, flags, offset);
247 + ret = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
253 up(¤t->mm->mmap_sem);
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)
262 + return do_mmap2(addr, len, prot, flags, fd, pgoff);
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)
272 + if (offset & ~PAGE_MASK)
275 + ret = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
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
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,
292 + unsigned long pgoff)
294 struct file * file = NULL;
295 unsigned long retval = -EBADF;
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);
307 up(¤t->mm->mmap_sem);
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)
315 + /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
317 + return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12));
320 +asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
321 + unsigned long prot, unsigned long flags, unsigned long fd,
324 + return do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
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
332 #define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
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)
338 struct sunos_dirent * dirent;
339 struct sunos_dirent_callback * buf = (struct sunos_dirent_callback *) __buf;
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)
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
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
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
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);
396 extern void bcopy (const char *, char *, int);
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);
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
409 sethi %hi(sys_bdflush), %g1
410 jmpl %g1 + %lo(sys_bdflush), %g0
417 + sethi %hi(sys_mmap), %g1
419 + jmpl %g1 + %lo(sys_mmap), %g0
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);
428 + if (ret) return ret;
429 + if (f.l_start >= 0x7fffffffUL ||
430 + f.l_len >= 0x7fffffffUL ||
431 + f.l_start + f.l_len >= 0x7fffffffUL)
433 if(put_flock(&f, (struct flock32 *)arg))
439 return sys_fcntl(fd, cmd, (unsigned long)arg);
443 +asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
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);
451 __u32 dqb_bhardlimit;
452 __u32 dqb_bsoftlimit;
457 +extern asmlinkage long sys_truncate(const char * path, unsigned long length);
458 +extern asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
460 +asmlinkage int sys32_truncate64(const char * path, unsigned long high, unsigned long low)
465 + return sys_truncate(path, (high << 32) | low);
468 +asmlinkage int sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low)
473 + return sys_ftruncate(fd, (high << 32) | low);
476 extern asmlinkage int sys_utime(char * filename, struct utimbuf * times);
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)
486 struct readdir_callback32 * buf = (struct readdir_callback32 *) __buf;
487 struct old_linux_dirent32 * dirent;
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)
496 struct linux_dirent32 * dirent;
497 struct getdents_callback32 * buf = (struct getdents_callback32 *) __buf;
498 @@ -4049,6 +4081,39 @@
504 +/* This is just a version for 32-bit applications which does
505 + * not force O_LARGEFILE on.
508 +asmlinkage long sparc32_open(const char * filename, int flags, int mode)
513 + tmp = getname(filename);
515 + if (!IS_ERR(tmp)) {
517 + fd = get_unused_fd();
519 + struct file * f = filp_open(tmp, flags, mode);
520 + error = PTR_ERR(f);
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
542 #define ROUND_UP(x) (((x)+sizeof(s32)-1) & ~(sizeof(s32)-1))
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)
548 struct sunos_dirent * dirent;
549 struct sunos_dirent_callback * buf = (struct sunos_dirent_callback *) __buf;
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)
557 struct sunos_direntry * dirent;
558 struct sunos_direntry_callback * buf = (struct sunos_direntry_callback *) __buf;
559 @@ -1297,13 +1297,15 @@
563 +extern asmlinkage long sparc32_open(const char * filename, int flags, int mode);
565 asmlinkage int sunos_open(u32 filename, int flags, int mode)
570 current->personality |= PER_BSD;
571 - ret = sys_open ((char *)A(filename), flags, mode);
572 + ret = sparc32_open ((char *)A(filename), flags, mode);
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
580 .globl 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
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
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
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 @@
638 +extern asmlinkage long sparc32_open(const char * filename, int flags, int mode);
640 asmlinkage int solaris_open(u32 filename, int flags, u32 mode)
642 - int (*sys_open)(const char *,int,int) =
643 - (int (*)(const char *,int,int))SYS(open);
644 int fl = flags & 0xf;
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);
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 @@
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;
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);
675 size = MAX_DISK_SIZE;
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 @@
684 - if (filldir(dirent, ".", 1, i, IROOT) < 0)
685 + if (filldir(dirent, ".", 1, i, IROOT, DT_DIR) < 0)
692 - if (filldir(dirent, "..", 2, i, IROOT) < 0)
693 + if (filldir(dirent, "..", 2, i, IROOT, DT_DIR) < 0)
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)
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)
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)
724 @@ -380,13 +380,13 @@
726 switch ((unsigned int)filp->f_pos) {
728 - if (filldir(dirent, ".", 1, filp->f_pos, ino) < 0)
729 + if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) < 0)
735 - if (filldir(dirent, "..", 2, filp->f_pos, IROOT) < 0)
736 + if (filldir(dirent, "..", 2, filp->f_pos, IROOT, DT_DIR) < 0)
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
745 switch ((unsigned long)filp->f_pos) {
747 - if (filldir(dirent, ".", 1, 0, inode->i_ino) < 0)
748 + if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
753 - if (filldir(dirent, "..", 2, 1, dir.parent_id) < 0)
754 + if (filldir(dirent, "..", 2, 1, dir.parent_id, DT_DIR) < 0)
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)
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
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) {
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) {
788 pr_debug("AFFS: readdir(): filldir(\"%.*s\",ino=%lu), i=%d\n",
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)
794 filp->private_data = (void *)i;
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)
802 struct inode *inode = filp->f_dentry->d_inode;
808 + ssize_t blocksize, blockshift;
809 struct buffer_head *bh;
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,
820 affs_error(inode->i_sb,"file_write","Inode = NULL");
821 @@ -611,16 +611,22 @@
825 - blocksize = AFFS_I2BSIZE(inode);
826 + blocksize = AFFS_I2BSIZE(inode);
827 + blockshift = AFFS_I2BITS(inode);
829 + if (pos >= 0x7fffffff) /* Max size: 2G-1 */
831 + if ((pos + count) > 0x7fffffff)
832 + count = 0x7fffffff - pos;
834 while (written < count) {
835 - bh = affs_getblock(inode,pos / blocksize);
836 + bh = affs_getblock(inode, pos >> blockshift);
842 - c = blocksize - (pos % blocksize);
843 + c = blocksize - (pos & (blocksize -1));
844 if (c > count - written)
846 if (c != blocksize && !buffer_uptodate(bh)) {
851 - p = (pos % blocksize) + bh->b_data;
852 + p = (pos & (blocksize -1)) + bh->b_data;
853 c -= copy_from_user(p,buf,c);
861 + ssize_t blocksize, blockshift;
862 struct buffer_head *bh;
865 @@ -692,15 +698,16 @@
868 blocksize = AFFS_I2BSIZE(inode) - 24;
869 + blockshift = AFFS_I2BITS(inode);
871 while (written < count) {
872 - bh = affs_getblock(inode,pos / blocksize);
873 + bh = affs_getblock(inode,pos >> blockshift);
879 - c = blocksize - (pos % blocksize);
880 + c = blocksize - (pos & (blocksize -1));
881 if (c > count - written)
883 if (c != blocksize && !buffer_uptodate(bh)) {
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);
893 @@ -782,10 +789,10 @@
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);
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)) {
907 bh = affs_getblock(inode,first - 1);
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);
919 affs_free_block(inode->i_sb,ekey);
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;
926 /* If the file is not truncated to a block boundary,
928 * so it cannot become accessible again.
931 - rem = inode->i_size % net_blocksize;
932 + rem = inode->i_size & (net_blocksize -1);
934 if ((inode->i_sb->u.affs_sb.s_flags & SF_OFS))
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
940 block = AFFS_I2BSIZE(inode) - 24;
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;
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
952 switch((unsigned long) filp->f_pos)
955 - if (filldir(dirent, ".", 1, 0, inode->i_ino) < 0)
956 + if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
961 - if (filldir(dirent, "..", 2, 1, AUTOFS_ROOT_INO) < 0)
962 + if (filldir(dirent, "..", 2, 1, AUTOFS_ROOT_INO, DT_DIR) < 0)
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
973 - if (filldir(dirent, ".", 1, nr, inode->i_ino) < 0)
974 + if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0)
979 - if (filldir(dirent, "..", 2, nr, inode->i_ino) < 0)
980 + if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0)
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)
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
998 if (!file->f_op || !file->f_op->mmap ||
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) {
1006 "fd_offset is not blocksize aligned. Loading %s in anonymous memory.\n",
1007 @@ -467,7 +471,11 @@
1009 start_addr = ex.a_entry & 0xfffff000;
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) {
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 @@
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))
1031 @@ -1682,15 +1682,46 @@
1032 set_bit(PG_locked, &page->flags);
1033 set_bit(PG_free_after, &page->flags);
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;
1040 - *p = inode->i_op->bmap(inode, block);
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... */
1053 + /* Filesystem blocksize is same, or smaller than CPU
1054 + page size, we can easily process this.. */
1058 + /* Scale by FS blocks per page, presuming FS-blocks are smaller
1059 + than the processor page... */
1063 + *p = inode->i_op->bmap(inode, block);
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 !!! */
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
1090 char *name = vdirent->d_name;
1092 errfill = filldir(getdent, name, namlen,
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
1102 &cont_file, &cont_dentry);
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));
1108 generic_readpage(&cont_file, page);
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
1117 - if (filldir(dirent, ".", 1, nr, inode->i_ino) < 0)
1118 + if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0)
1123 - if (filldir(dirent, "..", 2, nr, inode->i_ino) < 0)
1124 + if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0)
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 )
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))
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)
1147 dquot_drop(inode); /* We don't want quota on quota files */
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
1153 filp->f_pos = (block << EFS_DIRBSIZE_BITS) | slot;
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);
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
1168 +static unsigned char ext2_filetype_table[] = {
1169 + DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
1172 static int ext2_readdir(struct file *, void *, filldir_t);
1174 static struct file_operations ext2_dir_operations = {
1175 @@ -201,10 +205,14 @@
1178 unsigned long version = filp->f_version;
1179 + unsigned char d_type = DT_UNKNOWN;
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,
1186 - filp->f_pos, le32_to_cpu(de->inode));
1187 + filp->f_pos, le32_to_cpu(de->inode), d_type);
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
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 *);
1203 #define EXT2_MAX_SIZE(bits) \
1204 (((EXT2_NDIR_BLOCKS + (1LL << (bits - 2)) + \
1206 EXT2_MAX_SIZE(10), EXT2_MAX_SIZE(11), EXT2_MAX_SIZE(12), EXT2_MAX_SIZE(13)
1212 * We have mostly NULL's here: the current defaults are ok for
1213 * the ext2 filesystem.
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 */
1224 ext2_release_file, /* release */
1225 ext2_sync_file, /* fsync */
1226 @@ -120,14 +110,9 @@
1228 offset += file->f_pos;
1230 -#if BITS_PER_LONG < 64
1235 offset > ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(inode->i_sb)])
1238 if (offset != file->f_pos) {
1239 file->f_pos = offset;
1242 size_t count, loff_t *ppos)
1244 struct inode * inode = filp->f_dentry->d_inode;
1250 @@ -202,24 +187,17 @@
1252 /* Check for overflow.. */
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)
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 */
1274 + if (pos + count > 0x7fffffffULL)
1275 + /* Write only until end of allowed region */
1276 + count = 0x7fffffffULL - pos;
1278 - off_t max = ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(sb)];
1279 + loff_t max = ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(sb)];
1283 @@ -239,20 +217,18 @@
1284 mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
1289 /* From SUS: We must generate a SIGXFSZ for file size overflow
1290 * only if no bytes were actually written to the file. --sct */
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);
1300 + if (limit != RLIM_INFINITY) {
1301 + if (pos >= limit) {
1302 + send_sig(SIGXFSZ, current, 0);
1305 + if (pos+count > limit)
1306 + count = limit - pos;
1310 @@ -382,15 +358,3 @@
1314 -#if BITS_PER_LONG < 64
1316 - * Called when an inode is about to be open.
1317 - * We use this to disallow opening RW large files on 32bit systems.
1319 -static int ext2_open_file (struct inode * inode, struct file * filp)
1321 - if (inode->u.ext2_i.i_high_size && (filp->f_mode & FMODE_WRITE))
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);
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;
1339 - inode->i_size |= ((__u64)le32_to_cpu(raw_inode->i_size_high))
1342 + inode->i_size = ((__u64)(inode->i_size & 0xFFFFFFFFUL)) |
1343 + (((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32);
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);
1351 -#if BITS_PER_LONG < 64
1352 - raw_inode->i_size_high =
1353 - cpu_to_le32(inode->u.ext2_i.i_high_size);
1355 raw_inode->i_size_high = cpu_to_le32(inode->i_size >> 32);
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 @@
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;
1370 -#if BITS_PER_LONG == 64
1371 if (size > ext2_max_sizes[EXT2_BLOCK_SIZE_BITS(inode->i_sb)])
1374 - if (limit < RLIM_INFINITY && size > limit) {
1375 + if (limit != RLIM_INFINITY && size > limit) {
1376 send_sig(SIGXFSZ, current, 0);
1380 -#if BITS_PER_LONG == 64
1382 struct super_block *sb = inode->i_sb;
1383 struct ext2_super_block *es = sb->u.ext2_sb.s_es;
1385 mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
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
1396 * Currently we always hold the inode semaphore during truncate, so
1397 * there's no need to test for changes during the operation.
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) \
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
1413 /* Fake . and .. for the root directory. */
1414 if (inode->i_ino == MSDOS_ROOT_INO) {
1416 - if (filldir(dirent, "..", cpos+1, cpos, MSDOS_ROOT_INO) < 0)
1417 + if (filldir(dirent, "..", cpos+1, cpos, MSDOS_ROOT_INO, DT_DIR) < 0)
1422 if (!long_slots||shortnames) {
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)
1432 memcpy(&longname[long_len+1], bufname, i);
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)
1447 + unsigned int d_type)
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
1455 Each time we process one block in bhlist, we replace
1456 it by a new prefetch block if needed.
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));
1462 We must prefetch complete block, so we must
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
1470 struct buffer_head *bh = pre.bhlist[pre.nolist];
1474 void fat_truncate(struct inode *inode)
1477 + int cluster_bytes, cluster_shift;
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 */;
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);
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
1498 sizeof(struct msdos_dir_entry);
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;
1508 MSDOS_I(inode)->i_attrs = 0;
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));
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 @@
1528 -asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
1530 - struct file * filp;
1531 - long err = -EBADF;
1537 +static long do_fcntl(unsigned int fd, unsigned int cmd,
1538 + unsigned long arg, struct file * filp)
1545 err = dupfd(fd, arg);
1546 @@ -219,11 +213,60 @@
1547 err = sock_fcntl (filp, cmd, arg);
1554 +asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
1556 + struct file * filp;
1557 + long err = -EBADF;
1564 + err = do_fcntl(fd, cmd, arg, filp);
1572 +#if BITS_PER_LONG == 32
1573 +asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
1575 + struct file * filp;
1576 + long err = -EBADF;
1585 + err = fcntl_getlk64(fd, (struct flock64 *) arg);
1588 + err = fcntl_setlk64(fd, cmd, (struct flock64 *) arg);
1591 + err = fcntl_setlk64(fd, cmd, (struct flock64 *) arg);
1594 + err = do_fcntl(fd, cmd, arg, filp);
1605 /* Table to convert sigio signal codes into poll band bitmaps */
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
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)) {
1622 if (filldir(dirent, DOT_DOT->Name,
1623 - DOT_DOT_LEN, 1, ntohl(cnid))) {
1624 + DOT_DOT_LEN, 1, ntohl(cnid), DT_DIR)) {
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);
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)) {
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)) {
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)) {
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
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)) {
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)) {
1686 &((struct hfs_cat_key *)brec.key)->CName);
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);
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)) {
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
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)) {
1718 if (filldir(dirent, DOT_DOT->Name,
1719 - DOT_DOT_LEN, 1, ntohl(cnid))) {
1720 + DOT_DOT_LEN, 1, ntohl(cnid), DT_DIR)) {
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);
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)) {
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)) {
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)) {
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 @@
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)
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)
1778 @@ -1402,7 +1402,7 @@
1780 ino = file_ino(de->fnode);
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;
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
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)
1797 filp->f_pos += de_len;
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)
1806 filp->f_pos += de_len;
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)
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
1822 int isofs_bmap(struct inode * inode,int block)
1824 - off_t b_off, offset, size;
1826 + unsigned offset, size;
1828 unsigned int firstext;
1829 unsigned long nextino;
1834 - b_off = block << ISOFS_BUFFER_BITS(inode);
1835 + b_off = (loff_t)block << ISOFS_BUFFER_BITS(inode);
1838 * If we are beyond the end of this file, don't give out any
1841 if( b_off >= inode->i_size )
1843 - off_t max_legal_read_offset;
1844 + loff_t max_legal_read_offset;
1847 * If we are *way* beyond the end of the file, print a message.
1849 if( b_off >= max_legal_read_offset )
1852 - printk("_isofs_bmap: block>= EOF(%d, %ld)\n", block,
1853 + printk("_isofs_bmap: block>= EOF(%d, %Ld)\n", block,
1857 @@ -1209,7 +1210,7 @@
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);
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;
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,
1891 *(u32 *)(&block->b_call.a_args.cookie.data));
1892 if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) {
1894 @@ -293,12 +297,12 @@
1895 struct inode *inode = file->f_file.f_dentry->d_inode;
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,
1905 + (long long)lock->fl.fl_start,
1906 + (long long)lock->fl.fl_end,
1909 /* Checking for read only file system */
1910 @@ -371,16 +375,18 @@
1912 struct file_lock *fl;
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,
1919 - lock->fl.fl_start,
1921 + (long long)lock->fl.fl_start,
1922 + (long long)lock->fl.fl_end);
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",
1929 + (long long)lock->fl.fl_start,
1930 + (long long)lock->fl.fl_end);
1932 conflock->caller = "somehost"; /* FIXME */
1933 conflock->oh.len = 0; /* don't return OH info */
1934 @@ -403,12 +409,12 @@
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,
1943 - lock->fl.fl_start,
1945 + (long long)lock->fl.fl_start,
1946 + (long long)lock->fl.fl_end);
1948 /* First, cancel any lock that might be there */
1949 nlmsvc_cancel_blocked(file, lock);
1950 @@ -431,12 +437,12 @@
1952 struct nlm_block *block;
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,
1959 - lock->fl.fl_start,
1961 + (long long)lock->fl.fl_start,
1962 + (long long)lock->fl.fl_end);
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
1971 #define NLMDBG_FACILITY NLMDBG_XDR
1972 #define NLM_MAXSTRLEN 1024
1973 -#define OFFSET_MAX LONG_MAX
1975 #define QUADLEN(len) (((len) + 3) >> 2)
1978 static void nlm_register_stats(void);
1979 static void nlm_unregister_stats(void);
1981 +static inline loff_t
1982 +s32_to_loff_t(__s32 offset)
1984 + return (loff_t)offset;
1987 +static inline __s32
1988 +loff_t_to_s32(loff_t offset)
1991 + if (offset >= NLM_OFFSET_MAX)
1992 + res = NLM_OFFSET_MAX;
1993 + else if (offset <= -NLM_OFFSET_MAX)
1994 + res = -NLM_OFFSET_MAX;
2001 * Initialization of NFS status variables
2004 nlm_decode_lock(u32 *p, struct nlm_lock *lock)
2006 struct file_lock *fl = &lock->fl;
2008 + s32 start, len, end;
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++);
2019 - if (len == 0 || (fl->fl_end = fl->fl_start + len - 1) < 0)
2020 + end = start + len - 1;
2022 + fl->fl_start = s32_to_loff_t(start);
2024 + if (len == 0 || end < 0)
2025 fl->fl_end = OFFSET_MAX;
2027 + fl->fl_end = s32_to_loff_t(end);
2032 nlm_encode_lock(u32 *p, struct nlm_lock *lock)
2034 struct file_lock *fl = &lock->fl;
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))
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)
2050 - *p++ = htonl(fl->fl_end - fl->fl_start + 1);
2051 + len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
2053 + *p++ = htonl(fl->fl_pid);
2054 + *p++ = htonl(start);
2055 + *p++ = htonl(len);
2061 nlm_encode_testres(u32 *p, struct nlm_res *resp)
2065 if (!(p = nlm_encode_cookie(p, &resp->cookie)))
2067 *p++ = resp->status;
2068 @@ -223,11 +253,14 @@
2069 if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
2072 - *p++ = htonl(fl->fl_start);
2073 + start = loff_t_to_s32(fl->fl_start);
2074 if (fl->fl_end == OFFSET_MAX)
2078 - *p++ = htonl(fl->fl_end - fl->fl_start + 1);
2079 + len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
2081 + *p++ = htonl(start);
2082 + *p++ = htonl(len);
2087 resp->status = ntohl(*p++);
2088 if (resp->status == NLM_LCK_DENIED) {
2089 struct file_lock *fl = &resp->lock.fl;
2092 + s32 start, len, end;
2094 memset(&resp->lock, 0, sizeof(resp->lock));
2096 @@ -456,10 +490,15 @@
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++);
2103 - if (len == 0 || (fl->fl_end = fl->fl_start + len - 1) < 0)
2104 + end = start + len - 1;
2106 + fl->fl_start = s32_to_loff_t(start);
2107 + if (len == 0 || end < 0)
2108 fl->fl_end = OFFSET_MAX;
2110 + fl->fl_end = s32_to_loff_t(end);
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
2119 #define NLMDBG_FACILITY NLMDBG_XDR
2120 #define NLM_MAXSTRLEN 1024
2121 -#define OFFSET_MAX ((off_t)LONG_MAX)
2123 #define QUADLEN(len) (((len) + 3) >> 2)
2127 typedef struct nlm_args nlm_args;
2129 -static inline off_t
2130 -size_to_off_t(__s64 size)
2131 +static inline loff_t
2132 +s64_to_loff_t(__s64 offset)
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;
2140 +loff_t_to_s64(loff_t offset)
2143 + if (offset > NLM4_OFFSET_MAX)
2144 + res = NLM4_OFFSET_MAX;
2145 + else if (offset < -NLM4_OFFSET_MAX)
2146 + res = -NLM4_OFFSET_MAX;
2153 @@ -139,11 +150,12 @@
2154 p = xdr_decode_hyper(p, &len);
2155 end = start + len - 1;
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);
2161 - if (len == 0 || fl->fl_end < 0)
2162 + if (len == 0 || end < 0)
2163 fl->fl_end = OFFSET_MAX;
2165 + fl->fl_end = s64_to_loff_t(end);
2169 @@ -154,18 +166,26 @@
2170 nlm4_encode_lock(u32 *p, struct nlm_lock *lock)
2172 struct file_lock *fl = &lock->fl;
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)))
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))
2186 + start = loff_t_to_s64(fl->fl_start);
2187 if (fl->fl_end == OFFSET_MAX)
2188 - p = xdr_encode_hyper(p, 0);
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);
2194 + *p++ = htonl(fl->fl_pid);
2195 + p = xdr_encode_hyper(p, start);
2196 + p = xdr_encode_hyper(p, len);
2202 nlm4_encode_testres(u32 *p, struct nlm_res *resp)
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)))
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);
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);
2222 + len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
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);
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;
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;
2243 + fl->fl_end = s64_to_loff_t(end);
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 @@
2252 #include <asm/uaccess.h>
2254 -#define OFFSET_MAX ((off_t)LONG_MAX) /* FIXME: move elsewhere? */
2256 static int flock_make_lock(struct file *filp, struct file_lock *fl,
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,
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,
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)
2279 - if (!posix_make_lock(filp, &file_lock, &flock))
2280 + if ((error = flock_to_posix_lock(filp, &file_lock, &flock)))
2284 if (filp->f_op->lock) {
2285 error = filp->f_op->lock(filp, F_GETLK, &file_lock);
2287 @@ -363,6 +364,18 @@
2288 flock.l_type = F_UNLCK;
2290 flock.l_pid = fl->fl_pid;
2291 +#if BITS_PER_LONG == 32
2293 + * Make sure we can represent the posix lock via
2294 + * legacy 32bit flock.
2296 + error = -EOVERFLOW;
2297 + if (fl->fl_start > OFFT_OFFSET_MAX)
2299 + if ((fl->fl_end != OFFSET_MAX)
2300 + && (fl->fl_end > OFFT_OFFSET_MAX))
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;
2311 - if (!posix_make_lock(filp, &file_lock, &flock))
2312 + if ((error = flock_to_posix_lock(filp, &file_lock, &flock)))
2316 @@ -475,6 +487,169 @@
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().
2324 +int fcntl_getlk64(unsigned int fd, struct flock64 *l)
2326 + struct file *filp;
2327 + struct file_lock *fl,file_lock;
2328 + struct flock64 flock;
2332 + if (copy_from_user(&flock, l, sizeof(flock)))
2335 + if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
2344 + if (!filp->f_dentry || !filp->f_dentry->d_inode || !filp->f_op)
2347 + if (!flock64_to_posix_lock(filp, &file_lock, &flock))
2350 + if (filp->f_op->lock) {
2351 + error = filp->f_op->lock(filp, F_GETLK, &file_lock);
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);
2358 + fl = (file_lock.fl_type == F_UNLCK ? NULL : &file_lock);
2360 + fl = posix_test_lock(filp, &file_lock);
2363 + flock.l_type = F_UNLCK;
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;
2373 + if (!copy_to_user(l, &flock, sizeof(flock)))
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().
2385 +int fcntl_setlk64(unsigned int fd, unsigned int cmd, struct flock64 *l)
2387 + struct file *filp;
2388 + struct file_lock file_lock;
2389 + struct flock64 flock;
2390 + struct dentry * dentry;
2391 + struct inode *inode;
2395 + * This might block, so we do it before checking the inode.
2398 + if (copy_from_user(&flock, l, sizeof(flock)))
2401 + /* Get arguments and validate them ...
2410 + if (!(dentry = filp->f_dentry))
2412 + if (!(inode = dentry->d_inode))
2417 + /* Don't allow mandatory locks on files that may be memory mapped
2420 + if (IS_MANDLOCK(inode) &&
2421 + (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
2423 + struct vm_area_struct *vma = inode->i_mmap;
2426 + if (vma->vm_flags & VM_MAYSHARE)
2428 + } while ((vma = vma->vm_next_share) != NULL);
2432 + if (!flock64_to_posix_lock(filp, &file_lock, &flock))
2436 + switch (flock.l_type) {
2438 + if (!(filp->f_mode & FMODE_READ))
2442 + if (!(filp->f_mode & FMODE_WRITE))
2450 +/* warn a bit for now, but don't overdo it */
2452 + static int count = 0;
2455 + printk(KERN_WARNING
2456 + "fcntl_setlk() called by process %d (%s) with broken flock() emulation\n",
2457 + current->pid, current->comm);
2460 + if (!(filp->f_mode & 3))
2469 + if (filp->f_op->lock != NULL) {
2470 + error = filp->f_op->lock(filp, cmd, &file_lock);
2474 + error = posix_lock_file(filp, &file_lock, cmd == F_SETLKW64);
2481 +#endif /* BITS_PER_LONG == 32 */
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
2490 -static int posix_make_lock(struct file *filp, struct file_lock *fl,
2492 +static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
2496 + int ret = -EINVAL;
2498 + memset(fl, 0, sizeof(*fl));
2500 + fl->fl_flags = FL_POSIX;
2502 + switch (l->l_type) {
2506 + fl->fl_type = l->l_type;
2512 + switch (l->l_whence) {
2513 + case 0: /*SEEK_SET*/
2516 + case 1: /*SEEK_CUR*/
2517 + start = filp->f_pos;
2519 + case 2: /*SEEK_END*/
2520 + start = filp->f_dentry->d_inode->i_size;
2526 + if (((start += l->l_start) < 0) || (l->l_len < 0))
2528 + fl->fl_end = start + l->l_len - 1;
2529 + if (l->l_len > 0 && fl->fl_end < 0)
2531 + fl->fl_start = start; /* we record the absolute position */
2532 + if (l->l_len != 0) {
2533 + start = fl->fl_end;
2535 + start = fl->fl_start;
2536 + fl->fl_end = OFFSET_MAX;
2539 + if (start > OFFT_OFFSET_MAX)
2542 + fl->fl_file = filp;
2543 + fl->fl_owner = current->files;
2544 + fl->fl_pid = current->pid;
2551 +#if BITS_PER_LONG == 32
2552 +static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
2553 + struct flock64 *l)
2558 memset(fl, 0, sizeof(*fl));
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 ");
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 ",
2575 kdevname(inode->i_dev), inode->i_ino, fl->fl_start,
2577 @@ -1282,6 +1518,3 @@
2579 return (q - buffer);
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
2588 de = (struct minix_dir_entry *) (offset + bh->b_data);
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) {
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
2600 size_t count, loff_t *ppos)
2602 struct inode * inode = filp->f_dentry->d_inode;
2604 - ssize_t written, c;
2606 + ssize_t written, c, m;
2607 struct buffer_head * bh;
2611 pos = inode->i_size;
2615 + /* L-F-S spec 2.2.1.27: */
2616 + if (!(filp->f_flags & O_LARGEFILE)) {
2617 + if (pos >= 0x7fffffffULL) /* pos@2G forbidden */
2620 + if (pos + count > 0x7fffffffULL)
2621 + /* Write only until end of allowed region */
2622 + count = 0x7fffffffULL - pos;
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;
2633 while (written < count) {
2634 - bh = minix_getblk(inode,pos/BLOCK_SIZE,1);
2635 + bh = minix_getblk(inode, pos >> BLOCK_SIZE_BITS, 1);
2641 - c = BLOCK_SIZE - (pos % BLOCK_SIZE);
2642 + m = pos & (BLOCK_SIZE - 1);
2643 + c = BLOCK_SIZE - m;
2644 if (c > count-written)
2646 if (c != BLOCK_SIZE && !buffer_uptodate(bh)) {
2651 - p = (pos % BLOCK_SIZE) + bh->b_data;
2652 + p = bh->b_data + m;
2653 c -= copy_from_user(p,buf,c);
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 @@
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) {
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) {
2677 ino = ncp_invent_inos(1);
2679 if (filldir(dirent, entry->i.entryName, entry->i.nameLen,
2680 - entry->f_pos, ino) < 0) {
2681 + entry->f_pos, ino, DT_UNKNOWN) < 0) {
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
2689 #include <linux/mm.h>
2690 #include <linux/locks.h>
2691 #include <linux/malloc.h>
2692 +#include <linux/unistd.h>
2694 #include <linux/ncp_fs.h>
2695 #include "ncplib_kernel.h"
2697 /* First read in as much as possible for each bufsize. */
2698 while (already_read < count) {
2700 - size_t to_read = min(bufsize - (pos % bufsize),
2701 + size_t to_read = min(bufsize - (pos & (bufsize-1)),
2702 count - already_read);
2704 error = ncp_read_bounce(NCP_SERVER(inode),
2706 struct dentry *dentry = file->f_dentry;
2707 struct inode *inode = dentry->d_inode;
2708 size_t already_written = 0;
2714 @@ -238,12 +239,18 @@
2716 already_written = 0;
2718 + /* Maximum file size: 2G-1 */
2719 + if (pos >= 0x7fffffffULL)
2721 + if ((pos + count) >= 0x7fffffffULL)
2722 + count = 0x7fffffffULL - pos;
2724 bouncebuffer = kmalloc(bufsize, GFP_NFS);
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);
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
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;
2745 inode->i_mtime = ncp_date_dos2unix(le16_to_cpu(nwi->modifyTime),
2748 inode->i_blocks = 0;
2749 if ((inode->i_blksize != 0) && (inode->i_size != 0)) {
2751 - (inode->i_size - 1) / inode->i_blksize + 1;
2752 + inode->i_blocks = ((inode->i_size - 1) >> fslog2(inode->i_blksize)) + 1;
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
2760 int plus = NFS_USE_READDIRPLUS(inode);
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));
2767 error = NFS_PROTO(inode)->readdir(inode, cred,
2769 * Note: assumes we have exclusive access to this inode either
2770 * throught inode->i_sem or some other mechanism.
2772 - if (page->offset == 0)
2773 + if (page_index(page) == 0)
2774 invalidate_inode_pages(inode);
2775 nfs_unlock_page(page);
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);
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
2791 static int nfs_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
2793 + if (!NFS_PROTO(file->f_dentry->d_inode)->bigfiles &&
2794 + page_index(page) > (0x7fffffff>>PAGE_SHIFT))
2796 return nfs_flush_incompatible(file, page);
2799 @@ -232,10 +235,10 @@
2800 struct inode * inode = dentry->d_inode;
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);
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
2816 * Preset the size and mtime, as there's no need
2817 * to invalidate the caches.
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;
2829 + if ((attr->ia_valid & ATTR_SIZE) && !NFS_PROTO(inode)->bigfiles &&
2830 + attr->ia_size > 0x7fffffff)
2833 error = nfs_wb_all(inode);
2836 @@ -831,6 +836,10 @@
2837 struct rpc_cred *cred = rpcauth_lookupcred(auth, 0);
2839 filp->private_data = cred;
2841 + if (!NFS_PROTO(filp->f_dentry->d_inode)->bigfiles)
2842 + filp->f_flags &= ~O_LARGEFILE;
2849 nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
2851 - off_t new_size, new_isize;
2853 + __u64 new_size, new_mtime;
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);
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
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)
2878 struct nfs_readargs arg = { NFS_FH(inode), offset, count, 1,
2880 struct rpc_message msg = { NFS3PROC_READ, &arg, &res, cred };
2883 - dprintk("NFS call read %d @ %ld\n", count, offset);
2884 + dprintk("NFS call read %d @ %Ld\n", count, (long long) offset);
2886 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
2887 dprintk("NFS reply read: %d\n", status);
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)
2896 struct nfs_writeargs arg = { NFS_FH(inode), offset, count,
2898 struct rpc_message msg = { NFS3PROC_WRITE, &arg, &res, cred };
2899 int status, rpcflags = 0;
2901 - dprintk("NFS call write %d @ %ld\n", count, offset);
2902 + dprintk("NFS call write %d @ %Ld\n", count, (long long) offset);
2904 if (flags & NFS_RW_SWAP)
2905 rpcflags |= NFS_RPC_SWAPFLAGS;
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
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)
2924 struct nfs_readargs arg = { NFS_FH(inode), offset, count, 1,
2926 struct rpc_message msg = { NFSPROC_READ, &arg, &res, cred };
2929 - dprintk("NFS call read %d @ %ld\n", count, offset);
2930 + dprintk("NFS call read %d @ %Ld\n", count, (long long) offset);
2932 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
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)
2942 struct nfs_writeargs arg = {NFS_FH(inode), offset, count,
2944 struct rpc_message msg = { NFSPROC_WRITE, &arg, &res, cred };
2945 int status, flags = 0;
2947 - dprintk("NFS call write %d @ %ld\n", count, offset);
2948 + dprintk("NFS call write %d @ %Ld\n", count, (long long) offset);
2950 if (how & NFS_RW_SWAP)
2951 flags |= NFS_RPC_SWAPFLAGS;
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
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)
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);
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);
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),
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);
2999 inode = file->f_dentry->d_inode;
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));
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
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)
3018 struct rpc_cred *cred = NULL;
3019 unsigned int wsize = NFS_SERVER(inode)->wsize;
3020 @@ -152,16 +152,17 @@
3022 struct nfs_fattr fattr;
3023 struct nfs_writeverf verifier;
3027 cred = nfs_file_cred(file);
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));
3035 buffer = (u8 *) page_address(page) + offset;
3036 - offset += nfs_page_offset(page);
3037 + base = nfs_page_offset(page) + offset;
3039 flags = ((IS_SWAPFILE(inode)) ? NFS_RW_SWAP : 0) | NFS_RW_SYNC;
3044 result = NFS_PROTO(inode)->write(inode, cred, &fattr, flags,
3045 - offset, wsize, buffer,
3046 + base, wsize, buffer,
3048 nfs_write_attributes(inode, &fattr);
3050 @@ -184,15 +185,15 @@
3059 * If we've extended the file, update the inode
3060 * now so we don't invalidate the cache.
3062 - if (offset > inode->i_size)
3063 - inode->i_size = offset;
3064 + if (base > inode->i_size)
3065 + inode->i_size = base;
3070 inode = page->inode;
3072 inode = file->f_dentry->d_inode;
3073 - if (page->offset >= inode->i_size)
3074 + if (nfs_page_offset(page) >= inode->i_size)
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);
3082 region_locked(struct inode *inode, struct nfs_page *req)
3084 struct file_lock *fl;
3085 - unsigned long rqstart, rqend;
3086 + loff_t rqstart, rqend;
3088 /* Don't optimize writes if we don't use NLM */
3089 if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)
3091 struct nfs_page *req;
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);
3101 * If wsize is smaller than page size, update and write
3104 nfs_release_request(req);
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);
3111 clear_bit(PG_uptodate, &page->flags);
3113 @@ -1193,18 +1194,18 @@
3115 struct nfs_page *req;
3116 struct inode *inode;
3117 - unsigned long start, end, len;
3118 + loff_t start, end, len;
3120 /* Set up the RPC argument and reply structs
3121 * NB: take care not to mess about with data->commit et al. */
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;
3139 - if (end >= inode->i_size || len > (~((u32)0) >> 1))
3140 + if (end >= inode->i_size || len < 0 || len > (~((u32)0) >> 1))
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);
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),
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) {
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
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;
3168 - iap->ia_size = ~(size_t) 0;
3169 + iap->ia_size = NFS_OFFSET_MAX;
3171 if ((tmp = ntohl(*p++)) == 1) { /* set to server time */
3172 iap->ia_valid |= ATTR_ATIME;
3173 @@ -678,11 +678,6 @@
3178 - dprintk("encode_entry(%.*s @%ld%s)\n",
3179 - namlen, name, (long) offset, plus? " plus" : "");
3182 /* truncate filename if too long */
3183 if (namlen > NFS3_MAXNAMLEN)
3184 namlen = NFS3_MAXNAMLEN;
3185 @@ -727,14 +722,14 @@
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)
3192 return encode_entry(cd, name, namlen, offset, ino, 0);
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)
3200 return encode_entry(cd, name, namlen, offset, ino, 1);
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
3206 * the name matching the specified inode number.
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)
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
3218 current->session = 1;
3220 current->fs->umask = 0;
3221 + current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
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
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)
3235 u32 *p = cd->buffer;
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 @@
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;
3249 - filp->f_flags = O_RDONLY;
3250 + filp->f_flags = O_RDONLY | O_LARGEFILE;
3251 filp->f_mode = FMODE_READ;
3255 /* Write back readahead params */
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
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 */
3278 @@ -226,11 +226,11 @@
3280 /* FIXME: Maybe we can return those with the previous call */
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;
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;
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;
3304 - error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &fs.f_blocks );
3305 + error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &size );
3308 + fs.f_blocks = size;
3309 fs.f_bfree=ntfs_get_free_cluster_count(vol->bitmap);
3310 fs.f_bavail=fs.f_bfree;
3312 /* Number of files is limited by free space only, so we lie here */
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;
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
3324 * Writes the volume size into vol_size. Returns 0 if successful
3327 -int ntfs_get_volumesize(ntfs_volume *vol, long *vol_size )
3328 +int ntfs_get_volumesize(ntfs_volume *vol, ntfs_u64 *vol_size )
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;
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
3347 #define ALLOC_REQUIRE_SIZE 2
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
3360 #include <asm/uaccess.h>
3362 -asmlinkage int sys_statfs(const char * path, struct statfs * buf)
3363 +asmlinkage long sys_statfs(const char * path, struct statfs * buf)
3365 struct dentry * dentry;
3371 -asmlinkage int sys_fstatfs(unsigned int fd, struct statfs * buf)
3372 +asmlinkage long sys_fstatfs(unsigned int fd, struct statfs * buf)
3375 struct inode * inode;
3380 -int do_truncate(struct dentry *dentry, unsigned long length)
3381 +int do_truncate(struct dentry *dentry, loff_t length)
3383 struct inode *inode = dentry->d_inode;
3385 struct iattr newattrs;
3387 - /* Not pretty: "inode->i_size" shouldn't really be "off_t". But it is. */
3388 - if ((off_t) length < 0)
3390 + /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
3395 fs_down(&inode->i_sem);
3396 newattrs.ia_size = length;
3398 inode->i_op->truncate(inode);
3400 fs_up(&inode->i_sem);
3405 -asmlinkage int sys_truncate(const char * path, unsigned long length)
3406 +static inline long do_sys_truncate(const char * path, loff_t length)
3408 struct dentry * dentry;
3409 struct inode * inode;
3410 @@ -136,7 +138,12 @@
3414 -asmlinkage int sys_ftruncate(unsigned int fd, unsigned long length)
3415 +asmlinkage long sys_truncate(const char * path, unsigned long length)
3417 + return do_sys_truncate(path, length);
3420 +static inline long do_sys_ftruncate(unsigned int fd, loff_t length)
3422 struct inode * inode;
3423 struct dentry *dentry;
3424 @@ -171,6 +178,24 @@
3428 +asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
3430 + return do_sys_ftruncate(fd, length);
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)
3437 + return do_sys_truncate(path, length);
3440 +asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
3442 + return do_sys_ftruncate(fd, length);
3450 * must be owner or have write permission.
3451 * Else, update from *times, must be owner or super user.
3453 -asmlinkage int sys_utime(char * filename, struct utimbuf * times)
3454 +asmlinkage long sys_utime(char * filename, struct utimbuf * times)
3457 struct dentry * dentry;
3459 * must be owner or have write permission.
3460 * Else, update from *times, must be owner or super user.
3462 -asmlinkage int sys_utimes(char * filename, struct timeval * utimes)
3463 +asmlinkage long sys_utimes(char * filename, struct timeval * utimes)
3466 struct dentry * dentry;
3468 * We do this by temporarily clearing all FS-related capabilities and
3469 * switching the fsuid/fsgid around to the real ones.
3471 -asmlinkage int sys_access(const char * filename, int mode)
3472 +asmlinkage long sys_access(const char * filename, int mode)
3474 struct dentry * dentry;
3475 int old_fsuid, old_fsgid;
3480 -asmlinkage int sys_chdir(const char * filename)
3481 +asmlinkage long sys_chdir(const char * filename)
3484 struct inode *inode;
3489 -asmlinkage int sys_fchdir(unsigned int fd)
3490 +asmlinkage long sys_fchdir(unsigned int fd)
3493 struct dentry *dentry;
3498 -asmlinkage int sys_chroot(const char * filename)
3499 +asmlinkage long sys_chroot(const char * filename)
3502 struct inode *inode;
3507 -asmlinkage int sys_fchmod(unsigned int fd, mode_t mode)
3508 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
3510 struct inode * inode;
3511 struct dentry * dentry;
3516 -asmlinkage int sys_chmod(const char * filename, mode_t mode)
3517 +asmlinkage long sys_chmod(const char * filename, mode_t mode)
3519 struct dentry * dentry;
3520 struct inode * inode;
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)
3528 struct dentry * dentry;
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)
3537 struct dentry * dentry;
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)
3546 struct dentry * dentry;
3549 f = get_empty_filp();
3552 +#if BITS_PER_LONG != 32
3553 + flags |= O_LARGEFILE;
3555 f->f_flags = flag = flags;
3556 f->f_mode = (flag+1) & O_ACCMODE;
3559 * For backward compatibility? Maybe this should be moved
3560 * into arch/i386 instead?
3562 -asmlinkage int sys_creat(const char * pathname, int mode)
3563 +asmlinkage long sys_creat(const char * pathname, int mode)
3565 return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
3568 * This routine simulates a hangup on the tty, to arrange that users
3569 * are given clean terminals at login time.
3571 -asmlinkage int sys_vhangup(void)
3572 +asmlinkage long sys_vhangup(void)
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)
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 */
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 */
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
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)
3607 read_unlock(&tasklist_lock);
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)
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 @@
3622 - if (filldir(dirent, ".", 1, i, ino) < 0) return 0;
3623 + if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0) return 0;
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)
3635 @@ -869,14 +869,14 @@
3636 if (prom_getname (nodes[node].node, buffer, 128) < 0)
3638 if (filldir(dirent, buffer, strlen(buffer),
3639 - filp->f_pos, NODE2INO(node)) < 0)
3640 + filp->f_pos, NODE2INO(node), DT_DIR) < 0)
3643 node = nodes[node].next;
3645 j = NODEP2INO(NODE(ino).first_prop);
3647 - if (filldir(dirent, ".node", 5, filp->f_pos, j) < 0)
3648 + if (filldir(dirent, ".node", 5, filp->f_pos, j, DT_REG) < 0)
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;
3664 if (filldir(dirent, p, strlen(p),
3665 - filp->f_pos, j) < 0)
3666 + filp->f_pos, j, DT_REG) < 0)
3672 if (filldir(dirent, d->name,
3674 - filp->f_pos, d->inode) < 0)
3675 + filp->f_pos, d->inode, d->mode >> 12) < 0)
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 @@
3686 - if (filldir(dirent, ".", 1, i, ino) < 0)
3687 + if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
3693 - if (filldir(dirent, "..", 2, i, de->parent->low_ino) < 0)
3694 + if (filldir(dirent, "..", 2, i, de->parent->low_ino, DT_DIR) < 0)
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)
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)
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
3720 QNX4_INODES_PER_BLOCK +
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) {
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
3733 asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
3736 + off_t retval, oldpos;
3738 struct dentry * dentry;
3739 struct inode * inode;
3741 if (!(dentry = file->f_dentry) ||
3742 !(inode = dentry->d_inode))
3744 + oldpos = file->f_pos;
3747 retval = llseek(file, offset, origin);
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;
3762 struct dentry * dentry;
3763 struct inode * inode;
3765 + loff_t offset, oldpos;
3773 + oldpos = file->f_pos;
3774 offset = llseek(file, ((loff_t) offset_high << 32) | offset_low,
3777 @@ -105,6 +116,14 @@
3778 if (!copy_to_user(result, &offset, sizeof(offset)))
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;
3795 ssize_t (*read)(struct file *, char *, size_t, loff_t *);
3796 + struct inode * inode;
3800 @@ -342,10 +362,13 @@
3805 + inode = file->f_dentry->d_inode;
3807 if (!(file->f_mode & FMODE_READ))
3809 - ret = locks_verify_area(FLOCK_VERIFY_READ, file->f_dentry->d_inode,
3810 - file, pos, count);
3812 + ret = locks_verify_area(FLOCK_VERIFY_READ, inode, file, pos, count);
3819 ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
3820 + struct inode * inode;
3824 @@ -376,8 +400,10 @@
3826 if (!(file->f_mode & FMODE_WRITE))
3828 - ret = locks_verify_area(FLOCK_VERIFY_WRITE, file->f_dentry->d_inode,
3829 - file, pos, count);
3831 + inode = file->f_dentry->d_inode;
3833 + ret = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file, pos, count);
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);
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
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)
3859 struct readdir_callback * buf = (struct readdir_callback *) __buf;
3860 struct old_linux_dirent * dirent;
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)
3868 struct linux_dirent * dirent;
3869 struct getdents_callback * buf = (struct getdents_callback *) __buf;
3870 @@ -187,6 +187,123 @@
3871 lastdirent = buf.previous;
3873 put_user(file->f_pos, &lastdirent->d_off);
3874 + error = count - buf.count;
3886 + * And even better one including d_type field and 64bit d_ino and d_off.
3888 +struct linux_dirent64 {
3891 + unsigned short d_reclen;
3892 + unsigned char d_type;
3896 +#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
3898 +struct getdents_callback64 {
3899 + struct linux_dirent64 * current_dir;
3900 + struct linux_dirent64 * previous;
3905 +static int filldir64(void * __buf, const char * name, int namlen, off_t offset,
3906 + ino_t ino, unsigned int d_type)
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);
3912 + buf->error = -EINVAL; /* only used if we fail.. */
3913 + if (reclen > buf->count)
3915 + dirent = buf->previous;
3917 +#if BITS_PER_LONG < 64
3919 + copy_to_user(&dirent->d_off, &d.d_off, sizeof(d.d_off));
3921 + put_user(offset, &dirent->d_off);
3924 + dirent = buf->current_dir;
3925 + buf->previous = dirent;
3926 + memset(&d, 0, NAME_OFFSET(&d));
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;
3939 +asmlinkage int sys_getdents64(unsigned int fd, void * dirent, unsigned int count)
3941 + struct file * file;
3942 + struct dentry * dentry;
3943 + struct inode * inode;
3944 + struct linux_dirent64 * lastdirent;
3945 + struct getdents_callback64 buf;
3954 + dentry = file->f_dentry;
3958 + inode = dentry->d_inode;
3962 + buf.current_dir = (struct linux_dirent64 *) dirent;
3963 + buf.previous = NULL;
3964 + buf.count = count;
3968 + if (!file->f_op || !file->f_op->readdir)
3973 + * Get the inode's semaphore to prevent changes
3974 + * to the directory while we read it.
3976 + down(&inode->i_sem);
3977 + error = file->f_op->readdir(file, &buf, filldir64);
3978 + up(&inode->i_sem);
3981 + error = buf.error;
3982 + lastdirent = buf.previous;
3984 +#if BITS_PER_LONG < 64
3986 + d_off = file->f_pos;
3987 + copy_to_user(&lastdirent->d_off, &d_off, sizeof(d_off));
3989 + put_user(file->f_pos, &lastdirent->d_off);
3991 error = count - buf.count;
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 @@
4001 +static unsigned char romfs_dtype_table[] = {
4002 + DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_SOCK, DT_FIFO
4006 romfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
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) {
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
4031 struct cache_head * cachep;
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);
4040 PARANOIA("cache %s/%s has existing block!\n",
4041 DENTRY_PATH(dentry));
4043 - offset = PAGE_SIZE + (i << PAGE_SHIFT);
4044 - block = (struct cache_block *) get_cached_page(inode,
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);
4052 index->block = block;
4054 struct inode * inode = get_cache_inode(cachep);
4055 struct cache_index * index;
4056 struct cache_block * block;
4057 - unsigned long page_off;
4059 unsigned int nent, offset, len = entry->len;
4060 unsigned int needed = len + sizeof(struct cache_entry);
4062 @@ -180,14 +181,15 @@
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);
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));
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
4084 switch ((unsigned int) filp->f_pos)
4087 - if (filldir(dirent, ".", 1, 0, dir->i_ino) < 0)
4088 + if (filldir(dirent, ".", 1, 0, dir->i_ino, DT_DIR) < 0)
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)
4101 if (filldir(dirent, entry->name, entry->len,
4102 - filp->f_pos, entry->ino) < 0)
4103 + filp->f_pos, entry->ino, DT_UNKNOWN) < 0)
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
4111 #include <linux/mm.h>
4112 #include <linux/malloc.h>
4113 #include <linux/pagemap.h>
4114 +#include <linux/unistd.h>
4116 #include <asm/uaccess.h>
4117 #include <asm/system.h>
4119 smb_readpage_sync(struct dentry *dentry, struct page *page)
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;
4128 clear_bit(PG_error, &page->flags);
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);
4141 - result = smb_proc_read(dentry, offset, rsize, buffer);
4142 + result = smb_proc_read(dentry, loffset, rsize, buffer);
4148 + loffset += result;
4150 dentry->d_inode->i_atime = CURRENT_TIME;
4152 @@ -113,23 +114,36 @@
4153 * Offset is the data offset within the page.
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)
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;
4167 + VERBOSE("file %s/%s, count=%d@%Ld, wsize=%d\n",
4168 + DENTRY_PATH(dentry), count, loffset, wsize);
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)
4176 + if (loffset + count > 0x7fffffffULL)
4177 + count = 0x7fffffff - loffset;
4180 + if (loffset >= 0xffffffffULL) /* 4G-1 ??? Or 2G-1 ??? */
4182 + if ((loffset + count) > 0xffffffffULL)
4183 + count = 0xffffffffULL - loffset;
4189 - result = smb_proc_write(dentry, offset, wsize, buffer);
4190 + result = smb_proc_write(dentry, loffset, wsize, buffer);
4193 /* N.B. what if result < wsize?? */
4194 @@ -138,29 +152,27 @@
4195 printk(KERN_DEBUG "short write, wsize=%d, result=%d\n",
4206 * Update the inode now rather than waiting for a refresh.
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;
4215 return written ? written : result;
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.
4224 smb_writepage(struct file *file, struct page *page)
4226 - struct dentry *dentry = file->f_dentry;
4229 #ifdef SMBFS_PARANOIA
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));
4239 @@ -180,10 +192,10 @@
4241 struct dentry *dentry = file->f_dentry;
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);
4248 - return smb_writepage_sync(dentry, page, offset, count);
4249 + return smb_writepage_sync(file, page, offset, count);
4254 struct dentry * dentry = file->f_dentry;
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);
4262 status = smb_revalidate_inode(dentry);
4265 struct dentry * dentry = file->f_dentry;
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);
4274 result = smb_revalidate_inode(dentry);
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);
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. */
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)
4296 struct smb_sb_info *server = server_from_dentry(dentry);
4297 __u16 returned_count, data_len;
4301 + if (offset > 0xffffffff)
4304 smb_lock_server(server);
4305 smb_setup_header(server, SMBread, 5, 0);
4306 buf = server->packet;
4307 @@ -1133,13 +1136,16 @@
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)
4314 struct smb_sb_info *server = server_from_dentry(dentry);
4318 - VERBOSE("file %s/%s, count=%d@%ld, packet_size=%d\n",
4319 + if (offset > 0xffffffff)
4322 + VERBOSE("file %s/%s, count=%d@%Ld, packet_size=%d\n",
4323 DENTRY_PATH(dentry), count, offset, server->packet_size);
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
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;
4337 tmp.st_size = inode->i_size;
4338 tmp.st_atime = inode->i_atime;
4339 tmp.st_mtime = inode->i_mtime;
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;
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 @@
4357 +/* ---------- LFS-64 ----------- */
4358 +#if !defined(__alpha__)
4360 +static long cp_new_stat64(struct inode * inode, struct stat64 * statbuf)
4362 + struct stat64 tmp;
4363 + unsigned int blocks, indirect;
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;
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;
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)
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
4396 +#define I_B (BLOCK_SIZE / sizeof(unsigned short))
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;
4410 + tmp.st_blocks = (BLOCK_SIZE / 512) * blocks;
4411 + tmp.st_blksize = BLOCK_SIZE;
4413 + tmp.st_blocks = inode->i_blocks;
4414 + tmp.st_blksize = inode->i_blksize;
4416 + return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
4419 +asmlinkage long sys_stat64(char * filename, struct stat64 * statbuf, long flags)
4421 + struct dentry * dentry;
4425 + dentry = namei(filename);
4427 + error = PTR_ERR(dentry);
4428 + if (!IS_ERR(dentry)) {
4429 + error = do_revalidate(dentry);
4431 + error = cp_new_stat64(dentry->d_inode, statbuf);
4439 +asmlinkage long sys_lstat64(char * filename, struct stat64 * statbuf, long flags)
4441 + struct dentry * dentry;
4445 + dentry = lnamei(filename);
4447 + error = PTR_ERR(dentry);
4448 + if (!IS_ERR(dentry)) {
4449 + error = do_revalidate(dentry);
4451 + error = cp_new_stat64(dentry->d_inode, statbuf);
4459 +asmlinkage long sys_fstat64(unsigned long fd, struct stat64 * statbuf, long flags)
4467 + struct dentry * dentry = f->f_dentry;
4469 + err = do_revalidate(dentry);
4471 + err = cp_new_stat64(dentry->d_inode, statbuf);
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
4483 inode->i_ino, (off_t) filp->f_pos, sde.inode);
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) {
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
4496 struct inode * inode = filp->f_dentry->d_inode;
4497 struct super_block * sb = inode->i_sb;
4501 struct buffer_head * bh;
4503 @@ -232,6 +232,21 @@
4508 + /* L-F-S spec 2.2.1.27: */
4509 + if (!(filp->f_flags & O_LARGEFILE)) {
4510 + if (pos >= 0x7fffffffULL) /* pos@2G forbidden */
4513 + if (pos + count > 0x7fffffffULL)
4514 + /* Write only until end of allowed region */
4515 + count = 0x7fffffffULL - pos;
4517 + if (pos >= 0xffffffffULL)
4518 + return -EFBIG; /* Only up to 4G-1! */
4519 + if ((pos + count) > 0xffffffffULL)
4520 + count = 0xffffffffULL - pos;
4522 while (written<count) {
4523 bh = sysv_getblk (inode, pos >> sb->sv_block_size_bits, 1);
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
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;
4535 + unsigned int start, length, location, result;
4536 + unsigned int possition, fragsize, blockmap, mask;
4537 + unsigned int swab;
4539 UFSD(("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count))
4543 start = ucpi->c_frotor >> 3;
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
4555 #include <linux/fs.h>
4556 #include <linux/ufs_fs.h>
4557 +#include <linux/unistd.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;
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);
4576 if (version != inode->i_version)
4578 error_msg = "inode out of bounds";
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
4592 struct inode * inode = filp->f_dentry->d_inode;
4598 @@ -177,11 +177,14 @@
4602 - /* Check for overflow.. */
4603 - if (pos > (__u32) (pos + count)) {
4604 - count = ~pos; /* == 0xFFFFFFFF - pos */
4606 + /* L-F-S spec 2.2.1.27: */
4607 + if (!(filp->f_flags & O_LARGEFILE)) {
4608 + if (pos >= 0x7fffffffULL) /* pos@2G forbidden */
4611 + if (pos + count > 0x7fffffffULL)
4612 + /* Write only until end of allowed region */
4613 + count = 0x7fffffffULL - pos;
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
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 @@
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);
4642 lastblock = ufs_fragstoblks (lastfrag);
4643 lastblockoff = ufs_fragnum (lastfrag);
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))) {
4655 @@ -497,13 +499,10 @@
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..
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);
4670 inode->i_atime = SWAB32(ufs_inode->ui_atime.tv_sec);
4671 inode->i_ctime = SWAB32(ufs_inode->ui_ctime.tv_sec);
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;
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
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);
4694 uspi = sb->u.ufs_sb.s_uspi;
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
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)
4714 static int ufs_trunc_direct (struct inode * inode)
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)
4723 struct super_block * sb;
4724 struct ufs_sb_private_info * uspi;
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;
4735 swab = sb->u.ufs_sb.s_swab;
4736 uspi = sb->u.ufs_sb.s_uspi;
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);
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)))
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);
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
4768 * some useful macros
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))
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
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);
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) {
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;
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
4814 + unsigned int d_type)
4817 struct RDIR_FILLDIR *d = (struct RDIR_FILLDIR *) buf;
4819 /* Make sure the .. entry points back to the pseudo_root */
4820 ino = pseudo_root->i_ino;
4822 - ret = d->filldir (d->dirbuf, name, name_len, offset, ino);
4823 + ret = d->filldir (d->dirbuf, name, name_len, offset, ino, DT_UNKNOWN);
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);
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
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 */
4841 #define F_DUPFD 0 /* dup */
4842 #define F_GETFD 1 /* get f_flags */
4844 __kernel_off_t l_len;
4845 __kernel_pid_t l_pid;
4849 +#define flock64 flock
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
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
4862 #if defined(__GNUC__)
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
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
4874 #define F_DUPFD 0 /* dup */
4875 #define F_GETFD 1 /* get f_flags */
4877 #define F_SETSIG 10 /* for sockets. */
4878 #define F_GETSIG 11 /* for sockets. */
4880 +#define F_GETLK64 12 /* using 'struct flock64' */
4881 +#define F_SETLK64 13
4882 +#define F_SETLKW64 14
4884 /* for F_[GET|SET]FL */
4885 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
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
4906 unsigned long __unused5;
4909 +/* Someone please add a glibc/arm compatible stat64 struct here. */
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 @@
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)
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
4932 #define F_SETSIG 10 /* for sockets. */
4933 #define F_GETSIG 11 /* for sockets. */
4935 +#define F_GETLK64 12 /* using 'struct flock64' */
4936 +#define F_SETLK64 13
4937 +#define F_SETLKW64 14
4939 /* for F_[GET|SET]FL */
4940 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
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
4961 unsigned long __unused5;
4964 +/* This matches struct stat64 in glibc2.1, hence the absolutely
4965 + * insane amounts of padding around dev_t's.
4968 + unsigned short st_dev;
4969 + unsigned char __pad0[10];
4971 +#define STAT64_HAS_BROKEN_ST_INO 1
4972 + unsigned long __st_ino;
4974 + unsigned int st_mode;
4975 + unsigned int st_nlink;
4977 + unsigned long st_uid;
4978 + unsigned long st_gid;
4980 + unsigned short st_rdev;
4981 + unsigned char __pad3[10];
4983 + long long st_size;
4984 + unsigned long st_blksize;
4986 + unsigned long st_blocks; /* Number 512-byte blocks allocated. */
4987 + unsigned long __pad4; /* future possible st_blocks high bits */
4989 + unsigned long st_atime;
4990 + unsigned long __pad5;
4992 + unsigned long st_mtime;
4993 + unsigned long __pad6;
4995 + unsigned long st_ctime;
4996 + unsigned long __pad7; /* will be high 32 bits of ctime someday */
4998 + unsigned long long st_ino;
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
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
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 */
5050 +#define __NR_getdents64 220
5051 +#define __NR_fcntl64 221
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> */
5056 #define __syscall_return(type, res) \
5058 @@ -269,6 +303,19 @@
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); \
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) \
5070 +__asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; int $0x80 ; pop %%ebp" \
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); \
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
5082 #define F_SETSIG 10 /* for sockets. */
5083 #define F_GETSIG 11 /* for sockets. */
5085 +#define F_GETLK64 12 /* using 'struct flock64' */
5086 +#define F_SETLK64 13
5087 +#define F_SETLKW64 14
5089 /* for F_[GET|SET]FL */
5090 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
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
5111 unsigned long __unused5;
5114 +/* stat64 struct goes here -- someone please make
5115 + * it mesh with whatever glibc does in userland on
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
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
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
5149 #define F_SETSIG 10 /* for sockets. */
5150 #define F_GETSIG 11 /* for sockets. */
5152 +#define F_GETLK64 33 /* using 'struct flock64' */
5153 +#define F_SETLK64 34
5154 +#define F_SETLKW64 35
5156 /* for F_[GET|SET]FL */
5157 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
5160 __kernel_pid_t l_pid;
5161 long pad[4]; /* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
5164 +typedef struct flock64 {
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
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 */
5183 #define F_DUPFD 0 /* dup */
5184 #define F_GETFD 1 /* get f_flags */
5186 #define F_SETSIG 10 /* for sockets. */
5187 #define F_GETSIG 11 /* for sockets. */
5189 +#define F_GETLK64 12 /* using 'struct flock64' */
5190 +#define F_SETLK64 13
5191 +#define F_SETLKW64 14
5193 /* for F_[GET|SET]FL */
5194 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
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
5215 unsigned long __unused5;
5218 +/* This matches struct stat64 in glibc2.1.
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. */
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;
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
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
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
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 */
5276 #define F_DUPFD 0 /* dup */
5277 #define F_GETFD 1 /* get f_flags */
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
5286 /* for F_[GET|SET]FL */
5287 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
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
5310 #ifndef _SPARC_STAT_H
5311 #define _SPARC_STAT_H
5316 unsigned long __unused4[2];
5320 + unsigned char __pad0[6];
5321 + unsigned short st_dev;
5323 + unsigned long long st_ino;
5325 + unsigned int st_mode;
5326 + unsigned int st_nlink;
5328 + unsigned int st_uid;
5329 + unsigned int st_gid;
5331 + unsigned char __pad2[6];
5332 + unsigned short st_rdev;
5334 + unsigned char __pad3[8];
5336 + long long st_size;
5337 + unsigned int st_blksize;
5339 + unsigned char __pad4[8];
5340 + unsigned int st_blocks;
5342 + unsigned int st_atime;
5343 + unsigned int __unused1;
5345 + unsigned int st_mtime;
5346 + unsigned int __unused2;
5348 + unsigned int st_ctime;
5349 + unsigned int __unused3;
5351 + unsigned int __unused4;
5352 + unsigned int __unused5;
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
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 */
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 */
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
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
5430 #define F_DUPFD 0 /* dup */
5431 #define F_GETFD 1 /* get f_flags */
5434 #define F_SETSIG 10 /* for sockets. */
5435 #define F_GETSIG 11 /* for sockets. */
5437 +#define F_GETLK64 12
5438 +#define F_SETLK64 13
5439 +#define F_SETLKW64 14
5442 /* for F_[GET|SET]FL */
5443 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
5453 __kernel_pid_t32 l_pid;
5457 +struct flock32_64 {
5460 + __kernel_loff_t32 l_start;
5461 + __kernel_loff_t32 l_len;
5462 + __kernel_pid_t32 l_pid;
5466 +#define flock64 flock
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
5476 #ifndef _SPARC64_STAT_H
5477 #define _SPARC64_STAT_H
5481 unsigned long __unused4[2];
5485 +/* This is sparc32 stat64 structure. */
5488 + unsigned char __pad0[6];
5489 + unsigned short st_dev;
5491 + unsigned long long st_ino;
5493 + unsigned int st_mode;
5494 + unsigned int st_nlink;
5496 + unsigned int st_uid;
5497 + unsigned int st_gid;
5499 + unsigned char __pad2[6];
5500 + unsigned short st_rdev;
5502 + unsigned char __pad3[8];
5504 + long long st_size;
5505 + unsigned int st_blksize;
5507 + unsigned char __pad4[8];
5508 + unsigned int st_blocks;
5510 + unsigned int st_atime;
5511 + unsigned int __unused1;
5513 + unsigned int st_mtime;
5514 + unsigned int __unused2;
5516 + unsigned int st_ctime;
5517 + unsigned int __unused3;
5519 + unsigned int __unused4;
5520 + unsigned int __unused5;
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
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 */
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
5590 char d_name[256]; /* We must not include limits.h! */
5596 + unsigned short d_reclen;
5597 + unsigned char d_type;
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
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 */
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)
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)
5627 + for (i = 0; val != 0; ++i, val >>= 1) {
5628 + if (val & 1) return i;
5633 +static int off_t_presentable(loff_t) __attribute((const));
5634 +static __inline__ int off_t_presentable(loff_t loff)
5636 + return loff >= 0 && loff <= (~0UL >> 1);
5639 #include <linux/pipe_fs_i.h>
5640 #include <linux/minix_fs_i.h>
5641 #include <linux/ext2_fs_i.h>
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;
5670 struct file *fl_file;
5671 unsigned char fl_flags;
5672 unsigned char fl_type;
5678 void (*fl_notify)(struct file_lock *); /* unblock callback */
5679 void (*fl_insert)(struct file_lock *); /* lock insertion callback */
5684 +#define OFFSET_MAX ((loff_t)((~0ULL)>>1))
5685 +#define OFFT_OFFSET_MAX ((off_t)((~0UL)>>1))
5687 extern struct file_lock *file_lock_table;
5689 #include <linux/fcntl.h>
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);
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);
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 *);
5706 +#define DT_UNKNOWN 0
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.
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);
5725 struct file_operations {
5726 loff_t (*llseek) (struct file *, loff_t, int);
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);
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
5740 struct vm_area_struct **vm_pprev_share;
5742 struct vm_operations_struct * vm_ops;
5743 - unsigned long vm_offset;
5745 struct file * vm_file;
5746 unsigned long vm_pte; /* shared mem */
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);
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 (?)
5764 +typedef struct pgoff_t {
5765 + unsigned long pgoff;
5768 +#define pgoff2ulong(pgof) ((pgof).pgoff)
5769 +extern __inline__ pgoff_t ulong2pgoff(unsigned long ul) {
5775 +#define pgoff2loff(pgof) (((loff_t)(pgof).pgoff) << PAGE_SHIFT)
5776 +#define loff2pgoff(loff) ulong2pgoff((loff) >> PAGE_SHIFT)
5778 +#else /* Integer scalars -- simpler code.. */
5780 +typedef unsigned long pgoff_t;
5782 +#define pgoff2ulong(pgof) (pgof)
5783 +#define ulong2pgoff(pgof) (pgof)
5785 +#define pgoff2loff(pgof) (((loff_t)(pgof)) << PAGE_SHIFT)
5786 +#define loff2pgoff(loff) ulong2pgoff((loff) >> PAGE_SHIFT)
5790 +#define PAGE_MASK_loff ((loff_t)(long)(PAGE_MASK))
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).
5801 typedef struct page {
5802 /* these must be first (free area handling) */
5806 struct inode *inode;
5807 - unsigned long offset;
5808 struct page *next_hash;
5810 unsigned long flags; /* atomic flags, some possibly updated asynchronously */
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);
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);
5820 @@ -319,16 +357,22 @@
5821 extern void exit_mmap(struct mm_struct *);
5822 extern unsigned long get_unmapped_area(unsigned long, unsigned long);
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);
5830 +extern unsigned long do_mmap(struct file *, unsigned long,
5831 + unsigned long, unsigned long,
5832 + unsigned long, unsigned long);
5834 extern int do_munmap(unsigned long, size_t);
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);
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
5851 #define NFS_MNTPROC_MNT 1
5852 #define NFS_MNTPROC_UMNT 3
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.
5858 -#define NFS_OFFSET_MAX LONG_MAX
5859 +#define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1))
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 @@
5870 -unsigned long nfs_page_offset(struct page *page)
5871 +loff_t nfs_page_offset(struct page *page)
5873 - return page->offset;
5874 + return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
5878 unsigned long page_index(struct page *page)
5880 - return page->offset >> PAGE_CACHE_SHIFT;
5881 + return page->index;
5885 @@ -284,6 +284,15 @@
5886 nfs_size_to_off_t(__u64 size)
5888 return (size > (__u64)LONG_MAX) ? (off_t)LONG_MAX : (off_t) size;
5891 +static inline loff_t
5892 +nfs_size_to_loff_t(__u64 size)
5894 + loff_t maxsz = (((loff_t) ULONG_MAX) << PAGE_CACHE_SHIFT) + PAGE_CACHE_SIZE - 1;
5897 + return (loff_t) size;
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 *,
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 *,
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 *,
5919 int (*statfs)(struct nfs_server *, struct nfs_fh *,
5920 struct nfs_fsinfo *);
5921 __u32 * (*decode_dirent)(__u32 *, struct nfs_entry *, int plus);
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
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);
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
5942 int nfssvc_encode_readdirres(struct svc_rqst *, u32 *, struct nfsd_readdirres *);
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);
5948 int nfssvc_release_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
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
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);
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
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
5974 #define page_cache_alloc() __get_free_page(GFP_USER)
5975 #define page_cache_free(x) free_page(x)
5977 * inode pointer and offsets are distributed (ie, we
5978 * roughly know which bits are "significant")
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)
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);
5991 #define page_hash(inode,offset) (page_hash_table+_page_hashfn(inode,offset))
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)
6000 if (page->inode != inode)
6002 - if (page->offset == offset)
6003 + if (pgoff2ulong(page->index) == pgoff2ulong(index))
6006 /* Found the page. */
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)
6014 - return __find_page(inode, offset, *page_hash(inode, offset));
6015 + return __find_page(inode, poffset, *page_hash(inode, poffset));
6018 static inline void remove_page_from_hash_queue(struct page * page)
6020 page->pprev_hash = p;
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)
6026 - __add_page_to_hash_queue(page, page_hash(inode,offset));
6027 + __add_page_to_hash_queue(page, page_hash(inode,poffset));
6030 static inline void remove_page_from_inode_queue(struct page * page)
6032 __wait_on_page(page);
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);
6040 typedef int filler_t(void *, struct page*);
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
6046 int keep_capabilities:1;
6047 struct user_struct *user;
6049 - struct rlimit rlim[RLIM_NLIMITS];
6050 + struct rlimit rlim[RLIM_NLIMITS];
6051 unsigned short used_math;
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
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
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 */
6081 extern inline unsigned long in_swap_cache(struct page *page)
6083 if (PageSwapCache(page))
6084 - return page->offset;
6085 + return pgoff2ulong(page->index);
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))
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
6103 __u8 i_symlink[4*15];
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
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' */
6126 #define do_div(n,base) ({ \
6128 -__res = ((unsigned long) n) % (unsigned) base; \
6129 -n = ((unsigned long) n) / (unsigned) base; \
6132 + __res = ((unsigned long) n) % (unsigned) base; \
6133 + n = ((unsigned long) n) / (unsigned) base; \
6136 +#if BITS_PER_LONG < 64
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.
6141 +#define do_ldiv(n, base) \
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; \
6148 + temp = value >> 32; \
6149 + result_div1 = temp/(base); \
6150 + result_mod = temp%(base); \
6152 + temp = (result_mod << 24) | ((value >> 8) & 0xFFFFFF); \
6153 + result_div2 = temp/(base); \
6154 + result_mod = temp%(base); \
6156 + temp = (result_mod << 8) | (value & 0xFF); \
6157 + result_div3 = temp/(base); \
6158 + result_mod = temp%(base);\
6160 + leftover = ((unsigned long long)result_div1 << 32) | \
6161 + ((unsigned long long)result_div2 << 8) | (result_div3); \
6168 +static char * lnumber(char * str, long long num, int base, int size,
6169 + int precision, int type)
6171 + char c,sign,tmp[66];
6172 + const char *digits="0123456789abcdef";
6176 + digits = "0123456789ABCDEF";
6179 + if (base < 2 || base > 36)
6181 + c = (type & ZEROPAD) ? '0' : ' ';
6183 + if (type & SIGN) {
6188 + } else if (type & PLUS) {
6191 + } else if (type & SPACE) {
6196 + if (type & SPECIAL) {
6203 + else while (num != 0)
6204 + tmp[i++] = digits[do_ldiv(num,base)];
6205 + if (i > precision)
6207 + size -= precision;
6208 + if (!(type&(ZEROPAD+LEFT)))
6213 + if (type & SPECIAL) {
6216 + *str++ = digits[33];
6219 + if (!(type & LEFT))
6220 + while (size-- > 0)
6222 + while (i < precision--)
6226 + while (size-- > 0)
6232 static char * number(char * str, long num, int base, int size, int precision
6234 @@ -207,7 +303,10 @@
6235 /* get the conversion qualifier */
6237 if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
6239 + if (*fmt == 'l' && qualifier == 'l')
6246 @@ -290,7 +389,22 @@
6250 - if (qualifier == 'l')
6251 + if (qualifier == 'L') {
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. */
6258 + unsigned long long lnum;
6259 + lnum = va_arg(args, unsigned long long);
6260 + str = lnumber(str, lnum, base, field_width,
6261 + precision, flags);
6264 + num = va_arg(args, unsigned long); /* 64-bit longs..*/
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
6274 * Truncate the page cache at a set offset, removing the pages
6275 * that are beyond that offset (and zeroing out partial pages).
6277 -void truncate_inode_pages(struct inode * inode, unsigned long start)
6278 +void truncate_inode_pages(struct inode * inode, loff_t start)
6284 p = &inode->i_pages;
6285 while ((page = *p) != NULL) {
6286 - unsigned long offset = page->offset;
6287 + loff_t loffset = pgoff2loff(page->index);
6289 /* page wholly truncated - free it */
6290 - if (offset >= start) {
6291 + if (loffset >= start) {
6292 if (PageLocked(page)) {
6295 @@ -105,9 +105,10 @@
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);
6309 * were to be marked referenced..
6311 if (PageSwapCache(page)) {
6312 - if (referenced && swap_count(page->offset) != 1)
6314 + swap_count(pgoff2ulong(page->index)) != 1)
6316 delete_from_swap_cache(page);
6318 @@ -250,11 +252,12 @@
6319 * memory maps. --sct
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)
6325 unsigned long offset, len;
6326 + pgoff_t pgoff = loff2pgoff(pos);
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;
6337 - page = find_page(inode, pos);
6338 + page = find_page(inode, pgoff);
6340 char *dest = (char*) (offset + page_address(page));
6342 @@ -282,19 +285,20 @@
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)
6349 update_vm_cache_conditional(inode, pos, buf, count, 0);
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,
6358 + struct page **hash)
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);
6367 @@ -305,29 +309,32 @@
6368 * this is all overlapped with the IO on the previous page finishing anyway)
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)
6374 struct inode *inode = file->f_dentry->d_inode;
6375 - struct page * page;
6376 - struct page ** hash;
6379 - offset &= PAGE_CACHE_MASK;
6380 - switch (page_cache) {
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));
6386 + if (!page_cache) {
6387 page_cache = page_cache_alloc();
6391 - if (offset >= inode->i_size)
6393 - hash = page_hash(inode, offset);
6394 - page = __find_page(inode, offset, *hash);
6395 + return 0; /* Can't allocate! */
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);
6405 * Ok, add the new page to the hash-queues...
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);
6413 @@ -381,11 +388,11 @@
6415 #define PROFILE_MAXREADCOUNT 1000
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;
6428 static void profile_readahead(int async, struct file *filp)
6430 @@ -493,13 +500,13 @@
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)
6437 - unsigned long max_ahead, ahead;
6438 - unsigned long raend;
6439 + loff_t max_ahead, ahead;
6441 int max_readahead = get_max_readahead(inode);
6443 - raend = filp->f_raend & PAGE_CACHE_MASK;
6444 + raend = filp->f_raend & PAGE_CACHE_MASK_loff;
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),
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;
6464 int max_readahead = get_max_readahead(inode);
6469 - pgpos = pos & PAGE_CACHE_MASK;
6470 + posp = pos & PAGE_CACHE_MASK_loff;
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
6475 * otherwise, we assume that the file accesses are sequential enough to
6476 * continue read-ahead.
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) {
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.
6487 - if (pos + desc->count <= (PAGE_CACHE_SIZE >> 1)) {
6488 + if (pos + desc->count <= (loff_t)(PAGE_CACHE_SIZE >> 1)) {
6491 - unsigned long needed;
6494 - needed = ((pos + desc->count) & PAGE_CACHE_MASK) - pgpos;
6495 + needed = ((pos + desc->count) & PAGE_CACHE_MASK) - posp;
6497 if (filp->f_ramax < needed)
6498 filp->f_ramax = needed;
6502 struct page *page, **hash;
6505 if (pos >= inode->i_size)
6509 * Try to find the data in the page cache..
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);
6517 goto no_cached_page;
6520 * the page has been rewritten.
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;
6529 flush_dcache_page(page_address(page));
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;
6541 page = page_cache_entry(page_cache);
6543 - add_to_page_cache(page, inode, pos & PAGE_CACHE_MASK, hash);
6544 + add_to_page_cache(page, inode, pgoff, hash);
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)
6552 + struct inode *inode = filp->f_dentry->d_inode;
6554 + if (((ssize_t) count) < 0)
6558 if (access_ok(VERIFY_WRITE, buf, count)) {
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;
6573 read_descriptor_t desc;
6576 struct file * in_file, * out_file;
6577 struct inode * in_inode, * out_inode;
6579 + if (((ssize_t) count) < 0)
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;
6591 + pgoff_t pgoff, reada;
6593 struct page * page, **hash;
6594 unsigned long old_page, new_page;
6597 - offset = (address & PAGE_MASK) - area->vm_start + area->vm_offset;
6598 + offset = ((loff_t)((address & PAGE_MASK) - area->vm_start) +
6601 if (offset >= inode->i_size && (area->vm_flags & VM_SHARED) && area->vm_mm == current->mm)
6605 * Do we have something in the page cache already?
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);
6613 goto no_cached_page;
6615 @@ -1052,11 +1085,12 @@
6617 * Try to read in an entire cluster at once.
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));
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);
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.
6636 - page = find_page(inode, offset);
6637 + page = find_page(inode, pgoff);
6641 @@ -1079,7 +1113,7 @@
6643 page = page_cache_entry(new_page);
6645 - add_to_page_cache(page, inode, offset, hash);
6646 + add_to_page_cache(page, inode, pgoff, hash);
6648 if (inode->i_op->readpage(file, page) != 0)
6650 @@ -1128,10 +1162,10 @@
6651 * if the disk is full.
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)
6658 - unsigned long size;
6660 loff_t loff = offset;
6661 mm_segment_t old_fs;
6663 @@ -1155,7 +1189,7 @@
6666 static int filemap_write_page(struct vm_area_struct * vma,
6667 - unsigned long offset,
6672 @@ -1189,7 +1223,7 @@
6674 int filemap_swapout(struct vm_area_struct * vma, struct page * page)
6676 - return filemap_write_page(vma, page->offset, page_address(page));
6677 + return filemap_write_page(vma, pgoff2loff(page->index), page_address(page));
6680 static inline int filemap_sync_pte(pte_t * ptep, struct vm_area_struct *vma,
6681 @@ -1553,7 +1587,7 @@
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 @@
6694 + if (((ssize_t) count) < 0)
6697 sync = file->f_flags & O_SYNC;
6700 @@ -1579,31 +1616,39 @@
6701 * Check whether we've reached the file size limit.
6704 - if (pos >= limit) {
6705 + if (limit != RLIM_INFINITY && pos >= limit) {
6706 send_sig(SIGXFSZ, current, 0);
6711 + if (!(file->f_flags & O_LARGEFILE) &&
6712 + S_ISREG(inode->i_mode) && count) {
6713 + if (pos >= 0x7fffffff) /* pos@2G forbidden */
6716 + if (pos + count > 0x7fffffff)
6717 + count = 0x7fffffff - pos;
6722 * Check whether to truncate the write,
6723 * and send the signal if we do.
6725 - if (count > limit - pos) {
6726 - send_sig(SIGXFSZ, current, 0);
6727 + if (limit != RLIM_INFINITY && count > limit - pos)
6728 count = limit - pos;
6732 - unsigned long bytes, pgpos, offset;
6733 + unsigned long bytes, offset;
6734 + pgoff_t pgpos = loff2pgoff(pos);
6738 * Try to find the page in the cache. If it isn't there,
6739 * allocate a free page.
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;
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.
6751 -unsigned long get_cached_page(struct inode * inode, unsigned long offset,
6753 +unsigned long get_cached_page(struct inode * inode, pgoff_t pgoff, int new)
6756 struct page ** hash;
6757 unsigned long page_cache = 0;
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);
6766 @@ -1698,7 +1742,7 @@
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);
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
6780 if (!PageSwapCache(page_map))
6782 - if (swap_count(page_map->offset) != 1)
6783 + if (swap_count(pgoff2ulong(page_map->index)) != 1)
6785 delete_from_swap_cache(page_map);
6788 * between the file and the memory map for a potential last
6789 * incomplete page. Ugly, but necessary.
6791 -void vmtruncate(struct inode * inode, unsigned long offset)
6792 +void vmtruncate(struct inode * inode, loff_t offset)
6794 truncate_inode_pages(inode, offset);
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 @@
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)
6809 + unsigned long ret = -EINVAL;
6810 + if ((offset + PAGE_ALIGN(len)) < offset)
6812 + if (!(offset & ~PAGE_MASK))
6813 + ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
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)
6821 struct mm_struct * mm = current->mm;
6822 struct vm_area_struct * vma;
6823 + loff_t off = (loff_t)pg_off << PAGE_SHIFT;
6826 if (file && (!file->f_op || !file->f_op->mmap))
6828 * the offsets must be contiguous..
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)
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
6841 add_mem_queue(area, list(map_nr));
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;
6851 page = mem_map + map_nr;
6852 list_add((struct list_head *) page, ¤t->local_pages);
6853 - page->offset = order;
6854 + page->index = order;
6855 current->nr_local_pages++;
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
6862 * as if it were: we are not allowed to manipulate the inode
6863 * hashing for locked pages.
6865 - if (page->offset != entry) {
6866 + if (pgoff2ulong(page->index) != entry) {
6867 printk ("swap entry mismatch");
6871 printk("VM: swap page is not in swap cache\n");
6874 - if (page->offset != entry) {
6875 - printk ("swap entry mismatch");
6876 + if (pgoff2ulong(page->index) != entry) {
6877 + printk ("VM: swap entry mismatch");
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");
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);
6894 clear_bit(PG_swap_cache, &page->flags);
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
6901 if (PageTestandSetSwapCache(page)) {
6902 printk(KERN_ERR "swap_cache: replacing non-empty entry %08lx "
6904 - page->offset, page_address(page));
6905 + pgoff2ulong(page->index), page_address(page));
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);
6922 void delete_from_swap_cache(struct page *page)
6924 - long entry = page->offset;
6925 + long entry = pgoff2ulong(page->index);
6927 #ifdef SWAP_CACHE_INFO
6928 swap_cache_del_total++;
6930 swap_cache_find_total++;
6933 - found = find_page(&swapper_inode, entry);
6934 + found = find_page(&swapper_inode, ulong2pgoff(entry));
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
6942 * memory, and we should just continue our scan.
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));