aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/dir.c
diff options
context:
space:
mode:
authorKaiGai Kohei <kaigai@ak.jp.nec.com>2007-09-14 02:16:35 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2007-10-20 09:10:54 -0400
commitcfc8dc6f6f69ede939e09c2af06a01adee577285 (patch)
treea37149d6353fb4b911beb5ad4ad18f2ec2b1468a /fs/jffs2/dir.c
parente8b8c977734193adedf2b0f607d6252c78e86394 (diff)
[JFFS2] Tidy up fix for ACL/permissions problem.
[In commit 9ed437c50d89eabae763dd422579f73fdebf288d we fixed a problem with standard permissions on newly-created inodes, when POSIX ACLs are enabled. This cleans it up...] The attached patch separate jffs2_init_acl() into two parts. The one is jffs2_init_acl_pre() called from jffs2_new_inode(). It compute ACL oriented inode->i_mode bits, and allocate in-memory ACL objects associated with the new inode just before when inode meta infomation is written to the medium. The other is jffs2_init_acl_post() called from jffs2_symlink(), jffs2_mkdir(), jffs2_mknod() and jffs2_do_create(). It actually writes in-memory ACL objects into the medium next to the success of writing meta-information. In the current implementation, we have to write a same inode meta infomation twice when inode->i_mode is updated by the default ACL. However, we can avoid the behavior by putting an updated i_mode before it is written at first, as jffs2_init_acl_pre() doing. Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/dir.c')
-rw-r--r--fs/jffs2/dir.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 8353eb9c1799..787e392ffd41 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -182,7 +182,6 @@ 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;
186 int ret; 185 int ret;
187 186
188 ri = jffs2_alloc_raw_inode(); 187 ri = jffs2_alloc_raw_inode();
@@ -193,7 +192,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
193 192
194 D1(printk(KERN_DEBUG "jffs2_create()\n")); 193 D1(printk(KERN_DEBUG "jffs2_create()\n"));
195 194
196 inode = jffs2_new_inode(dir_i, mode, ri, &acl); 195 inode = jffs2_new_inode(dir_i, mode, ri);
197 196
198 if (IS_ERR(inode)) { 197 if (IS_ERR(inode)) {
199 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); 198 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n"));
@@ -211,14 +210,6 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
211 210
212 ret = jffs2_do_create(c, dir_f, f, ri, 211 ret = jffs2_do_create(c, dir_f, f, ri,
213 dentry->d_name.name, dentry->d_name.len); 212 dentry->d_name.name, dentry->d_name.len);
214
215 if (ret)
216 goto fail_acl;
217
218 ret = jffs2_init_security(inode, dir_i);
219 if (ret)
220 goto fail_acl;
221 ret = jffs2_init_acl(inode, acl);
222 if (ret) 213 if (ret)
223 goto fail; 214 goto fail;
224 215
@@ -231,8 +222,6 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
231 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages)); 222 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages));
232 return 0; 223 return 0;
233 224
234 fail_acl:
235 posix_acl_release(acl);
236 fail: 225 fail:
237 make_bad_inode(inode); 226 make_bad_inode(inode);
238 iput(inode); 227 iput(inode);
@@ -309,7 +298,6 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
309 struct jffs2_full_dirent *fd; 298 struct jffs2_full_dirent *fd;
310 int namelen; 299 int namelen;
311 uint32_t alloclen; 300 uint32_t alloclen;
312 struct posix_acl *acl;
313 int ret, targetlen = strlen(target); 301 int ret, targetlen = strlen(target);
314 302
315 /* FIXME: If you care. We'd need to use frags for the target 303 /* FIXME: If you care. We'd need to use frags for the target
@@ -336,7 +324,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
336 return ret; 324 return ret;
337 } 325 }
338 326
339 inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri, &acl); 327 inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri);
340 328
341 if (IS_ERR(inode)) { 329 if (IS_ERR(inode)) {
342 jffs2_free_raw_inode(ri); 330 jffs2_free_raw_inode(ri);
@@ -366,7 +354,6 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
366 up(&f->sem); 354 up(&f->sem);
367 jffs2_complete_reservation(c); 355 jffs2_complete_reservation(c);
368 jffs2_clear_inode(inode); 356 jffs2_clear_inode(inode);
369 posix_acl_release(acl);
370 return PTR_ERR(fn); 357 return PTR_ERR(fn);
371 } 358 }
372 359
@@ -377,7 +364,6 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
377 up(&f->sem); 364 up(&f->sem);
378 jffs2_complete_reservation(c); 365 jffs2_complete_reservation(c);
379 jffs2_clear_inode(inode); 366 jffs2_clear_inode(inode);
380 posix_acl_release(acl);
381 return -ENOMEM; 367 return -ENOMEM;
382 } 368 }
383 369
@@ -395,10 +381,9 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
395 ret = jffs2_init_security(inode, dir_i); 381 ret = jffs2_init_security(inode, dir_i);
396 if (ret) { 382 if (ret) {
397 jffs2_clear_inode(inode); 383 jffs2_clear_inode(inode);
398 posix_acl_release(acl);
399 return ret; 384 return ret;
400 } 385 }
401 ret = jffs2_init_acl(inode, acl); 386 ret = jffs2_init_acl_post(inode);
402 if (ret) { 387 if (ret) {
403 jffs2_clear_inode(inode); 388 jffs2_clear_inode(inode);
404 return ret; 389 return ret;
@@ -476,7 +461,6 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
476 struct jffs2_full_dirent *fd; 461 struct jffs2_full_dirent *fd;
477 int namelen; 462 int namelen;
478 uint32_t alloclen; 463 uint32_t alloclen;
479 struct posix_acl *acl;
480 int ret; 464 int ret;
481 465
482 mode |= S_IFDIR; 466 mode |= S_IFDIR;
@@ -499,7 +483,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
499 return ret; 483 return ret;
500 } 484 }
501 485
502 inode = jffs2_new_inode(dir_i, mode, ri, &acl); 486 inode = jffs2_new_inode(dir_i, mode, ri);
503 487
504 if (IS_ERR(inode)) { 488 if (IS_ERR(inode)) {
505 jffs2_free_raw_inode(ri); 489 jffs2_free_raw_inode(ri);
@@ -526,7 +510,6 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
526 up(&f->sem); 510 up(&f->sem);
527 jffs2_complete_reservation(c); 511 jffs2_complete_reservation(c);
528 jffs2_clear_inode(inode); 512 jffs2_clear_inode(inode);
529 posix_acl_release(acl);
530 return PTR_ERR(fn); 513 return PTR_ERR(fn);
531 } 514 }
532 /* No data here. Only a metadata node, which will be 515 /* No data here. Only a metadata node, which will be
@@ -540,10 +523,9 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
540 ret = jffs2_init_security(inode, dir_i); 523 ret = jffs2_init_security(inode, dir_i);
541 if (ret) { 524 if (ret) {
542 jffs2_clear_inode(inode); 525 jffs2_clear_inode(inode);
543 posix_acl_release(acl);
544 return ret; 526 return ret;
545 } 527 }
546 ret = jffs2_init_acl(inode, acl); 528 ret = jffs2_init_acl_post(inode);
547 if (ret) { 529 if (ret) {
548 jffs2_clear_inode(inode); 530 jffs2_clear_inode(inode);
549 return ret; 531 return ret;
@@ -639,7 +621,6 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
639 union jffs2_device_node dev; 621 union jffs2_device_node dev;
640 int devlen = 0; 622 int devlen = 0;
641 uint32_t alloclen; 623 uint32_t alloclen;
642 struct posix_acl *acl;
643 int ret; 624 int ret;
644 625
645 if (!new_valid_dev(rdev)) 626 if (!new_valid_dev(rdev))
@@ -666,7 +647,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
666 return ret; 647 return ret;
667 } 648 }
668 649
669 inode = jffs2_new_inode(dir_i, mode, ri, &acl); 650 inode = jffs2_new_inode(dir_i, mode, ri);
670 651
671 if (IS_ERR(inode)) { 652 if (IS_ERR(inode)) {
672 jffs2_free_raw_inode(ri); 653 jffs2_free_raw_inode(ri);
@@ -695,7 +676,6 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
695 up(&f->sem); 676 up(&f->sem);
696 jffs2_complete_reservation(c); 677 jffs2_complete_reservation(c);
697 jffs2_clear_inode(inode); 678 jffs2_clear_inode(inode);
698 posix_acl_release(acl);
699 return PTR_ERR(fn); 679 return PTR_ERR(fn);
700 } 680 }
701 /* No data here. Only a metadata node, which will be 681 /* No data here. Only a metadata node, which will be
@@ -709,10 +689,9 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
709 ret = jffs2_init_security(inode, dir_i); 689 ret = jffs2_init_security(inode, dir_i);
710 if (ret) { 690 if (ret) {
711 jffs2_clear_inode(inode); 691 jffs2_clear_inode(inode);
712 posix_acl_release(acl);
713 return ret; 692 return ret;
714 } 693 }
715 ret = jffs2_init_acl(inode, acl); 694 ret = jffs2_init_acl_post(inode);
716 if (ret) { 695 if (ret) {
717 jffs2_clear_inode(inode); 696 jffs2_clear_inode(inode);
718 return ret; 697 return ret;