aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/xattr.c
diff options
context:
space:
mode:
authorMimi Zohar <zohar@linux.vnet.ibm.com>2011-06-06 15:29:25 -0400
committerMimi Zohar <zohar@linux.vnet.ibm.com>2011-07-18 12:29:38 -0400
commit9d8f13ba3f4833219e50767b022b82cd0da930eb (patch)
tree3ba2367380d009111ea17696162a62320c88d144 /fs/btrfs/xattr.c
parent0f2a55d5bb2372058275b0b343d90dd5d640d045 (diff)
security: new security_inode_init_security API adds function callback
This patch changes the security_inode_init_security API by adding a filesystem specific callback to write security extended attributes. This change is in preparation for supporting the initialization of multiple LSM xattrs and the EVM xattr. Initially the callback function walks an array of xattrs, writing each xattr separately, but could be optimized to write multiple xattrs at once. For existing security_inode_init_security() calls, which have not yet been converted to use the new callback function, such as those in reiserfs and ocfs2, this patch defines security_old_inode_init_security(). Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Diffstat (limited to 'fs/btrfs/xattr.c')
-rw-r--r--fs/btrfs/xattr.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index 5366fe452ab0..a039e6ed4ce0 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -360,36 +360,36 @@ int btrfs_removexattr(struct dentry *dentry, const char *name)
360 XATTR_REPLACE); 360 XATTR_REPLACE);
361} 361}
362 362
363int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, 363int btrfs_initxattrs(struct inode *inode, const struct xattr *xattr_array,
364 struct inode *inode, struct inode *dir, 364 void *fs_info)
365 const struct qstr *qstr)
366{ 365{
367 int err; 366 const struct xattr *xattr;
368 size_t len; 367 struct btrfs_trans_handle *trans = fs_info;
369 void *value;
370 char *suffix;
371 char *name; 368 char *name;
369 int err = 0;
372 370
373 err = security_inode_init_security(inode, dir, qstr, &suffix, &value, 371 for (xattr = xattr_array; xattr->name != NULL; xattr++) {
374 &len); 372 name = kmalloc(XATTR_SECURITY_PREFIX_LEN +
375 if (err) { 373 strlen(xattr->name) + 1, GFP_NOFS);
376 if (err == -EOPNOTSUPP) 374 if (!name) {
377 return 0; 375 err = -ENOMEM;
378 return err; 376 break;
379 } 377 }
380
381 name = kmalloc(XATTR_SECURITY_PREFIX_LEN + strlen(suffix) + 1,
382 GFP_NOFS);
383 if (!name) {
384 err = -ENOMEM;
385 } else {
386 strcpy(name, XATTR_SECURITY_PREFIX); 378 strcpy(name, XATTR_SECURITY_PREFIX);
387 strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); 379 strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name);
388 err = __btrfs_setxattr(trans, inode, name, value, len, 0); 380 err = __btrfs_setxattr(trans, inode, name,
381 xattr->value, xattr->value_len, 0);
389 kfree(name); 382 kfree(name);
383 if (err < 0)
384 break;
390 } 385 }
391
392 kfree(suffix);
393 kfree(value);
394 return err; 386 return err;
395} 387}
388
389int btrfs_xattr_security_init(struct btrfs_trans_handle *trans,
390 struct inode *inode, struct inode *dir,
391 const struct qstr *qstr)
392{
393 return security_inode_init_security(inode, dir, qstr,
394 &btrfs_initxattrs, trans);
395}