* 2.6.2: "filp->f_mode & 2..."
@ 2004-02-12 10:04 Ulrich Windl
2004-02-12 11:13 ` viro
2004-02-13 3:32 ` Jamie Lokier
0 siblings, 2 replies; 3+ messages in thread
From: Ulrich Windl @ 2004-02-12 10:04 UTC (permalink / raw)
To: linux-kernel
Hi everybody!
I think there's one thing to change in kernel sources; consider this:
filp->f_mode & 2 || permission(filp->f_dentry->d_inode,2,NULL)
It's obvious to some, likely for others that "2" there really stands for
"002", the good old UNIX write permission. I'd suggest either to write
those permission bits in three-digit-octal, or introduce (maybe just use)
symbolic constants for improved readability.
One could even consider a macro MAY_WRITE(filp):
#define MAY_WRITE(filp) ((filp)->f_mode & WRITE_PERMISSION)
#define WRITE_PERMISSION 002
Regards,
Ulrich
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 2.6.2: "filp->f_mode & 2..."
2004-02-12 10:04 2.6.2: "filp->f_mode & 2..." Ulrich Windl
@ 2004-02-12 11:13 ` viro
2004-02-13 3:32 ` Jamie Lokier
1 sibling, 0 replies; 3+ messages in thread
From: viro @ 2004-02-12 11:13 UTC (permalink / raw)
To: Ulrich Windl; +Cc: linux-kernel
On Thu, Feb 12, 2004 at 11:04:34AM +0100, Ulrich Windl wrote:
> Hi everybody!
>
> I think there's one thing to change in kernel sources; consider this:
> filp->f_mode & 2 || permission(filp->f_dentry->d_inode,2,NULL)
filp->f_mode & FMODE_WRITE
permission(...., MAY_WRITE, ...)
>
> It's obvious to some, likely for others that "2" there really stands for
> "002", the good old UNIX write permission. I'd suggest either to write
> those permission bits in three-digit-octal, or introduce (maybe just use)
> symbolic constants for improved readability.
>
> One could even consider a macro MAY_WRITE(filp):
> #define MAY_WRITE(filp) ((filp)->f_mode & WRITE_PERMISSION)
> #define WRITE_PERMISSION 002
Grep is such a wondeful thing...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 2.6.2: "filp->f_mode & 2..."
2004-02-12 10:04 2.6.2: "filp->f_mode & 2..." Ulrich Windl
2004-02-12 11:13 ` viro
@ 2004-02-13 3:32 ` Jamie Lokier
1 sibling, 0 replies; 3+ messages in thread
From: Jamie Lokier @ 2004-02-13 3:32 UTC (permalink / raw)
To: Ulrich Windl; +Cc: linux-kernel
Ulrich Windl wrote:
> filp->f_mode & 2 || permission(filp->f_dentry->d_inode,2,NULL)
>
> It's obvious to some, likely for others that "2" there really stands for
> "002", the good old UNIX write permission.
That's FMODE_WRITE (= 2). It isn't related at all to the Unix write
permission of 002, as you'll notice FMODE_READ is 1, not 4.
-- Jamie
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-02-13 3:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-12 10:04 2.6.2: "filp->f_mode & 2..." Ulrich Windl
2004-02-12 11:13 ` viro
2004-02-13 3:32 ` Jamie Lokier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®