aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-11-30 17:37:04 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-11 06:44:29 -0500
commitf8b7256096a20436f6d0926747e3ac3d64c81d24 (patch)
tree18bcabd1de263bd2d0f8d6b763bde8b037716c5c /mm
parent0067bd8a55862ac9dd212bd1c4f6f5bff1ca1301 (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 'mm')
-rw-r--r--mm/util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/mm/util.c b/mm/util.c
index 7c35ad95f927..3bf81b294ae8 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -4,6 +4,10 @@
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/err.h> 5#include <linux/err.h>
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/hugetlb.h>
8#include <linux/syscalls.h>
9#include <linux/mman.h>
10#include <linux/file.h>
7#include <asm/uaccess.h> 11#include <asm/uaccess.h>
8 12
9#define CREATE_TRACE_POINTS 13#define CREATE_TRACE_POINTS
@@ -268,6 +272,31 @@ int __attribute__((weak)) get_user_pages_fast(unsigned long start,
268} 272}
269EXPORT_SYMBOL_GPL(get_user_pages_fast); 273EXPORT_SYMBOL_GPL(get_user_pages_fast);
270 274
275SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
276 unsigned long, prot, unsigned long, flags,
277 unsigned long, fd, unsigned long, pgoff)
278{
279 struct file * file = NULL;
280 unsigned long retval = -EBADF;
281
282 if (!(flags & MAP_ANONYMOUS)) {
283 file = fget(fd);
284 if (!file)
285 goto out;
286 }
287
288 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
289
290 down_write(&current->mm->mmap_sem);
291 retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
292 up_write(&current->mm->mmap_sem);
293
294 if (file)
295 fput(file);
296out:
297 return retval;
298}
299
271/* Tracepoints definitions. */ 300/* Tracepoints definitions. */
272EXPORT_TRACEPOINT_SYMBOL(kmalloc); 301EXPORT_TRACEPOINT_SYMBOL(kmalloc);
273EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); 302EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc);