sys_mn10300.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* MN10300 Weird system calls
  2. *
  3. * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
  4. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/errno.h>
  12. #include <linux/sched.h>
  13. #include <linux/syscalls.h>
  14. #include <linux/mm.h>
  15. #include <linux/smp.h>
  16. #include <linux/sem.h>
  17. #include <linux/msg.h>
  18. #include <linux/shm.h>
  19. #include <linux/stat.h>
  20. #include <linux/mman.h>
  21. #include <linux/file.h>
  22. #include <linux/tty.h>
  23. #include <asm/uaccess.h>
  24. asmlinkage long old_mmap(unsigned long addr, unsigned long len,
  25. unsigned long prot, unsigned long flags,
  26. unsigned long fd, unsigned long offset)
  27. {
  28. if (offset & ~PAGE_MASK)
  29. return -EINVAL;
  30. return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
  31. }
  32. struct sel_arg_struct {
  33. unsigned long n;
  34. fd_set *inp;
  35. fd_set *outp;
  36. fd_set *exp;
  37. struct timeval *tvp;
  38. };
  39. asmlinkage int old_select(struct sel_arg_struct __user *arg)
  40. {
  41. struct sel_arg_struct a;
  42. if (copy_from_user(&a, arg, sizeof(a)))
  43. return -EFAULT;
  44. /* sys_select() does the appropriate kernel locking */
  45. return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
  46. }
  47. /*
  48. * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  49. *
  50. * This is really horribly ugly.
  51. */
  52. asmlinkage long sys_ipc(uint call, int first, int second,
  53. int third, void __user *ptr, long fifth)
  54. {
  55. int version, ret;
  56. version = call >> 16; /* hack for backward compatibility */
  57. call &= 0xffff;
  58. switch (call) {
  59. case SEMOP:
  60. return sys_semtimedop(first, (struct sembuf __user *)ptr,
  61. second, NULL);
  62. case SEMTIMEDOP:
  63. return sys_semtimedop(first, (struct sembuf __user *)ptr,
  64. second,
  65. (const struct timespec __user *)fifth);
  66. case SEMGET:
  67. return sys_semget(first, second, third);
  68. case SEMCTL: {
  69. union semun fourth;
  70. if (!ptr)
  71. return -EINVAL;
  72. if (get_user(fourth.__pad, (void __user * __user *) ptr))
  73. return -EFAULT;
  74. return sys_semctl(first, second, third, fourth);
  75. }
  76. case MSGSND:
  77. return sys_msgsnd(first, (struct msgbuf __user *) ptr,
  78. second, third);
  79. case MSGRCV:
  80. switch (version) {
  81. case 0: {
  82. struct ipc_kludge tmp;
  83. if (!ptr)
  84. return -EINVAL;
  85. if (copy_from_user(&tmp,
  86. (struct ipc_kludge __user *) ptr,
  87. sizeof(tmp)))
  88. return -EFAULT;
  89. return sys_msgrcv(first, tmp.msgp, second,
  90. tmp.msgtyp, third);
  91. }
  92. default:
  93. return sys_msgrcv(first,
  94. (struct msgbuf __user *) ptr,
  95. second, fifth, third);
  96. }
  97. case MSGGET:
  98. return sys_msgget((key_t) first, second);
  99. case MSGCTL:
  100. return sys_msgctl(first, second,
  101. (struct msqid_ds __user *) ptr);
  102. case SHMAT:
  103. switch (version) {
  104. default: {
  105. ulong raddr;
  106. ret = do_shmat(first, (char __user *) ptr, second,
  107. &raddr);
  108. if (ret)
  109. return ret;
  110. return put_user(raddr, (ulong *) third);
  111. }
  112. case 1: /* iBCS2 emulator entry point */
  113. if (!segment_eq(get_fs(), get_ds()))
  114. return -EINVAL;
  115. return do_shmat(first, (char __user *) ptr, second,
  116. (ulong *) third);
  117. }
  118. case SHMDT:
  119. return sys_shmdt((char __user *)ptr);
  120. case SHMGET:
  121. return sys_shmget(first, second, third);
  122. case SHMCTL:
  123. return sys_shmctl(first, second,
  124. (struct shmid_ds __user *) ptr);
  125. default:
  126. return -EINVAL;
  127. }
  128. }