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