mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 12:16:41 +00:00
fs/adfs: inode: fix adfs_mode2atts()
Fix adfs_mode2atts() to actually update the file permissions on the media rather than using the current inode mode. Note also that directories do not have read/write permissions stored on the media. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
eeeb9dd98e
commit
81916245ce
@ -126,29 +126,29 @@ adfs_atts2mode(struct super_block *sb, struct inode *inode)
|
|||||||
* Convert Linux permission to ADFS attribute. We try to do the reverse
|
* Convert Linux permission to ADFS attribute. We try to do the reverse
|
||||||
* of atts2mode, but there is not a 1:1 translation.
|
* of atts2mode, but there is not a 1:1 translation.
|
||||||
*/
|
*/
|
||||||
static int
|
static int adfs_mode2atts(struct super_block *sb, struct inode *inode,
|
||||||
adfs_mode2atts(struct super_block *sb, struct inode *inode)
|
umode_t ia_mode)
|
||||||
{
|
{
|
||||||
|
struct adfs_sb_info *asb = ADFS_SB(sb);
|
||||||
umode_t mode;
|
umode_t mode;
|
||||||
int attr;
|
int attr;
|
||||||
struct adfs_sb_info *asb = ADFS_SB(sb);
|
|
||||||
|
|
||||||
/* FIXME: should we be able to alter a link? */
|
/* FIXME: should we be able to alter a link? */
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
return ADFS_I(inode)->attr;
|
return ADFS_I(inode)->attr;
|
||||||
|
|
||||||
|
/* Directories do not have read/write permissions on the media */
|
||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
attr = ADFS_NDA_DIRECTORY;
|
return ADFS_NDA_DIRECTORY;
|
||||||
else
|
|
||||||
attr = 0;
|
|
||||||
|
|
||||||
mode = inode->i_mode & asb->s_owner_mask;
|
attr = 0;
|
||||||
|
mode = ia_mode & asb->s_owner_mask;
|
||||||
if (mode & S_IRUGO)
|
if (mode & S_IRUGO)
|
||||||
attr |= ADFS_NDA_OWNER_READ;
|
attr |= ADFS_NDA_OWNER_READ;
|
||||||
if (mode & S_IWUGO)
|
if (mode & S_IWUGO)
|
||||||
attr |= ADFS_NDA_OWNER_WRITE;
|
attr |= ADFS_NDA_OWNER_WRITE;
|
||||||
|
|
||||||
mode = inode->i_mode & asb->s_other_mask;
|
mode = ia_mode & asb->s_other_mask;
|
||||||
mode &= ~asb->s_owner_mask;
|
mode &= ~asb->s_owner_mask;
|
||||||
if (mode & S_IRUGO)
|
if (mode & S_IRUGO)
|
||||||
attr |= ADFS_NDA_PUBLIC_READ;
|
attr |= ADFS_NDA_PUBLIC_READ;
|
||||||
@ -328,7 +328,7 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
|
|||||||
if (ia_valid & ATTR_CTIME)
|
if (ia_valid & ATTR_CTIME)
|
||||||
inode->i_ctime = attr->ia_ctime;
|
inode->i_ctime = attr->ia_ctime;
|
||||||
if (ia_valid & ATTR_MODE) {
|
if (ia_valid & ATTR_MODE) {
|
||||||
ADFS_I(inode)->attr = adfs_mode2atts(sb, inode);
|
ADFS_I(inode)->attr = adfs_mode2atts(sb, inode, attr->ia_mode);
|
||||||
inode->i_mode = adfs_atts2mode(sb, inode);
|
inode->i_mode = adfs_atts2mode(sb, inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user