Re: [PATCH 13/19] Unify sys_mmap*

From: Al Viro
Date: Mon Dec 07 2009 - 21:43:49 EST


On Tue, Dec 08, 2009 at 10:36:29AM +0800, liqin.chen@xxxxxxxxxxxxx wrote:
> > --- a/arch/score/kernel/sys_score.c
> > +++ b/arch/score/kernel/sys_score.c
> > @@ -36,33 +36,18 @@ asmlinkage long
> > sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
> > unsigned long flags, unsigned long fd, unsigned long pgoff)
> > {
> > - int error = -EBADF;
> > - struct file *file = NULL;
> > -
> > if (pgoff & (~PAGE_MASK >> 12))
> > return -EINVAL;
> >
> > - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
> > - if (!(flags & MAP_ANONYMOUS)) {
> > - file = fget(fd);
> > - if (!file)
> > - return error;
> > - }
> > -
> > - down_write(&current->mm->mmap_sem);
> > - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
> > - up_write(&current->mm->mmap_sem);
> > -
> > - if (file)
> > - fput(file);
> > -
> > - return error;
> > + return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
> > + /* sic - almost certainly should shift pgoff as well */
> > }
> >
> > asmlinkage long
> > sys_mmap(unsigned long addr, unsigned long len, unsigned long prot,
> > unsigned long flags, unsigned long fd, off_t pgoff)
> > {
> > + /* where's the alignment check? */
> > return sys_mmap2(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
> > }
> >
>
> It's ok for your update, even
> if (pgoff & (~PAGE_MASK >> 12))
> return -EINVAL;
> code haven't use anymore, you could remove it.

The sys_mmap2() simply disappears - it's exactly the same as sys_mmap_pgoff().
Good.

> In addition, the sys_mmap should like this.
>
> asmlinkage long
> sys_mmap(unsigned long addr, unsigned long len, unsigned long prot,
> unsigned long flags, unsigned long fd, off_t pgoff)
> {
> unsigned long result;
>
> result = -EINVAL;
> if (pgoff & ~PAGE_MASK)
> goto out;
>
> result = sys_mmap2(addr, len, prot, flags, fd, pgoff >>
> PAGE_SHIFT);
> out:
> return result;
> }

s/sys_mmap2/sys_mmap_pgoff/ and for pity sake, s/\<pgoff\>/offset/ ;-)

> Thanks
> liqin

OK, will fold sys_mmap2 replacement with sys_mmap_pgoff into that patch,
adding a missing chech on top of it - I'd rather keep that one an
equivalent transformation.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/