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/mmap.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/mmap.c')
-rw-r--r-- | mm/mmap.c | 30 |
1 files changed, 1 insertions, 29 deletions
@@ -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 | ||
1105 | unsigned 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 | } | ||
1125 | EXPORT_SYMBOL(vm_mmap); | ||
1126 | |||
1127 | SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, | 1105 | SYSCALL_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(¤t->mm->mmap_sem); | ||
1161 | retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
1162 | up_write(¤t->mm->mmap_sem); | ||
1163 | } | ||
1164 | |||
1165 | if (file) | 1137 | if (file) |
1166 | fput(file); | 1138 | fput(file); |
1167 | out: | 1139 | out: |