aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-05-30 20:17:35 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-06-01 10:37:18 -0400
commiteb36c5873b96e8c7376768d3906da74aae6e3839 (patch)
tree01c5290ed4c55fea85e0dc3f8d70eeaab44678cf /mm/mmap.c
parentdc982501d9643ab0c117e7d87562857ce234652d (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/mmap.c')
-rw-r--r--mm/mmap.c30
1 files changed, 1 insertions, 29 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 538c905d6d9b..98ef8a6c2cd8 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1102,28 +1102,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1102 return mmap_region(file, addr, len, flags, vm_flags, pgoff); 1102 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
1103} 1103}
1104 1104
1105unsigned long vm_mmap(struct file *file, unsigned long addr,
1106 unsigned long len, unsigned long prot,
1107 unsigned long flag, unsigned long offset)
1108{
1109 unsigned long ret;
1110 struct mm_struct *mm = current->mm;
1111
1112 if (unlikely(offset + PAGE_ALIGN(len) < offset))
1113 return -EINVAL;
1114 if (unlikely(offset & ~PAGE_MASK))
1115 return -EINVAL;
1116
1117 ret = security_mmap_file(file, prot, flag);
1118 if (!ret) {
1119 down_write(&mm->mmap_sem);
1120 ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
1121 up_write(&mm->mmap_sem);
1122 }
1123 return ret;
1124}
1125EXPORT_SYMBOL(vm_mmap);
1126
1127SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, 1105SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
1128 unsigned long, prot, unsigned long, flags, 1106 unsigned long, prot, unsigned long, flags,
1129 unsigned long, fd, unsigned long, pgoff) 1107 unsigned long, fd, unsigned long, pgoff)
@@ -1155,13 +1133,7 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
1155 1133
1156 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 1134 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1157 1135
1158 retval = security_mmap_file(file, prot, flags); 1136 retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1159 if (!retval) {
1160 down_write(&current->mm->mmap_sem);
1161 retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1162 up_write(&current->mm->mmap_sem);
1163 }
1164
1165 if (file) 1137 if (file)
1166 fput(file); 1138 fput(file);
1167out: 1139out: