diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-11-30 17:37:04 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-11 06:44:29 -0500 |
commit | f8b7256096a20436f6d0926747e3ac3d64c81d24 (patch) | |
tree | 18bcabd1de263bd2d0f8d6b763bde8b037716c5c /arch/s390 | |
parent | 0067bd8a55862ac9dd212bd1c4f6f5bff1ca1301 (diff) |
Unify sys_mmap*
New helper - sys_mmap_pgoff(); switch syscalls to using it.
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/kernel/compat_linux.c | 32 | ||||
-rw-r--r-- | arch/s390/kernel/sys_s390.c | 30 |
2 files changed, 5 insertions, 57 deletions
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c index 11556aa6bf17..22c9e557bb22 100644 --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c | |||
@@ -624,33 +624,6 @@ struct mmap_arg_struct_emu31 { | |||
624 | u32 offset; | 624 | u32 offset; |
625 | }; | 625 | }; |
626 | 626 | ||
627 | /* common code for old and new mmaps */ | ||
628 | static inline long do_mmap2( | ||
629 | unsigned long addr, unsigned long len, | ||
630 | unsigned long prot, unsigned long flags, | ||
631 | unsigned long fd, unsigned long pgoff) | ||
632 | { | ||
633 | struct file * file = NULL; | ||
634 | unsigned long error = -EBADF; | ||
635 | |||
636 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
637 | if (!(flags & MAP_ANONYMOUS)) { | ||
638 | file = fget(fd); | ||
639 | if (!file) | ||
640 | goto out; | ||
641 | } | ||
642 | |||
643 | down_write(¤t->mm->mmap_sem); | ||
644 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
645 | up_write(¤t->mm->mmap_sem); | ||
646 | |||
647 | if (file) | ||
648 | fput(file); | ||
649 | out: | ||
650 | return error; | ||
651 | } | ||
652 | |||
653 | |||
654 | asmlinkage unsigned long | 627 | asmlinkage unsigned long |
655 | old32_mmap(struct mmap_arg_struct_emu31 __user *arg) | 628 | old32_mmap(struct mmap_arg_struct_emu31 __user *arg) |
656 | { | 629 | { |
@@ -664,7 +637,8 @@ old32_mmap(struct mmap_arg_struct_emu31 __user *arg) | |||
664 | if (a.offset & ~PAGE_MASK) | 637 | if (a.offset & ~PAGE_MASK) |
665 | goto out; | 638 | goto out; |
666 | 639 | ||
667 | error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); | 640 | error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, |
641 | a.offset >> PAGE_SHIFT); | ||
668 | out: | 642 | out: |
669 | return error; | 643 | return error; |
670 | } | 644 | } |
@@ -677,7 +651,7 @@ sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg) | |||
677 | 651 | ||
678 | if (copy_from_user(&a, arg, sizeof(a))) | 652 | if (copy_from_user(&a, arg, sizeof(a))) |
679 | goto out; | 653 | goto out; |
680 | error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); | 654 | error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); |
681 | out: | 655 | out: |
682 | return error; | 656 | return error; |
683 | } | 657 | } |
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c index e9d94f61d500..86a74c9c9e63 100644 --- a/arch/s390/kernel/sys_s390.c +++ b/arch/s390/kernel/sys_s390.c | |||
@@ -32,32 +32,6 @@ | |||
32 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
33 | #include "entry.h" | 33 | #include "entry.h" |
34 | 34 | ||
35 | /* common code for old and new mmaps */ | ||
36 | static inline long do_mmap2( | ||
37 | unsigned long addr, unsigned long len, | ||
38 | unsigned long prot, unsigned long flags, | ||
39 | unsigned long fd, unsigned long pgoff) | ||
40 | { | ||
41 | long error = -EBADF; | ||
42 | struct file * file = NULL; | ||
43 | |||
44 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
45 | if (!(flags & MAP_ANONYMOUS)) { | ||
46 | file = fget(fd); | ||
47 | if (!file) | ||
48 | goto out; | ||
49 | } | ||
50 | |||
51 | down_write(¤t->mm->mmap_sem); | ||
52 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
53 | up_write(¤t->mm->mmap_sem); | ||
54 | |||
55 | if (file) | ||
56 | fput(file); | ||
57 | out: | ||
58 | return error; | ||
59 | } | ||
60 | |||
61 | /* | 35 | /* |
62 | * Perform the select(nd, in, out, ex, tv) and mmap() system | 36 | * Perform the select(nd, in, out, ex, tv) and mmap() system |
63 | * calls. Linux for S/390 isn't able to handle more than 5 | 37 | * calls. Linux for S/390 isn't able to handle more than 5 |
@@ -81,7 +55,7 @@ SYSCALL_DEFINE1(mmap2, struct mmap_arg_struct __user *, arg) | |||
81 | 55 | ||
82 | if (copy_from_user(&a, arg, sizeof(a))) | 56 | if (copy_from_user(&a, arg, sizeof(a))) |
83 | goto out; | 57 | goto out; |
84 | error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); | 58 | error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); |
85 | out: | 59 | out: |
86 | return error; | 60 | return error; |
87 | } | 61 | } |
@@ -98,7 +72,7 @@ SYSCALL_DEFINE1(s390_old_mmap, struct mmap_arg_struct __user *, arg) | |||
98 | if (a.offset & ~PAGE_MASK) | 72 | if (a.offset & ~PAGE_MASK) |
99 | goto out; | 73 | goto out; |
100 | 74 | ||
101 | error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); | 75 | error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); |
102 | out: | 76 | out: |
103 | return error; | 77 | return error; |
104 | } | 78 | } |