aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-28 11:38:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-28 11:38:04 -0500
commitbf3d846b783327359ddc4bd4f52627b36abb4d1d (patch)
treec6b8fddbf04a2962dfcf9f487af25033f11b10b9 /fs/jffs2
parent54c0a4b46150db1571d955d598cd342c9f1d9657 (diff)
parentf6500801522c61782d4990fa1ad96154cb397cd4 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "Assorted stuff; the biggest pile here is Christoph's ACL series. Plus assorted cleanups and fixes all over the place... There will be another pile later this week" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (43 commits) __dentry_path() fixes vfs: Remove second variable named error in __dentry_path vfs: Is mounted should be testing mnt_ns for NULL or error. Fix race when checking i_size on direct i/o read hfsplus: remove can_set_xattr nfsd: use get_acl and ->set_acl fs: remove generic_acl nfs: use generic posix ACL infrastructure for v3 Posix ACLs gfs2: use generic posix ACL infrastructure jfs: use generic posix ACL infrastructure xfs: use generic posix ACL infrastructure reiserfs: use generic posix ACL infrastructure ocfs2: use generic posix ACL infrastructure jffs2: use generic posix ACL infrastructure hfsplus: use generic posix ACL infrastructure f2fs: use generic posix ACL infrastructure ext2/3/4: use generic posix ACL infrastructure btrfs: use generic posix ACL infrastructure fs: make posix_acl_create more useful fs: make posix_acl_chmod more useful ...
Diffstat (limited to 'fs/jffs2')
-rw-r--r--fs/jffs2/acl.c141
-rw-r--r--fs/jffs2/acl.h7
-rw-r--r--fs/jffs2/dir.c1
-rw-r--r--fs/jffs2/file.c1
-rw-r--r--fs/jffs2/fs.c7
-rw-r--r--fs/jffs2/symlink.c1
-rw-r--r--fs/jffs2/xattr.c9
7 files changed, 24 insertions, 143 deletions
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 223283c30111..009ec0b5993d 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -178,10 +178,6 @@ struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
178 char *value = NULL; 178 char *value = NULL;
179 int rc, xprefix; 179 int rc, xprefix;
180 180
181 acl = get_cached_acl(inode, type);
182 if (acl != ACL_NOT_CACHED)
183 return acl;
184
185 switch (type) { 181 switch (type) {
186 case ACL_TYPE_ACCESS: 182 case ACL_TYPE_ACCESS:
187 xprefix = JFFS2_XPREFIX_ACL_ACCESS; 183 xprefix = JFFS2_XPREFIX_ACL_ACCESS;
@@ -232,13 +228,10 @@ static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *a
232 return rc; 228 return rc;
233} 229}
234 230
235static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 231int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
236{ 232{
237 int rc, xprefix; 233 int rc, xprefix;
238 234
239 if (S_ISLNK(inode->i_mode))
240 return -EOPNOTSUPP;
241
242 switch (type) { 235 switch (type) {
243 case ACL_TYPE_ACCESS: 236 case ACL_TYPE_ACCESS:
244 xprefix = JFFS2_XPREFIX_ACL_ACCESS; 237 xprefix = JFFS2_XPREFIX_ACL_ACCESS;
@@ -277,30 +270,21 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
277 270
278int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, umode_t *i_mode) 271int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, umode_t *i_mode)
279{ 272{
280 struct posix_acl *acl; 273 struct posix_acl *default_acl, *acl;
281 int rc; 274 int rc;
282 275
283 cache_no_acl(inode); 276 cache_no_acl(inode);
284 277
285 if (S_ISLNK(*i_mode)) 278 rc = posix_acl_create(dir_i, i_mode, &default_acl, &acl);
286 return 0; /* Symlink always has no-ACL */ 279 if (rc)
287 280 return rc;
288 acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT);
289 if (IS_ERR(acl))
290 return PTR_ERR(acl);
291
292 if (!acl) {
293 *i_mode &= ~current_umask();
294 } else {
295 if (S_ISDIR(*i_mode))
296 set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
297
298 rc = posix_acl_create(&acl, GFP_KERNEL, i_mode);
299 if (rc < 0)
300 return rc;
301 if (rc > 0)
302 set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
303 281
282 if (default_acl) {
283 set_cached_acl(inode, ACL_TYPE_DEFAULT, default_acl);
284 posix_acl_release(default_acl);
285 }
286 if (acl) {
287 set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
304 posix_acl_release(acl); 288 posix_acl_release(acl);
305 } 289 }
306 return 0; 290 return 0;
@@ -324,106 +308,3 @@ int jffs2_init_acl_post(struct inode *inode)
324 308
325 return 0; 309 return 0;
326} 310}
327
328int jffs2_acl_chmod(struct inode *inode)
329{
330 struct posix_acl *acl;
331 int rc;
332
333 if (S_ISLNK(inode->i_mode))
334 return -EOPNOTSUPP;
335 acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS);
336 if (IS_ERR(acl) || !acl)
337 return PTR_ERR(acl);
338 rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
339 if (rc)
340 return rc;
341 rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, acl);
342 posix_acl_release(acl);
343 return rc;
344}
345
346static size_t jffs2_acl_access_listxattr(struct dentry *dentry, char *list,
347 size_t list_size, const char *name, size_t name_len, int type)
348{
349 const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS);
350
351 if (list && retlen <= list_size)
352 strcpy(list, POSIX_ACL_XATTR_ACCESS);
353 return retlen;
354}
355
356static size_t jffs2_acl_default_listxattr(struct dentry *dentry, char *list,
357 size_t list_size, const char *name, size_t name_len, int type)
358{
359 const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT);
360
361 if (list && retlen <= list_size)
362 strcpy(list, POSIX_ACL_XATTR_DEFAULT);
363 return retlen;
364}
365
366static int jffs2_acl_getxattr(struct dentry *dentry, const char *name,
367 void *buffer, size_t size, int type)
368{
369 struct posix_acl *acl;
370 int rc;
371
372 if (name[0] != '\0')
373 return -EINVAL;
374
375 acl = jffs2_get_acl(dentry->d_inode, type);
376 if (IS_ERR(acl))
377 return PTR_ERR(acl);
378 if (!acl)
379 return -ENODATA;
380 rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
381 posix_acl_release(acl);
382
383 return rc;
384}
385
386static int jffs2_acl_setxattr(struct dentry *dentry, const char *name,
387 const void *value, size_t size, int flags, int type)
388{
389 struct posix_acl *acl;
390 int rc;
391
392 if (name[0] != '\0')
393 return -EINVAL;
394 if (!inode_owner_or_capable(dentry->d_inode))
395 return -EPERM;
396
397 if (value) {
398 acl = posix_acl_from_xattr(&init_user_ns, value, size);
399 if (IS_ERR(acl))
400 return PTR_ERR(acl);
401 if (acl) {
402 rc = posix_acl_valid(acl);
403 if (rc)
404 goto out;
405 }
406 } else {
407 acl = NULL;
408 }
409 rc = jffs2_set_acl(dentry->d_inode, type, acl);
410 out:
411 posix_acl_release(acl);
412 return rc;
413}
414
415const struct xattr_handler jffs2_acl_access_xattr_handler = {
416 .prefix = POSIX_ACL_XATTR_ACCESS,
417 .flags = ACL_TYPE_DEFAULT,
418 .list = jffs2_acl_access_listxattr,
419 .get = jffs2_acl_getxattr,
420 .set = jffs2_acl_setxattr,
421};
422
423const struct xattr_handler jffs2_acl_default_xattr_handler = {
424 .prefix = POSIX_ACL_XATTR_DEFAULT,
425 .flags = ACL_TYPE_DEFAULT,
426 .list = jffs2_acl_default_listxattr,
427 .get = jffs2_acl_getxattr,
428 .set = jffs2_acl_setxattr,
429};
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h
index 9b477246f2a6..2e2b5745c3b7 100644
--- a/fs/jffs2/acl.h
+++ b/fs/jffs2/acl.h
@@ -27,17 +27,14 @@ struct jffs2_acl_header {
27#ifdef CONFIG_JFFS2_FS_POSIX_ACL 27#ifdef CONFIG_JFFS2_FS_POSIX_ACL
28 28
29struct posix_acl *jffs2_get_acl(struct inode *inode, int type); 29struct posix_acl *jffs2_get_acl(struct inode *inode, int type);
30extern int jffs2_acl_chmod(struct inode *); 30int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
31extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *); 31extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);
32extern int jffs2_init_acl_post(struct inode *); 32extern int jffs2_init_acl_post(struct inode *);
33 33
34extern const struct xattr_handler jffs2_acl_access_xattr_handler;
35extern const struct xattr_handler jffs2_acl_default_xattr_handler;
36
37#else 34#else
38 35
39#define jffs2_get_acl (NULL) 36#define jffs2_get_acl (NULL)
40#define jffs2_acl_chmod(inode) (0) 37#define jffs2_set_acl (NULL)
41#define jffs2_init_acl_pre(dir_i,inode,mode) (0) 38#define jffs2_init_acl_pre(dir_i,inode,mode) (0)
42#define jffs2_init_acl_post(inode) (0) 39#define jffs2_init_acl_post(inode) (0)
43 40
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index e3aac222472e..938556025d64 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -59,6 +59,7 @@ const struct inode_operations jffs2_dir_inode_operations =
59 .mknod = jffs2_mknod, 59 .mknod = jffs2_mknod,
60 .rename = jffs2_rename, 60 .rename = jffs2_rename,
61 .get_acl = jffs2_get_acl, 61 .get_acl = jffs2_get_acl,
62 .set_acl = jffs2_set_acl,
62 .setattr = jffs2_setattr, 63 .setattr = jffs2_setattr,
63 .setxattr = jffs2_setxattr, 64 .setxattr = jffs2_setxattr,
64 .getxattr = jffs2_getxattr, 65 .getxattr = jffs2_getxattr,
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 1506673c087e..256cd19a3b78 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -66,6 +66,7 @@ const struct file_operations jffs2_file_operations =
66const struct inode_operations jffs2_file_inode_operations = 66const struct inode_operations jffs2_file_inode_operations =
67{ 67{
68 .get_acl = jffs2_get_acl, 68 .get_acl = jffs2_get_acl,
69 .set_acl = jffs2_set_acl,
69 .setattr = jffs2_setattr, 70 .setattr = jffs2_setattr,
70 .setxattr = jffs2_setxattr, 71 .setxattr = jffs2_setxattr,
71 .getxattr = jffs2_getxattr, 72 .getxattr = jffs2_getxattr,
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 09b3ed455724..a69e426435dd 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -190,15 +190,16 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
190 190
191int jffs2_setattr(struct dentry *dentry, struct iattr *iattr) 191int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
192{ 192{
193 struct inode *inode = dentry->d_inode;
193 int rc; 194 int rc;
194 195
195 rc = inode_change_ok(dentry->d_inode, iattr); 196 rc = inode_change_ok(inode, iattr);
196 if (rc) 197 if (rc)
197 return rc; 198 return rc;
198 199
199 rc = jffs2_do_setattr(dentry->d_inode, iattr); 200 rc = jffs2_do_setattr(inode, iattr);
200 if (!rc && (iattr->ia_valid & ATTR_MODE)) 201 if (!rc && (iattr->ia_valid & ATTR_MODE))
201 rc = jffs2_acl_chmod(dentry->d_inode); 202 rc = posix_acl_chmod(inode, inode->i_mode);
202 203
203 return rc; 204 return rc;
204} 205}
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c
index 6e563332bb24..c7c77b0dfccd 100644
--- a/fs/jffs2/symlink.c
+++ b/fs/jffs2/symlink.c
@@ -22,7 +22,6 @@ const struct inode_operations jffs2_symlink_inode_operations =
22{ 22{
23 .readlink = generic_readlink, 23 .readlink = generic_readlink,
24 .follow_link = jffs2_follow_link, 24 .follow_link = jffs2_follow_link,
25 .get_acl = jffs2_get_acl,
26 .setattr = jffs2_setattr, 25 .setattr = jffs2_setattr,
27 .setxattr = jffs2_setxattr, 26 .setxattr = jffs2_setxattr,
28 .getxattr = jffs2_getxattr, 27 .getxattr = jffs2_getxattr,
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 3034e970eb9a..ad0f2e2a1700 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -22,6 +22,7 @@
22#include <linux/crc32.h> 22#include <linux/crc32.h>
23#include <linux/jffs2.h> 23#include <linux/jffs2.h>
24#include <linux/xattr.h> 24#include <linux/xattr.h>
25#include <linux/posix_acl_xattr.h>
25#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
26#include "nodelist.h" 27#include "nodelist.h"
27/* -------- xdatum related functions ---------------- 28/* -------- xdatum related functions ----------------
@@ -921,8 +922,8 @@ const struct xattr_handler *jffs2_xattr_handlers[] = {
921 &jffs2_security_xattr_handler, 922 &jffs2_security_xattr_handler,
922#endif 923#endif
923#ifdef CONFIG_JFFS2_FS_POSIX_ACL 924#ifdef CONFIG_JFFS2_FS_POSIX_ACL
924 &jffs2_acl_access_xattr_handler, 925 &posix_acl_access_xattr_handler,
925 &jffs2_acl_default_xattr_handler, 926 &posix_acl_default_xattr_handler,
926#endif 927#endif
927 &jffs2_trusted_xattr_handler, 928 &jffs2_trusted_xattr_handler,
928 NULL 929 NULL
@@ -942,10 +943,10 @@ static const struct xattr_handler *xprefix_to_handler(int xprefix) {
942#endif 943#endif
943#ifdef CONFIG_JFFS2_FS_POSIX_ACL 944#ifdef CONFIG_JFFS2_FS_POSIX_ACL
944 case JFFS2_XPREFIX_ACL_ACCESS: 945 case JFFS2_XPREFIX_ACL_ACCESS:
945 ret = &jffs2_acl_access_xattr_handler; 946 ret = &posix_acl_access_xattr_handler;
946 break; 947 break;
947 case JFFS2_XPREFIX_ACL_DEFAULT: 948 case JFFS2_XPREFIX_ACL_DEFAULT:
948 ret = &jffs2_acl_default_xattr_handler; 949 ret = &posix_acl_default_xattr_handler;
949 break; 950 break;
950#endif 951#endif
951 case JFFS2_XPREFIX_TRUSTED: 952 case JFFS2_XPREFIX_TRUSTED: