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/sparc | |
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/sparc')
-rw-r--r-- | arch/sparc/kernel/sys_sparc_32.c | 31 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sparc_64.c | 22 |
2 files changed, 10 insertions, 43 deletions
diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c index 10c43bea32c7..36f6f26d9cec 100644 --- a/arch/sparc/kernel/sys_sparc_32.c +++ b/arch/sparc/kernel/sys_sparc_32.c | |||
@@ -234,31 +234,6 @@ int sparc_mmap_check(unsigned long addr, unsigned long len) | |||
234 | } | 234 | } |
235 | 235 | ||
236 | /* Linux version of mmap */ | 236 | /* Linux version of mmap */ |
237 | static unsigned long do_mmap2(unsigned long addr, unsigned long len, | ||
238 | unsigned long prot, unsigned long flags, unsigned long fd, | ||
239 | unsigned long pgoff) | ||
240 | { | ||
241 | struct file * file = NULL; | ||
242 | unsigned long retval = -EBADF; | ||
243 | |||
244 | if (!(flags & MAP_ANONYMOUS)) { | ||
245 | file = fget(fd); | ||
246 | if (!file) | ||
247 | goto out; | ||
248 | } | ||
249 | |||
250 | len = PAGE_ALIGN(len); | ||
251 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
252 | |||
253 | down_write(¤t->mm->mmap_sem); | ||
254 | retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
255 | up_write(¤t->mm->mmap_sem); | ||
256 | |||
257 | if (file) | ||
258 | fput(file); | ||
259 | out: | ||
260 | return retval; | ||
261 | } | ||
262 | 237 | ||
263 | asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, | 238 | asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, |
264 | unsigned long prot, unsigned long flags, unsigned long fd, | 239 | unsigned long prot, unsigned long flags, unsigned long fd, |
@@ -266,14 +241,16 @@ asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, | |||
266 | { | 241 | { |
267 | /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE | 242 | /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE |
268 | we have. */ | 243 | we have. */ |
269 | return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12)); | 244 | return sys_mmap_pgoff(addr, len, prot, flags, fd, |
245 | pgoff >> (PAGE_SHIFT - 12)); | ||
270 | } | 246 | } |
271 | 247 | ||
272 | asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len, | 248 | asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len, |
273 | unsigned long prot, unsigned long flags, unsigned long fd, | 249 | unsigned long prot, unsigned long flags, unsigned long fd, |
274 | unsigned long off) | 250 | unsigned long off) |
275 | { | 251 | { |
276 | return do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT); | 252 | /* no alignment check? */ |
253 | return sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); | ||
277 | } | 254 | } |
278 | 255 | ||
279 | long sparc_remap_file_pages(unsigned long start, unsigned long size, | 256 | long sparc_remap_file_pages(unsigned long start, unsigned long size, |
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index d498b32c75f6..8f9cd58497de 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c | |||
@@ -572,23 +572,13 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, | |||
572 | unsigned long, prot, unsigned long, flags, unsigned long, fd, | 572 | unsigned long, prot, unsigned long, flags, unsigned long, fd, |
573 | unsigned long, off) | 573 | unsigned long, off) |
574 | { | 574 | { |
575 | struct file * file = NULL; | 575 | unsigned long retval = -EINVAL; |
576 | unsigned long retval = -EBADF; | ||
577 | 576 | ||
578 | if (!(flags & MAP_ANONYMOUS)) { | 577 | if ((off + PAGE_ALIGN(len)) < off) |
579 | file = fget(fd); | 578 | goto out; |
580 | if (!file) | 579 | if (off & ~PAGE_MASK) |
581 | goto out; | 580 | goto out; |
582 | } | 581 | retval = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); |
583 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
584 | len = PAGE_ALIGN(len); | ||
585 | |||
586 | down_write(¤t->mm->mmap_sem); | ||
587 | retval = do_mmap(file, addr, len, prot, flags, off); | ||
588 | up_write(¤t->mm->mmap_sem); | ||
589 | |||
590 | if (file) | ||
591 | fput(file); | ||
592 | out: | 582 | out: |
593 | return retval; | 583 | return retval; |
594 | } | 584 | } |