Add generic sys_ipc wrapper
[safe/jmp/linux-2.6] / arch / mips / kernel / syscall.c
index fe0d798..257bf01 100644 (file)
@@ -93,7 +93,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
                 * We do not accept a shared mapping if it would violate
                 * cache aliasing constraints.
                 */
-               if ((flags & MAP_SHARED) && (addr & shm_align_mask))
+               if ((flags & MAP_SHARED) &&
+                   ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask))
                        return -EINVAL;
                return addr;
        }
@@ -129,31 +130,6 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
        }
 }
 
-/* common code for old and new mmaps */
-static inline unsigned long
-do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
-        unsigned long flags, unsigned long fd, unsigned long pgoff)
-{
-       unsigned long error = -EBADF;
-       struct file * file = NULL;
-
-       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
-       if (!(flags & MAP_ANONYMOUS)) {
-               file = fget(fd);
-               if (!file)
-                       goto out;
-       }
-
-       down_write(&current->mm->mmap_sem);
-       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
-       up_write(&current->mm->mmap_sem);
-
-       if (file)
-               fput(file);
-out:
-       return error;
-}
-
 SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len,
        unsigned long, prot, unsigned long, flags, unsigned long,
        fd, off_t, offset)
@@ -164,7 +140,7 @@ SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len,
        if (offset & ~PAGE_MASK)
                goto out;
 
-       result = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
+       result = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
 
 out:
        return result;
@@ -177,7 +153,7 @@ SYSCALL_DEFINE6(mips_mmap2, unsigned long, addr, unsigned long, len,
        if (pgoff & (~PAGE_MASK >> 12))
                return -EINVAL;
 
-       return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12));
+       return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12));
 }
 
 save_static_function(sys_fork);
@@ -431,94 +407,6 @@ _sys_sysmips(nabi_no_regargs struct pt_regs regs)
 }
 
 /*
- * sys_ipc() is the de-multiplexer for the SysV IPC calls..
- *
- * This is really horribly ugly.
- */
-SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, int, second,
-       unsigned long, third, void __user *, ptr, long, fifth)
-{
-       int version, ret;
-
-       version = call >> 16; /* hack for backward compatibility */
-       call &= 0xffff;
-
-       switch (call) {
-       case SEMOP:
-               return sys_semtimedop(first, (struct sembuf __user *)ptr,
-                                     second, NULL);
-       case SEMTIMEDOP:
-               return sys_semtimedop(first, (struct sembuf __user *)ptr,
-                                     second,
-                                     (const struct timespec __user *)fifth);
-       case SEMGET:
-               return sys_semget(first, second, third);
-       case SEMCTL: {
-               union semun fourth;
-               if (!ptr)
-                       return -EINVAL;
-               if (get_user(fourth.__pad, (void __user *__user *) ptr))
-                       return -EFAULT;
-               return sys_semctl(first, second, third, fourth);
-       }
-
-       case MSGSND:
-               return sys_msgsnd(first, (struct msgbuf __user *) ptr,
-                                 second, third);
-       case MSGRCV:
-               switch (version) {
-               case 0: {
-                       struct ipc_kludge tmp;
-                       if (!ptr)
-                               return -EINVAL;
-
-                       if (copy_from_user(&tmp,
-                                          (struct ipc_kludge __user *) ptr,
-                                          sizeof(tmp)))
-                               return -EFAULT;
-                       return sys_msgrcv(first, tmp.msgp, second,
-                                         tmp.msgtyp, third);
-               }
-               default:
-                       return sys_msgrcv(first,
-                                         (struct msgbuf __user *) ptr,
-                                         second, fifth, third);
-               }
-       case MSGGET:
-               return sys_msgget((key_t) first, second);
-       case MSGCTL:
-               return sys_msgctl(first, second,
-                                 (struct msqid_ds __user *) ptr);
-
-       case SHMAT:
-               switch (version) {
-               default: {
-                       unsigned long raddr;
-                       ret = do_shmat(first, (char __user *) ptr, second,
-                                      &raddr);
-                       if (ret)
-                               return ret;
-                       return put_user(raddr, (unsigned long __user *) third);
-               }
-               case 1: /* iBCS2 emulator entry point */
-                       if (!segment_eq(get_fs(), get_ds()))
-                               return -EINVAL;
-                       return do_shmat(first, (char __user *) ptr, second,
-                                       (unsigned long *) third);
-               }
-       case SHMDT:
-               return sys_shmdt((char __user *)ptr);
-       case SHMGET:
-               return sys_shmget(first, second, third);
-       case SHMCTL:
-               return sys_shmctl(first, second,
-                                 (struct shmid_ds __user *) ptr);
-       default:
-               return -ENOSYS;
-       }
-}
-
-/*
  * No implemented yet ...
  */
 SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op)