From: Al Viro <viro@ZenIV.linux.org.uk>
To: liqin.chen@sunplusct.com
Cc: Al Viro <viro@ftp.linux.org.uk>,
linux-arch@vger.kernel.org, linux-arch-owner@vger.kernel.org,
linux-kernel@vger.kernel.org, torvalds@linux-foundation.org
Subject: Re: [PATCH 13/19] Unify sys_mmap*
Date: Tue, 8 Dec 2009 02:43:30 +0000 [thread overview]
Message-ID: <20091208024330.GL14381@ZenIV.linux.org.uk> (raw)
In-Reply-To: <OFB4F0BC92.C5E0A391-ON48257686.000CDDCF-48257686.000E5459@sunplusct.com>
On Tue, Dec 08, 2009 at 10:36:29AM +0800, liqin.chen@sunplusct.com 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(¤t->mm->mmap_sem);
> > - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
> > - up_write(¤t->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.
prev parent reply other threads:[~2009-12-08 2:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-07 3:54 [PATCH 13/19] Unify sys_mmap* Al Viro
2009-12-07 3:54 ` Al Viro
2009-12-07 8:32 ` Geert Uytterhoeven
2009-12-07 15:42 ` Al Viro
2009-12-08 2:36 ` liqin.chen
2009-12-08 2:43 ` Al Viro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091208024330.GL14381@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-arch-owner@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liqin.chen@sunplusct.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).