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