mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 22:51:37 +00:00
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>
This commit is contained in:
parent
a46ef99d80
commit
6be5ceb02e
15 changed files with 87 additions and 97 deletions
|
@ -542,10 +542,8 @@ static int load_flat_file(struct linux_binprm * bprm,
|
|||
*/
|
||||
DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n");
|
||||
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC,
|
||||
textpos = vm_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC,
|
||||
MAP_PRIVATE|MAP_EXECUTABLE, 0);
|
||||
up_write(¤t->mm->mmap_sem);
|
||||
if (!textpos || IS_ERR_VALUE(textpos)) {
|
||||
if (!textpos)
|
||||
textpos = (unsigned long) -ENOMEM;
|
||||
|
@ -556,10 +554,8 @@ static int load_flat_file(struct linux_binprm * bprm,
|
|||
|
||||
len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long);
|
||||
len = PAGE_ALIGN(len);
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
realdatastart = do_mmap(0, 0, len,
|
||||
realdatastart = vm_mmap(0, 0, len,
|
||||
PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
|
||||
up_write(¤t->mm->mmap_sem);
|
||||
|
||||
if (realdatastart == 0 || IS_ERR_VALUE(realdatastart)) {
|
||||
if (!realdatastart)
|
||||
|
@ -603,10 +599,8 @@ static int load_flat_file(struct linux_binprm * bprm,
|
|||
|
||||
len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long);
|
||||
len = PAGE_ALIGN(len);
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
textpos = do_mmap(0, 0, len,
|
||||
textpos = vm_mmap(0, 0, len,
|
||||
PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0);
|
||||
up_write(¤t->mm->mmap_sem);
|
||||
|
||||
if (!textpos || IS_ERR_VALUE(textpos)) {
|
||||
if (!textpos)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue