aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2')
-rw-r--r--fs/jffs2/acl.c23
-rw-r--r--fs/jffs2/acl.h4
-rw-r--r--fs/jffs2/dir.c33
-rw-r--r--fs/jffs2/fs.c32
-rw-r--r--fs/jffs2/os-linux.h5
5 files changed, 67 insertions, 30 deletions
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 65b3a1b5b88d..8ec9323e830a 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -176,7 +176,7 @@ static void jffs2_iset_acl(struct inode *inode, struct posix_acl **i_acl, struct
176 spin_unlock(&inode->i_lock); 176 spin_unlock(&inode->i_lock);
177} 177}
178 178
179static struct posix_acl *jffs2_get_acl(struct inode *inode, int type) 179struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
180{ 180{
181 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 181 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
182 struct posix_acl *acl; 182 struct posix_acl *acl;
@@ -247,8 +247,13 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
247 if (rc < 0) 247 if (rc < 0)
248 return rc; 248 return rc;
249 if (inode->i_mode != mode) { 249 if (inode->i_mode != mode) {
250 inode->i_mode = mode; 250 struct iattr attr;
251 jffs2_dirty_inode(inode); 251
252 attr.ia_valid = ATTR_MODE;
253 attr.ia_mode = mode;
254 rc = jffs2_do_setattr(inode, &attr);
255 if (rc < 0)
256 return rc;
252 } 257 }
253 if (rc == 0) 258 if (rc == 0)
254 acl = NULL; 259 acl = NULL;
@@ -307,22 +312,16 @@ int jffs2_permission(struct inode *inode, int mask, struct nameidata *nd)
307 return generic_permission(inode, mask, jffs2_check_acl); 312 return generic_permission(inode, mask, jffs2_check_acl);
308} 313}
309 314
310int jffs2_init_acl(struct inode *inode, struct inode *dir) 315int jffs2_init_acl(struct inode *inode, struct posix_acl *acl)
311{ 316{
312 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 317 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
313 struct posix_acl *acl = NULL, *clone; 318 struct posix_acl *clone;
314 mode_t mode; 319 mode_t mode;
315 int rc = 0; 320 int rc = 0;
316 321
317 f->i_acl_access = JFFS2_ACL_NOT_CACHED; 322 f->i_acl_access = JFFS2_ACL_NOT_CACHED;
318 f->i_acl_default = JFFS2_ACL_NOT_CACHED; 323 f->i_acl_default = JFFS2_ACL_NOT_CACHED;
319 if (!S_ISLNK(inode->i_mode)) { 324
320 acl = jffs2_get_acl(dir, ACL_TYPE_DEFAULT);
321 if (IS_ERR(acl))
322 return PTR_ERR(acl);
323 if (!acl)
324 inode->i_mode &= ~current->fs->umask;
325 }
326 if (acl) { 325 if (acl) {
327 if (S_ISDIR(inode->i_mode)) { 326 if (S_ISDIR(inode->i_mode)) {
328 rc = jffs2_set_acl(inode, ACL_TYPE_DEFAULT, acl); 327 rc = jffs2_set_acl(inode, ACL_TYPE_DEFAULT, acl);
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h
index c84378cee82a..90a2dbf59051 100644
--- a/fs/jffs2/acl.h
+++ b/fs/jffs2/acl.h
@@ -28,9 +28,10 @@ struct jffs2_acl_header {
28 28
29#define JFFS2_ACL_NOT_CACHED ((void *)-1) 29#define JFFS2_ACL_NOT_CACHED ((void *)-1)
30 30
31extern struct posix_acl *jffs2_get_acl(struct inode *inode, int type);
31extern int jffs2_permission(struct inode *, int, struct nameidata *); 32extern int jffs2_permission(struct inode *, int, struct nameidata *);
32extern int jffs2_acl_chmod(struct inode *); 33extern int jffs2_acl_chmod(struct inode *);
33extern int jffs2_init_acl(struct inode *, struct inode *); 34extern int jffs2_init_acl(struct inode *, struct posix_acl *);
34extern void jffs2_clear_acl(struct jffs2_inode_info *); 35extern void jffs2_clear_acl(struct jffs2_inode_info *);
35 36
36extern struct xattr_handler jffs2_acl_access_xattr_handler; 37extern struct xattr_handler jffs2_acl_access_xattr_handler;
@@ -38,6 +39,7 @@ extern struct xattr_handler jffs2_acl_default_xattr_handler;
38 39
39#else 40#else
40 41
42#define jffs2_get_acl(inode, type) (NULL)
41#define jffs2_permission NULL 43#define jffs2_permission NULL
42#define jffs2_acl_chmod(inode) (0) 44#define jffs2_acl_chmod(inode) (0)
43#define jffs2_init_acl(inode,dir) (0) 45#define jffs2_init_acl(inode,dir) (0)
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;
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);
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 80daea96bbc2..f6743a915cf3 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -173,12 +173,15 @@ int jffs2_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
173extern const struct inode_operations jffs2_symlink_inode_operations; 173extern const struct inode_operations jffs2_symlink_inode_operations;
174 174
175/* fs.c */ 175/* fs.c */
176struct posix_acl;
177
176int jffs2_setattr (struct dentry *, struct iattr *); 178int jffs2_setattr (struct dentry *, struct iattr *);
179int jffs2_do_setattr (struct inode *, struct iattr *);
177void jffs2_read_inode (struct inode *); 180void jffs2_read_inode (struct inode *);
178void jffs2_clear_inode (struct inode *); 181void jffs2_clear_inode (struct inode *);
179void jffs2_dirty_inode(struct inode *inode); 182void jffs2_dirty_inode(struct inode *inode);
180struct inode *jffs2_new_inode (struct inode *dir_i, int mode, 183struct inode *jffs2_new_inode (struct inode *dir_i, int mode,
181 struct jffs2_raw_inode *ri); 184 struct jffs2_raw_inode *ri, struct posix_acl **acl);
182int jffs2_statfs (struct dentry *, struct kstatfs *); 185int jffs2_statfs (struct dentry *, struct kstatfs *);
183void jffs2_write_super (struct super_block *); 186void jffs2_write_super (struct super_block *);
184int jffs2_remount_fs (struct super_block *, int *, char *); 187int jffs2_remount_fs (struct super_block *, int *, char *);