Re: Description of open_to_namei_flags()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux