sys_parisc32.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * sys_parisc32.c: Conversion between 32bit and 64bit native syscalls.
  3. *
  4. * Copyright (C) 2000-2001 Hewlett Packard Company
  5. * Copyright (C) 2000 John Marvin
  6. * Copyright (C) 2001 Matthew Wilcox
  7. *
  8. * These routines maintain argument size conversion between 32bit and 64bit
  9. * environment. Based heavily on sys_ia32.c and sys_sparc32.c.
  10. */
  11. #include <linux/compat.h>
  12. #include <linux/kernel.h>
  13. #include <linux/sched.h>
  14. #include <linux/fs.h>
  15. #include <linux/mm.h>
  16. #include <linux/file.h>
  17. #include <linux/signal.h>
  18. #include <linux/resource.h>
  19. #include <linux/times.h>
  20. #include <linux/time.h>
  21. #include <linux/smp.h>
  22. #include <linux/sem.h>
  23. #include <linux/shm.h>
  24. #include <linux/slab.h>
  25. #include <linux/uio.h>
  26. #include <linux/ncp_fs.h>
  27. #include <linux/poll.h>
  28. #include <linux/personality.h>
  29. #include <linux/stat.h>
  30. #include <linux/highmem.h>
  31. #include <linux/highuid.h>
  32. #include <linux/mman.h>
  33. #include <linux/binfmts.h>
  34. #include <linux/namei.h>
  35. #include <linux/vfs.h>
  36. #include <linux/ptrace.h>
  37. #include <linux/swap.h>
  38. #include <linux/syscalls.h>
  39. #include <asm/types.h>
  40. #include <asm/uaccess.h>
  41. #include <asm/mmu_context.h>
  42. #include "sys32.h"
  43. #undef DEBUG
  44. #ifdef DEBUG
  45. #define DBG(x) printk x
  46. #else
  47. #define DBG(x)
  48. #endif
  49. asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23,
  50. int r22, int r21, int r20)
  51. {
  52. printk(KERN_ERR "%s(%d): Unimplemented 32 on 64 syscall #%d!\n",
  53. current->comm, current->pid, r20);
  54. return -ENOSYS;
  55. }
  56. asmlinkage long sys32_sched_rr_get_interval(pid_t pid,
  57. struct compat_timespec __user *interval)
  58. {
  59. struct timespec t;
  60. int ret;
  61. KERNEL_SYSCALL(ret, sys_sched_rr_get_interval, pid, (struct timespec __user *)&t);
  62. if (put_compat_timespec(&t, interval))
  63. return -EFAULT;
  64. return ret;
  65. }
  66. asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
  67. {
  68. mm_segment_t old_fs = get_fs();
  69. int ret;
  70. off_t of;
  71. if (offset && get_user(of, offset))
  72. return -EFAULT;
  73. set_fs(KERNEL_DS);
  74. ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, count);
  75. set_fs(old_fs);
  76. if (offset && put_user(of, offset))
  77. return -EFAULT;
  78. return ret;
  79. }
  80. asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
  81. {
  82. mm_segment_t old_fs = get_fs();
  83. int ret;
  84. loff_t lof;
  85. if (offset && get_user(lof, offset))
  86. return -EFAULT;
  87. set_fs(KERNEL_DS);
  88. ret = sys_sendfile64(out_fd, in_fd, offset ? (loff_t __user *)&lof : NULL, count);
  89. set_fs(old_fs);
  90. if (offset && put_user(lof, offset))
  91. return -EFAULT;
  92. return ret;
  93. }
  94. /* lseek() needs a wrapper because 'offset' can be negative, but the top
  95. * half of the argument has been zeroed by syscall.S.
  96. */
  97. asmlinkage int sys32_lseek(unsigned int fd, int offset, unsigned int origin)
  98. {
  99. return sys_lseek(fd, offset, origin);
  100. }
  101. asmlinkage long sys32_semctl(int semid, int semnum, int cmd, union semun arg)
  102. {
  103. union semun u;
  104. if (cmd == SETVAL) {
  105. /* Ugh. arg is a union of int,ptr,ptr,ptr, so is 8 bytes.
  106. * The int should be in the first 4, but our argument
  107. * frobbing has left it in the last 4.
  108. */
  109. u.val = *((int *)&arg + 1);
  110. return sys_semctl (semid, semnum, cmd, u);
  111. }
  112. return sys_semctl (semid, semnum, cmd, arg);
  113. }
  114. long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
  115. size_t len)
  116. {
  117. return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
  118. buf, len);
  119. }
  120. asmlinkage long compat_sys_fanotify_mark(int fan_fd, int flags, u32 mask_hi,
  121. u32 mask_lo, int fd,
  122. const char __user *pathname)
  123. {
  124. return sys_fanotify_mark(fan_fd, flags, ((u64)mask_hi << 32) | mask_lo,
  125. fd, pathname);
  126. }