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/frv | |
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/frv')
-rw-r--r-- | arch/frv/kernel/sys_frv.c | 66 |
1 files changed, 2 insertions, 64 deletions
diff --git a/arch/frv/kernel/sys_frv.c b/arch/frv/kernel/sys_frv.c index 2b6b5289cdcc..1d3d4c9e2521 100644 --- a/arch/frv/kernel/sys_frv.c +++ b/arch/frv/kernel/sys_frv.c | |||
@@ -31,9 +31,6 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | |||
31 | unsigned long prot, unsigned long flags, | 31 | unsigned long prot, unsigned long flags, |
32 | unsigned long fd, unsigned long pgoff) | 32 | unsigned long fd, unsigned long pgoff) |
33 | { | 33 | { |
34 | int error = -EBADF; | ||
35 | struct file * file = NULL; | ||
36 | |||
37 | /* As with sparc32, make sure the shift for mmap2 is constant | 34 | /* As with sparc32, make sure the shift for mmap2 is constant |
38 | (12), no matter what PAGE_SIZE we have.... */ | 35 | (12), no matter what PAGE_SIZE we have.... */ |
39 | 36 | ||
@@ -41,69 +38,10 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | |||
41 | trying to map something we can't */ | 38 | trying to map something we can't */ |
42 | if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1)) | 39 | if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1)) |
43 | return -EINVAL; | 40 | return -EINVAL; |
44 | pgoff >>= PAGE_SHIFT - 12; | ||
45 | |||
46 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
47 | if (!(flags & MAP_ANONYMOUS)) { | ||
48 | file = fget(fd); | ||
49 | if (!file) | ||
50 | goto out; | ||
51 | } | ||
52 | |||
53 | down_write(¤t->mm->mmap_sem); | ||
54 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
55 | up_write(¤t->mm->mmap_sem); | ||
56 | |||
57 | if (file) | ||
58 | fput(file); | ||
59 | out: | ||
60 | return error; | ||
61 | } | ||
62 | |||
63 | #if 0 /* DAVIDM - do we want this */ | ||
64 | struct mmap_arg_struct64 { | ||
65 | __u32 addr; | ||
66 | __u32 len; | ||
67 | __u32 prot; | ||
68 | __u32 flags; | ||
69 | __u64 offset; /* 64 bits */ | ||
70 | __u32 fd; | ||
71 | }; | ||
72 | |||
73 | asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg) | ||
74 | { | ||
75 | int error = -EFAULT; | ||
76 | struct file * file = NULL; | ||
77 | struct mmap_arg_struct64 a; | ||
78 | unsigned long pgoff; | ||
79 | |||
80 | if (copy_from_user(&a, arg, sizeof(a))) | ||
81 | return -EFAULT; | ||
82 | |||
83 | if ((long)a.offset & ~PAGE_MASK) | ||
84 | return -EINVAL; | ||
85 | |||
86 | pgoff = a.offset >> PAGE_SHIFT; | ||
87 | if ((a.offset >> PAGE_SHIFT) != pgoff) | ||
88 | return -EINVAL; | ||
89 | |||
90 | if (!(a.flags & MAP_ANONYMOUS)) { | ||
91 | error = -EBADF; | ||
92 | file = fget(a.fd); | ||
93 | if (!file) | ||
94 | goto out; | ||
95 | } | ||
96 | a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
97 | 41 | ||
98 | down_write(¤t->mm->mmap_sem); | 42 | return sys_mmap_pgoff(addr, len, prot, flags, fd, |
99 | error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff); | 43 | pgoff >> (PAGE_SHIFT - 12)); |
100 | up_write(¤t->mm->mmap_sem); | ||
101 | if (file) | ||
102 | fput(file); | ||
103 | out: | ||
104 | return error; | ||
105 | } | 44 | } |
106 | #endif | ||
107 | 45 | ||
108 | /* | 46 | /* |
109 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. | 47 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. |