* Description of open_to_namei_flags()?
@ 2009-02-12 3:10 Tetsuo Handa
2009-02-12 3:28 ` Al Viro
0 siblings, 1 reply; 2+ messages in thread
From: Tetsuo Handa @ 2009-02-12 3:10 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel
Hello.
> /*
> * Note that while the flag value (low two bits) for sys_open means:
> * 00 - read-only
> * 01 - write-only
> * 10 - read-write
> * 11 - special
> * it is changed into
> * 00 - no permissions needed
> * 01 - read-permission
> * 10 - write-permission
> * 11 - read-write
> * for the internal routines (ie open_namei()/follow_link() etc)
> * This is more logical, and also allows the 00 "no perm needed"
> * to be used for symlinks (where the permissions are checked
> * later).
> *
> */
> 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.
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?
Regards.
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Description of open_to_namei_flags()?
2009-02-12 3:10 Description of open_to_namei_flags()? Tetsuo Handa
@ 2009-02-12 3:28 ` Al Viro
0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2009-02-12 3:28 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: linux-fsdevel, linux-kernel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-12 3:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-12 3:10 Description of open_to_namei_flags()? Tetsuo Handa
2009-02-12 3:28 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox