Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83371
b: refs/heads/master
c: 19c561a
h: refs/heads/master
i:
  83369: 0e50695
  83367: 5d66adb
v: v3
  • Loading branch information
Jan Engelhardt authored and Linus Torvalds committed Feb 6, 2008
1 parent 9bd27f8 commit a1bead9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 20292bc2c3feaee7f2e93911ffcb692732293894
refs/heads/master: 19c561a60ffe52df88dd63de0bff480ca094efe4
47 changes: 44 additions & 3 deletions trunk/fs/fat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,42 @@ static int fat_cont_expand(struct inode *inode, loff_t size)
return err;
}

static int check_mode(const struct msdos_sb_info *sbi, mode_t mode)
{
mode_t req = mode & ~S_IFMT;

/*
* Of the r and x bits, all (subject to umask) must be present. Of the
* w bits, either all (subject to umask) or none must be present.
*/

if (S_ISREG(mode)) {
req &= ~sbi->options.fs_fmask;

if ((req & (S_IRUGO | S_IXUGO)) !=
((S_IRUGO | S_IXUGO) & ~sbi->options.fs_fmask))
return -EPERM;

if ((req & S_IWUGO) != 0 &&
(req & S_IWUGO) != (S_IWUGO & ~sbi->options.fs_fmask))
return -EPERM;
} else if (S_ISDIR(mode)) {
req &= ~sbi->options.fs_dmask;

if ((req & (S_IRUGO | S_IXUGO)) !=
((S_IRUGO | S_IXUGO) & ~sbi->options.fs_dmask))
return -EPERM;

if ((req & S_IWUGO) != 0 &&
(req & S_IWUGO) != (S_IWUGO & ~sbi->options.fs_dmask))
return -EPERM;
} else {
return -EPERM;
}

return 0;
}

int fat_notify_change(struct dentry *dentry, struct iattr *attr)
{
struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb);
Expand Down Expand Up @@ -186,16 +222,21 @@ int fat_notify_change(struct dentry *dentry, struct iattr *attr)
if (((attr->ia_valid & ATTR_UID) &&
(attr->ia_uid != sbi->options.fs_uid)) ||
((attr->ia_valid & ATTR_GID) &&
(attr->ia_gid != sbi->options.fs_gid)) ||
((attr->ia_valid & ATTR_MODE) &&
(attr->ia_mode & ~MSDOS_VALID_MODE)))
(attr->ia_gid != sbi->options.fs_gid)))
error = -EPERM;

if (error) {
if (sbi->options.quiet)
error = 0;
goto out;
}

if (attr->ia_valid & ATTR_MODE) {
error = check_mode(sbi, attr->ia_mode);
if (error != 0 && !sbi->options.quiet)
goto out;
}

error = inode_setattr(inode, attr);
if (error)
goto out;
Expand Down

0 comments on commit a1bead9

Please sign in to comment.