aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/dir.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/dir.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/dir.c')
-rw-r--r--fs/jffs2/dir.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index d293a1fad6d6..8353eb9c1799 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -182,6 +182,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
182 struct jffs2_inode_info *f, *dir_f; 182 struct jffs2_inode_info *f, *dir_f;
183 struct jffs2_sb_info *c; 183 struct jffs2_sb_info *c;
184 struct inode *inode; 184 struct inode *inode;
185 struct posix_acl *acl;
185 int ret; 186 int ret;
186 187
187 ri = jffs2_alloc_raw_inode(); 188 ri = jffs2_alloc_raw_inode();
@@ -192,7 +193,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
192 193
193 D1(printk(KERN_DEBUG "jffs2_create()\n")); 194 D1(printk(KERN_DEBUG "jffs2_create()\n"));
194 195
195 inode = jffs2_new_inode(dir_i, mode, ri); 196 inode = jffs2_new_inode(dir_i, mode, ri, &acl);
196 197
197 if (IS_ERR(inode)) { 198 if (IS_ERR(inode)) {
198 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); 199 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n"));
@@ -212,12 +213,12 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
212 dentry->d_name.name, dentry->d_name.len); 213 dentry->d_name.name, dentry->d_name.len);
213 214
214 if (ret) 215 if (ret)
215 goto fail; 216 goto fail_acl;
216 217
217 ret = jffs2_init_security(inode, dir_i); 218 ret = jffs2_init_security(inode, dir_i);
218 if (ret) 219 if (ret)
219 goto fail; 220 goto fail_acl;
220 ret = jffs2_init_acl(inode, dir_i); 221 ret = jffs2_init_acl(inode, acl);
221 if (ret) 222 if (ret)
222 goto fail; 223 goto fail;
223 224
@@ -230,6 +231,8 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
230 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages)); 231 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages));
231 return 0; 232 return 0;
232 233
234 fail_acl:
235 posix_acl_release(acl);
233 fail: 236 fail:
234 make_bad_inode(inode); 237 make_bad_inode(inode);
235 iput(inode); 238 iput(inode);
@@ -306,6 +309,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
306 struct jffs2_full_dirent *fd; 309 struct jffs2_full_dirent *fd;
307 int namelen; 310 int namelen;
308 uint32_t alloclen; 311 uint32_t alloclen;
312 struct posix_acl *acl;
309 int ret, targetlen = strlen(target); 313 int ret, targetlen = strlen(target);
310 314
311 /* FIXME: If you care. We'd need to use frags for the target 315 /* FIXME: If you care. We'd need to use frags for the target
@@ -332,7 +336,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
332 return ret; 336 return ret;
333 } 337 }
334 338
335 inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri); 339 inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri, &acl);
336 340
337 if (IS_ERR(inode)) { 341 if (IS_ERR(inode)) {
338 jffs2_free_raw_inode(ri); 342 jffs2_free_raw_inode(ri);
@@ -362,6 +366,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
362 up(&f->sem); 366 up(&f->sem);
363 jffs2_complete_reservation(c); 367 jffs2_complete_reservation(c);
364 jffs2_clear_inode(inode); 368 jffs2_clear_inode(inode);
369 posix_acl_release(acl);
365 return PTR_ERR(fn); 370 return PTR_ERR(fn);
366 } 371 }
367 372
@@ -372,6 +377,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
372 up(&f->sem); 377 up(&f->sem);
373 jffs2_complete_reservation(c); 378 jffs2_complete_reservation(c);
374 jffs2_clear_inode(inode); 379 jffs2_clear_inode(inode);
380 posix_acl_release(acl);
375 return -ENOMEM; 381 return -ENOMEM;
376 } 382 }
377 383
@@ -389,9 +395,10 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
389 ret = jffs2_init_security(inode, dir_i); 395 ret = jffs2_init_security(inode, dir_i);
390 if (ret) { 396 if (ret) {
391 jffs2_clear_inode(inode); 397 jffs2_clear_inode(inode);
398 posix_acl_release(acl);
392 return ret; 399 return ret;
393 } 400 }
394 ret = jffs2_init_acl(inode, dir_i); 401 ret = jffs2_init_acl(inode, acl);
395 if (ret) { 402 if (ret) {
396 jffs2_clear_inode(inode); 403 jffs2_clear_inode(inode);
397 return ret; 404 return ret;
@@ -469,6 +476,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
469 struct jffs2_full_dirent *fd; 476 struct jffs2_full_dirent *fd;
470 int namelen; 477 int namelen;
471 uint32_t alloclen; 478 uint32_t alloclen;
479 struct posix_acl *acl;
472 int ret; 480 int ret;
473 481
474 mode |= S_IFDIR; 482 mode |= S_IFDIR;
@@ -491,7 +499,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
491 return ret; 499 return ret;
492 } 500 }
493 501
494 inode = jffs2_new_inode(dir_i, mode, ri); 502 inode = jffs2_new_inode(dir_i, mode, ri, &acl);
495 503
496 if (IS_ERR(inode)) { 504 if (IS_ERR(inode)) {
497 jffs2_free_raw_inode(ri); 505 jffs2_free_raw_inode(ri);
@@ -518,6 +526,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
518 up(&f->sem); 526 up(&f->sem);
519 jffs2_complete_reservation(c); 527 jffs2_complete_reservation(c);
520 jffs2_clear_inode(inode); 528 jffs2_clear_inode(inode);
529 posix_acl_release(acl);
521 return PTR_ERR(fn); 530 return PTR_ERR(fn);
522 } 531 }
523 /* No data here. Only a metadata node, which will be 532 /* No data here. Only a metadata node, which will be
@@ -531,9 +540,10 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
531 ret = jffs2_init_security(inode, dir_i); 540 ret = jffs2_init_security(inode, dir_i);
532 if (ret) { 541 if (ret) {
533 jffs2_clear_inode(inode); 542 jffs2_clear_inode(inode);
543 posix_acl_release(acl);
534 return ret; 544 return ret;
535 } 545 }
536 ret = jffs2_init_acl(inode, dir_i); 546 ret = jffs2_init_acl(inode, acl);
537 if (ret) { 547 if (ret) {
538 jffs2_clear_inode(inode); 548 jffs2_clear_inode(inode);
539 return ret; 549 return ret;
@@ -629,6 +639,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
629 union jffs2_device_node dev; 639 union jffs2_device_node dev;
630 int devlen = 0; 640 int devlen = 0;
631 uint32_t alloclen; 641 uint32_t alloclen;
642 struct posix_acl *acl;
632 int ret; 643 int ret;
633 644
634 if (!new_valid_dev(rdev)) 645 if (!new_valid_dev(rdev))
@@ -655,7 +666,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
655 return ret; 666 return ret;
656 } 667 }
657 668
658 inode = jffs2_new_inode(dir_i, mode, ri); 669 inode = jffs2_new_inode(dir_i, mode, ri, &acl);
659 670
660 if (IS_ERR(inode)) { 671 if (IS_ERR(inode)) {
661 jffs2_free_raw_inode(ri); 672 jffs2_free_raw_inode(ri);
@@ -684,6 +695,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
684 up(&f->sem); 695 up(&f->sem);
685 jffs2_complete_reservation(c); 696 jffs2_complete_reservation(c);
686 jffs2_clear_inode(inode); 697 jffs2_clear_inode(inode);
698 posix_acl_release(acl);
687 return PTR_ERR(fn); 699 return PTR_ERR(fn);
688 } 700 }
689 /* No data here. Only a metadata node, which will be 701 /* No data here. Only a metadata node, which will be
@@ -697,9 +709,10 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
697 ret = jffs2_init_security(inode, dir_i); 709 ret = jffs2_init_security(inode, dir_i);
698 if (ret) { 710 if (ret) {
699 jffs2_clear_inode(inode); 711 jffs2_clear_inode(inode);
712 posix_acl_release(acl);
700 return ret; 713 return ret;
701 } 714 }
702 ret = jffs2_init_acl(inode, dir_i); 715 ret = jffs2_init_acl(inode, acl);
703 if (ret) { 716 if (ret) {
704 jffs2_clear_inode(inode); 717 jffs2_clear_inode(inode);
705 return ret; 718 return ret;