diff options
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/xattr.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 69565e5fc6a0..426aa464f1af 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -383,36 +383,36 @@ int btrfs_removexattr(struct dentry *dentry, const char *name) | |||
383 | XATTR_REPLACE); | 383 | XATTR_REPLACE); |
384 | } | 384 | } |
385 | 385 | ||
386 | int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, | 386 | int btrfs_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
387 | struct inode *inode, struct inode *dir, | 387 | void *fs_info) |
388 | const struct qstr *qstr) | ||
389 | { | 388 | { |
390 | int err; | 389 | const struct xattr *xattr; |
391 | size_t len; | 390 | struct btrfs_trans_handle *trans = fs_info; |
392 | void *value; | ||
393 | char *suffix; | ||
394 | char *name; | 391 | char *name; |
392 | int err = 0; | ||
395 | 393 | ||
396 | err = security_inode_init_security(inode, dir, qstr, &suffix, &value, | 394 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
397 | &len); | 395 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + |
398 | if (err) { | 396 | strlen(xattr->name) + 1, GFP_NOFS); |
399 | if (err == -EOPNOTSUPP) | 397 | if (!name) { |
400 | return 0; | 398 | err = -ENOMEM; |
401 | return err; | 399 | break; |
402 | } | 400 | } |
403 | |||
404 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + strlen(suffix) + 1, | ||
405 | GFP_NOFS); | ||
406 | if (!name) { | ||
407 | err = -ENOMEM; | ||
408 | } else { | ||
409 | strcpy(name, XATTR_SECURITY_PREFIX); | 401 | strcpy(name, XATTR_SECURITY_PREFIX); |
410 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); | 402 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name); |
411 | err = __btrfs_setxattr(trans, inode, name, value, len, 0); | 403 | err = __btrfs_setxattr(trans, inode, name, |
404 | xattr->value, xattr->value_len, 0); | ||
412 | kfree(name); | 405 | kfree(name); |
406 | if (err < 0) | ||
407 | break; | ||
413 | } | 408 | } |
414 | |||
415 | kfree(suffix); | ||
416 | kfree(value); | ||
417 | return err; | 409 | return err; |
418 | } | 410 | } |
411 | |||
412 | int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, | ||
413 | struct inode *inode, struct inode *dir, | ||
414 | const struct qstr *qstr) | ||
415 | { | ||
416 | return security_inode_init_security(inode, dir, qstr, | ||
417 | &btrfs_initxattrs, trans); | ||
418 | } | ||