aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-27 12:30:52 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-27 12:30:52 -0400
commitd96a2a5c6479342229416565944b56bc7a2b1a60 (patch)
treea17556ff042e739973decf0f4d1a21712e409520 /arch
parent50c46637aa894f904e2fb39086a3d7732f68bd50 (diff)
parent81b4b98ae484f11d97b3d5b8e88d916b74055b78 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6: [PARISC] Add NOTES section [PARISC] Use compat_sys_getdents [PARISC] Do not allow STI_CONSOLE to be modular [PARISC] Clean up sti_flush [PARISC] Add dummy isa_(bus|virt)_to_(virt|bus) inlines [PARISC] Add empty <asm-parisc/vga.h>
Diffstat (limited to 'arch')
-rw-r--r--arch/parisc/kernel/sys_parisc32.c141
-rw-r--r--arch/parisc/kernel/syscall_table.S4
-rw-r--r--arch/parisc/kernel/vmlinux.lds.S2
3 files changed, 3 insertions, 144 deletions
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index bb23ff71c28e..2989c6682bf6 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -285,147 +285,6 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
285 return err; 285 return err;
286} 286}
287 287
288struct linux32_dirent {
289 u32 d_ino;
290 compat_off_t d_off;
291 u16 d_reclen;
292 char d_name[1];
293};
294
295struct old_linux32_dirent {
296 u32 d_ino;
297 u32 d_offset;
298 u16 d_namlen;
299 char d_name[1];
300};
301
302struct getdents32_callback {
303 struct linux32_dirent __user * current_dir;
304 struct linux32_dirent __user * previous;
305 int count;
306 int error;
307};
308
309struct readdir32_callback {
310 struct old_linux32_dirent __user * dirent;
311 int count;
312};
313
314#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
315static int filldir32 (void *__buf, const char *name, int namlen,
316 loff_t offset, u64 ino, unsigned int d_type)
317{
318 struct linux32_dirent __user * dirent;
319 struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
320 int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, 4);
321 u32 d_ino;
322
323 buf->error = -EINVAL; /* only used if we fail.. */
324 if (reclen > buf->count)
325 return -EINVAL;
326 d_ino = ino;
327 if (sizeof(d_ino) < sizeof(ino) && d_ino != ino)
328 return -EOVERFLOW;
329 dirent = buf->previous;
330 if (dirent)
331 put_user(offset, &dirent->d_off);
332 dirent = buf->current_dir;
333 buf->previous = dirent;
334 put_user(d_ino, &dirent->d_ino);
335 put_user(reclen, &dirent->d_reclen);
336 copy_to_user(dirent->d_name, name, namlen);
337 put_user(0, dirent->d_name + namlen);
338 dirent = ((void __user *)dirent) + reclen;
339 buf->current_dir = dirent;
340 buf->count -= reclen;
341 return 0;
342}
343
344asmlinkage long
345sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
346{
347 struct file * file;
348 struct linux32_dirent __user * lastdirent;
349 struct getdents32_callback buf;
350 int error;
351
352 error = -EFAULT;
353 if (!access_ok(VERIFY_WRITE, dirent, count))
354 goto out;
355
356 error = -EBADF;
357 file = fget(fd);
358 if (!file)
359 goto out;
360
361 buf.current_dir = (struct linux32_dirent __user *) dirent;
362 buf.previous = NULL;
363 buf.count = count;
364 buf.error = 0;
365
366 error = vfs_readdir(file, filldir32, &buf);
367 if (error < 0)
368 goto out_putf;
369 error = buf.error;
370 lastdirent = buf.previous;
371 if (lastdirent) {
372 if (put_user(file->f_pos, &lastdirent->d_off))
373 error = -EFAULT;
374 else
375 error = count - buf.count;
376 }
377
378out_putf:
379 fput(file);
380out:
381 return error;
382}
383
384static int fillonedir32(void * __buf, const char * name, int namlen,
385 loff_t offset, u64 ino, unsigned int d_type)
386{
387 struct readdir32_callback * buf = (struct readdir32_callback *) __buf;
388 struct old_linux32_dirent __user * dirent;
389 u32 d_ino;
390
391 if (buf->count)
392 return -EINVAL;
393 d_ino = ino;
394 if (sizeof(d_ino) < sizeof(ino) && d_ino != ino)
395 return -EOVERFLOW;
396 buf->count++;
397 dirent = buf->dirent;
398 put_user(d_ino, &dirent->d_ino);
399 put_user(offset, &dirent->d_offset);
400 put_user(namlen, &dirent->d_namlen);
401 copy_to_user(dirent->d_name, name, namlen);
402 put_user(0, dirent->d_name + namlen);
403 return 0;
404}
405
406asmlinkage long
407sys32_readdir (unsigned int fd, void __user * dirent, unsigned int count)
408{
409 int error;
410 struct file * file;
411 struct readdir32_callback buf;
412
413 error = -EBADF;
414 file = fget(fd);
415 if (!file)
416 goto out;
417
418 buf.count = 0;
419 buf.dirent = dirent;
420
421 error = vfs_readdir(file, fillonedir32, &buf);
422 if (error >= 0)
423 error = buf.count;
424 fput(file);
425out:
426 return error;
427}
428
429/*** copied from mips64 ***/ 288/*** copied from mips64 ***/
430/* 289/*
431 * Ooo, nasty. We need here to frob 32-bit unsigned longs to 290 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 627f3c28ad8c..2540786a970f 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -222,9 +222,7 @@
222 ENTRY_SAME(setfsgid) 222 ENTRY_SAME(setfsgid)
223 /* I think this might work */ 223 /* I think this might work */
224 ENTRY_SAME(llseek) /* 140 */ 224 ENTRY_SAME(llseek) /* 140 */
225 /* struct linux_dirent has longs, like 'unsigned long d_ino' which 225 ENTRY_COMP(getdents)
226 * almost definitely should be 'ino_t d_ino' but it's too late now */
227 ENTRY_DIFF(getdents)
228 /* it is POSSIBLE that select will be OK because even though fd_set 226 /* it is POSSIBLE that select will be OK because even though fd_set
229 * contains longs, the macros and sizes are clever. */ 227 * contains longs, the macros and sizes are clever. */
230 ENTRY_COMP(select) 228 ENTRY_COMP(select)
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index d4e6a93c8d9a..ee7a16eb6fdd 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -81,6 +81,8 @@ SECTIONS
81 __ex_table : { *(__ex_table) } 81 __ex_table : { *(__ex_table) }
82 __stop___ex_table = .; 82 __stop___ex_table = .;
83 83
84 NOTES
85
84 __start___unwind = .; /* unwind info */ 86 __start___unwind = .; /* unwind info */
85 .PARISC.unwind : { *(.PARISC.unwind) } 87 .PARISC.unwind : { *(.PARISC.unwind) }
86 __stop___unwind = .; 88 __stop___unwind = .;