aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/fs.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-08-22 07:39:19 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2007-08-22 07:39:19 -0400
commit9ed437c50d89eabae763dd422579f73fdebf288d (patch)
tree22329b749200798165a8a07fe141e9cbc3b1c733 /fs/jffs2/fs.c
parent09b3fba562ce366312b90a6f71d0b727b4d93ba9 (diff)
[JFFS2] Fix ACL vs. mode handling.
When POSIX ACL support was enabled, we weren't writing correct legacy modes to the medium on inode creation, or when the ACL was set. This meant that the permissions would be incorrect after the file system was remounted. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/fs.c')
-rw-r--r--fs/jffs2/fs.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 1d3b7a9fc828..dd64ddc11d43 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -24,7 +24,7 @@
24 24
25static int jffs2_flash_setup(struct jffs2_sb_info *c); 25static int jffs2_flash_setup(struct jffs2_sb_info *c);
26 26
27static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) 27int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
28{ 28{
29 struct jffs2_full_dnode *old_metadata, *new_metadata; 29 struct jffs2_full_dnode *old_metadata, *new_metadata;
30 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 30 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
@@ -36,10 +36,8 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
36 unsigned int ivalid; 36 unsigned int ivalid;
37 uint32_t alloclen; 37 uint32_t alloclen;
38 int ret; 38 int ret;
39
39 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); 40 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino));
40 ret = inode_change_ok(inode, iattr);
41 if (ret)
42 return ret;
43 41
44 /* Special cases - we don't want more than one data node 42 /* Special cases - we don't want more than one data node
45 for these types on the medium at any time. So setattr 43 for these types on the medium at any time. So setattr
@@ -183,9 +181,14 @@ int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
183{ 181{
184 int rc; 182 int rc;
185 183
184 rc = inode_change_ok(dentry->d_inode, iattr);
185 if (rc)
186 return rc;
187
186 rc = jffs2_do_setattr(dentry->d_inode, iattr); 188 rc = jffs2_do_setattr(dentry->d_inode, iattr);
187 if (!rc && (iattr->ia_valid & ATTR_MODE)) 189 if (!rc && (iattr->ia_valid & ATTR_MODE))
188 rc = jffs2_acl_chmod(dentry->d_inode); 190 rc = jffs2_acl_chmod(dentry->d_inode);
191
189 return rc; 192 return rc;
190} 193}
191 194
@@ -399,7 +402,8 @@ void jffs2_write_super (struct super_block *sb)
399 402
400/* jffs2_new_inode: allocate a new inode and inocache, add it to the hash, 403/* jffs2_new_inode: allocate a new inode and inocache, add it to the hash,
401 fill in the raw_inode while you're at it. */ 404 fill in the raw_inode while you're at it. */
402struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri) 405struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri,
406 struct posix_acl **acl)
403{ 407{
404 struct inode *inode; 408 struct inode *inode;
405 struct super_block *sb = dir_i->i_sb; 409 struct super_block *sb = dir_i->i_sb;
@@ -431,7 +435,23 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i
431 } else { 435 } else {
432 ri->gid = cpu_to_je16(current->fsgid); 436 ri->gid = cpu_to_je16(current->fsgid);
433 } 437 }
434 ri->mode = cpu_to_jemode(mode); 438
439 /* POSIX ACLs have to be processed now, at least partly.
440 The umask is only applied if there's no default ACL */
441 if (!S_ISLNK(mode)) {
442 *acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT);
443 if (IS_ERR(*acl)) {
444 make_bad_inode(inode);
445 iput(inode);
446 inode = (void *)*acl;
447 *acl = NULL;
448 return inode;
449 }
450 if (!(*acl))
451 mode &= ~current->fs->umask;
452 } else {
453 *acl = NULL;
454 }
435 ret = jffs2_do_new_inode (c, f, mode, ri); 455 ret = jffs2_do_new_inode (c, f, mode, ri);
436 if (ret) { 456 if (ret) {
437 make_bad_inode(inode); 457 make_bad_inode(inode);