Skip to content

Commit

Permalink
kill do_mmap() completely
Browse files Browse the repository at this point in the history
just pull into vm_mmap()

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jun 1, 2012
1 parent e3fc629 commit dc98250
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
16 changes: 5 additions & 11 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,28 +1102,22 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
return mmap_region(file, addr, len, flags, vm_flags, pgoff);
}

static unsigned long do_mmap(struct file *file, unsigned long addr,
unsigned long vm_mmap(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flag, unsigned long offset)
{
unsigned long ret;
struct mm_struct *mm = current->mm;

if (unlikely(offset + PAGE_ALIGN(len) < offset))
return -EINVAL;
if (unlikely(offset & ~PAGE_MASK))
return -EINVAL;
return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
}

unsigned long vm_mmap(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flag, unsigned long offset)
{
unsigned long ret;
struct mm_struct *mm = current->mm;

ret = security_mmap_file(file, prot, flag);
if (!ret) {
down_write(&mm->mmap_sem);
ret = do_mmap(file, addr, len, prot, flag, offset);
ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
up_write(&mm->mmap_sem);
}
return ret;
Expand Down
16 changes: 5 additions & 11 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,28 +1470,22 @@ unsigned long do_mmap_pgoff(struct file *file,
return -ENOMEM;
}

static unsigned long do_mmap(struct file *file, unsigned long addr,
unsigned long vm_mmap(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flag, unsigned long offset)
{
unsigned long ret;
struct mm_struct *mm = current->mm;

if (unlikely(offset + PAGE_ALIGN(len) < offset))
return -EINVAL;
if (unlikely(offset & ~PAGE_MASK))
return -EINVAL;
return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
}

unsigned long vm_mmap(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flag, unsigned long offset)
{
unsigned long ret;
struct mm_struct *mm = current->mm;

ret = security_mmap_file(file, prot, flag);
if (!ret) {
down_write(&mm->mmap_sem);
ret = do_mmap(file, addr, len, prot, flag, offset);
ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
up_write(&mm->mmap_sem);
}
return ret;
Expand Down

0 comments on commit dc98250

Please sign in to comment.