diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-05-30 20:17:35 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-01 10:37:18 -0400 |
commit | eb36c5873b96e8c7376768d3906da74aae6e3839 (patch) | |
tree | 01c5290ed4c55fea85e0dc3f8d70eeaab44678cf /mm/util.c | |
parent | dc982501d9643ab0c117e7d87562857ce234652d (diff) |
new helper: vm_mmap_pgoff()
take it to mm/util.c, convert vm_mmap() to use of that one and
take it to mm/util.c as well, convert both sys_mmap_pgoff() to
use of vm_mmap_pgoff()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/util.c')
-rw-r--r-- | mm/util.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/export.h> | 4 | #include <linux/export.h> |
5 | #include <linux/err.h> | 5 | #include <linux/err.h> |
6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
7 | #include <linux/security.h> | ||
7 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
8 | 9 | ||
9 | #include "internal.h" | 10 | #include "internal.h" |
@@ -341,6 +342,35 @@ int __attribute__((weak)) get_user_pages_fast(unsigned long start, | |||
341 | } | 342 | } |
342 | EXPORT_SYMBOL_GPL(get_user_pages_fast); | 343 | EXPORT_SYMBOL_GPL(get_user_pages_fast); |
343 | 344 | ||
345 | unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, | ||
346 | unsigned long len, unsigned long prot, | ||
347 | unsigned long flag, unsigned long pgoff) | ||
348 | { | ||
349 | unsigned long ret; | ||
350 | struct mm_struct *mm = current->mm; | ||
351 | |||
352 | ret = security_mmap_file(file, prot, flag); | ||
353 | if (!ret) { | ||
354 | down_write(&mm->mmap_sem); | ||
355 | ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff); | ||
356 | up_write(&mm->mmap_sem); | ||
357 | } | ||
358 | return ret; | ||
359 | } | ||
360 | |||
361 | unsigned long vm_mmap(struct file *file, unsigned long addr, | ||
362 | unsigned long len, unsigned long prot, | ||
363 | unsigned long flag, unsigned long offset) | ||
364 | { | ||
365 | if (unlikely(offset + PAGE_ALIGN(len) < offset)) | ||
366 | return -EINVAL; | ||
367 | if (unlikely(offset & ~PAGE_MASK)) | ||
368 | return -EINVAL; | ||
369 | |||
370 | return vm_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); | ||
371 | } | ||
372 | EXPORT_SYMBOL(vm_mmap); | ||
373 | |||
344 | /* Tracepoints definitions. */ | 374 | /* Tracepoints definitions. */ |
345 | EXPORT_TRACEPOINT_SYMBOL(kmalloc); | 375 | EXPORT_TRACEPOINT_SYMBOL(kmalloc); |
346 | EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); | 376 | EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); |