public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Description of open_to_namei_flags()?
Date: Thu, 12 Feb 2009 03:28:21 +0000	[thread overview]
Message-ID: <20090212032821.GD28946@ZenIV.linux.org.uk> (raw)
In-Reply-To: <200902120310.n1C3AwHL076677@www262.sakura.ne.jp>

On Thu, Feb 12, 2009 at 12:10:58PM +0900, Tetsuo Handa wrote:
> > static inline int open_to_namei_flags(int flag)
> > {
> > 	if ((flag+1) & O_ACCMODE)
> > 		flag++;
> > 	return flag;
> > }
> 
> I noticed that open_to_namei_flags() can't yield
> "00 - no permissions needed" output for "11 - special" input.
> To yield "00 - no permissions needed" output for "11 - special" input,
> I think
> 
>   static inline int open_to_namei_flags(int flag)
>   {
>   	return (flag + 1) & O_ACCMODE;
>   }
> 
> is needed.

No.  Comments are rather misleading; the code is correct.

> sys_open(path, 0) is open for reading.
> sys_open(path, 1) is open for writing.
> sys_open(path, 2) is open for reading and writing.
> What is sys_open(path, 3) for?

open for ioctls only; checks for rw permissions, doesn't allow read or
write calls.  Note that the latter is controlled by ->f_mode, which does
*not* come from open_to_namei_flags() (and is calculated as you suggested).
Results of open_to_namei_flags() are used for permission checks, where
3 -> read|write is correct.

      reply	other threads:[~2009-02-12  3:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-12  3:10 Description of open_to_namei_flags()? Tetsuo Handa
2009-02-12  3:28 ` 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=20090212032821.GD28946@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /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