diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 20:13:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 20:29:13 -0400 |
commit | 6be5ceb02e98eaf6cfc4f8b12a896d04023f340d (patch) | |
tree | f34de1392300bbf63549f4eeb20f7606d6f7b1f9 /include/linux | |
parent | a46ef99d80817a167477ed1c8b4d90ee0c2e726f (diff) |
VM: add "vm_mmap()" helper function
This continues the theme started with vm_brk() and vm_munmap():
vm_mmap() does the same thing as do_mmap(), but additionally does the
required VM locking.
This uninlines (and rewrites it to be clearer) do_mmap(), which sadly
duplicates it in mm/mmap.c and mm/nommu.c. But that way we don't have
to export our internal do_mmap_pgoff() function.
Some day we hopefully don't have to export do_mmap() either, if all
modular users can become the simpler vm_mmap() instead. We're actually
very close to that already, with the notable exception of the (broken)
use in i810, and a couple of stragglers in binfmt_elf.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mm.h | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index cb61950a3aa1..86a692c3b238 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1393,31 +1393,20 @@ extern int install_special_mapping(struct mm_struct *mm, | |||
1393 | 1393 | ||
1394 | extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); | 1394 | extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); |
1395 | 1395 | ||
1396 | extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, | ||
1397 | unsigned long len, unsigned long prot, | ||
1398 | unsigned long flag, unsigned long pgoff); | ||
1399 | extern unsigned long mmap_region(struct file *file, unsigned long addr, | 1396 | extern unsigned long mmap_region(struct file *file, unsigned long addr, |
1400 | unsigned long len, unsigned long flags, | 1397 | unsigned long len, unsigned long flags, |
1401 | vm_flags_t vm_flags, unsigned long pgoff); | 1398 | vm_flags_t vm_flags, unsigned long pgoff); |
1402 | 1399 | extern unsigned long do_mmap(struct file *, unsigned long, | |
1403 | static inline unsigned long do_mmap(struct file *file, unsigned long addr, | 1400 | unsigned long, unsigned long, |
1404 | unsigned long len, unsigned long prot, | 1401 | unsigned long, unsigned long); |
1405 | unsigned long flag, unsigned long offset) | ||
1406 | { | ||
1407 | unsigned long ret = -EINVAL; | ||
1408 | if ((offset + PAGE_ALIGN(len)) < offset) | ||
1409 | goto out; | ||
1410 | if (!(offset & ~PAGE_MASK)) | ||
1411 | ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); | ||
1412 | out: | ||
1413 | return ret; | ||
1414 | } | ||
1415 | |||
1416 | extern int do_munmap(struct mm_struct *, unsigned long, size_t); | 1402 | extern int do_munmap(struct mm_struct *, unsigned long, size_t); |
1417 | 1403 | ||
1418 | /* These take the mm semaphore themselves */ | 1404 | /* These take the mm semaphore themselves */ |
1419 | extern unsigned long vm_brk(unsigned long, unsigned long); | 1405 | extern unsigned long vm_brk(unsigned long, unsigned long); |
1420 | extern int vm_munmap(struct mm_struct *, unsigned long, size_t); | 1406 | extern int vm_munmap(struct mm_struct *, unsigned long, size_t); |
1407 | extern unsigned long vm_mmap(struct file *, unsigned long, | ||
1408 | unsigned long, unsigned long, | ||
1409 | unsigned long, unsigned long); | ||
1421 | 1410 | ||
1422 | /* truncate.c */ | 1411 | /* truncate.c */ |
1423 | extern void truncate_inode_pages(struct address_space *, loff_t); | 1412 | extern void truncate_inode_pages(struct address_space *, loff_t); |