diff options
author | Jim Owens <jowens@hp.com> | 2009-02-04 09:29:13 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-02-04 09:29:13 -0500 |
commit | 0279b4cd86685b5eea467c1b74ce94f0add2c0a3 (patch) | |
tree | 54caafd4c6b31e2bc9861217627297c00af89066 /fs/btrfs/xattr.c | |
parent | bef62ef339c15d7721da88958b03f7b544464722 (diff) | |
download | linux-0279b4cd86685b5eea467c1b74ce94f0add2c0a3.tar.gz linux-0279b4cd86685b5eea467c1b74ce94f0add2c0a3.tar.bz2 linux-0279b4cd86685b5eea467c1b74ce94f0add2c0a3.zip |
Btrfs: selinux support
Add call to LSM security initialization and save
resulting security xattr for new inodes.
Add xattr support to symlink inode ops.
Set inode->i_op for existing special files.
Signed-off-by: jim owens <jowens@hp.com>
Diffstat (limited to 'fs/btrfs/xattr.c')
-rw-r--r-- | fs/btrfs/xattr.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index b4fa5f4b6ad1..312b9435e9f8 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c @@ -21,6 +21,7 @@ #include <linux/slab.h> #include <linux/rwsem.h> #include <linux/xattr.h> +#include <linux/security.h> #include "ctree.h" #include "btrfs_inode.h" #include "transaction.h" @@ -330,3 +331,34 @@ int btrfs_removexattr(struct dentry *dentry, const char *name) return -EOPNOTSUPP; return __btrfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); } + +int btrfs_xattr_security_init(struct inode *inode, struct inode *dir) +{ + int err; + size_t len; + void *value; + char *suffix; + char *name; + + err = security_inode_init_security(inode, dir, &suffix, &value, &len); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + + name = kmalloc(XATTR_SECURITY_PREFIX_LEN + strlen(suffix) + 1, + GFP_NOFS); + if (!name) { + err = -ENOMEM; + } else { + strcpy(name, XATTR_SECURITY_PREFIX); + strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); + err = __btrfs_setxattr(inode, name, value, len, 0); + kfree(name); + } + + kfree(suffix); + kfree(value); + return err; +} |