From: Eric Dumazet <eric.dumazet@gmail.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Alex Davis <alex14641@yahoo.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: Possible coding issue in udf??
Date: Sun, 15 May 2011 18:29:50 +0200 [thread overview]
Message-ID: <1305476990.3120.154.camel@edumazet-laptop> (raw)
In-Reply-To: <m2k4dsnghx.fsf@firstfloor.org>
Le dimanche 15 mai 2011 à 08:14 -0700, Andi Kleen a écrit :
> Alex Davis <alex14641@yahoo.com> writes:
>
> > In fs/udf/inode.c, line 1455, linux 2.6.35, there is the following code:
> >
> > udfperms = ((inode->i_mode & S_IRWXO)) |
> > ((inode->i_mode & S_IRWXG) << 2) |
> > ((inode->i_mode & S_IRWXU) << 4);
> >
> > Shouldn't we be shifting by 3 bits? i.e:
> > udfperms = ((inode->i_mode & S_IRWXO)) |
> > ((inode->i_mode & S_IRWXG) << 3) |
> > ((inode->i_mode & S_IRWXU) << 6);
> >
> > The S_I.. constants are all defined in include/linux/stat.h as 3-bit values.
> >
> > I will send a patch if needed.
>
> I would suggest you test it first. Put in a UDF disk that triggers
> this case (verify with a printk). Check in ls -l if the
> permissions are correct or wrong.
Well, no need to test ;)
Existing code is fine AFAIK.
fs/udf/ecma_167.h
/* Permissions (ECMA 167r3 4/14.9.5) */
#define FE_PERM_O_EXEC 0x00000001U
#define FE_PERM_O_WRITE 0x00000002U
#define FE_PERM_O_READ 0x00000004U
#define FE_PERM_O_CHATTR 0x00000008U
#define FE_PERM_O_DELETE 0x00000010U
#define FE_PERM_G_EXEC 0x00000020U
#define FE_PERM_G_WRITE 0x00000040U
#define FE_PERM_G_READ 0x00000080U
#define FE_PERM_G_CHATTR 0x00000100U
#define FE_PERM_G_DELETE 0x00000200U
#define FE_PERM_U_EXEC 0x00000400U
#define FE_PERM_U_WRITE 0x00000800U
#define FE_PERM_U_READ 0x00001000U
#define FE_PERM_U_CHATTR 0x00002000U
#define FE_PERM_U_DELETE 0x00004000U
So Other bits (inode->i_mode & S_IRWXO) really maps to
FE_PERM_O_EXEC/WRITE/READ
For Group bits (inode->i_mode & S_IRWXG) we must shift by 2 bits to the
left to make them match FE_PERM_G_EXEC/WRITE/READ (to skip
O_CHATR/O_DELETE)
For Owner/User bits (inode->i_mode & S_IRWXU) we must shift by 4 bits
for same reason.
next prev parent reply other threads:[~2011-05-15 16:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-14 2:57 Alex Davis
2011-05-15 15:14 ` Andi Kleen
2011-05-15 16:29 ` Eric Dumazet [this message]
2011-05-15 16:32 ` Andreas Dilger
2011-05-15 17:15 ` Andreas Schwab
2011-05-15 17:13 ` Andreas Schwab
2011-05-15 18:04 ` Alex Davis
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=1305476990.3120.154.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=alex14641@yahoo.com \
--cc=andi@firstfloor.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®