Blame view

fs/ext2/xattr_security.c 1.4 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
  /*
   * linux/fs/ext2/xattr_security.c
   * Handler for storing security labels as extended attributes.
   */
f7699f2b0   Al Viro   migrate ext2_fs.h...
5
  #include "ext2.h"
10f47e6a1   Stephen Smalley   [PATCH] ext2: Ena...
6
  #include <linux/security.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
  #include "xattr.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
  static int
d9a82a040   Andreas Gruenbacher   xattr handlers: P...
9
  ext2_xattr_security_get(const struct xattr_handler *handler,
b296821a7   Al Viro   xattr_handler: pa...
10
11
  			struct dentry *unused, struct inode *inode,
  			const char *name, void *buffer, size_t size)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
  {
b296821a7   Al Viro   xattr_handler: pa...
13
  	return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
17
  			      buffer, size);
  }
  
  static int
d9a82a040   Andreas Gruenbacher   xattr handlers: P...
18
  ext2_xattr_security_set(const struct xattr_handler *handler,
593012268   Al Viro   switch xattr_hand...
19
20
21
  			struct dentry *unused, struct inode *inode,
  			const char *name, const void *value,
  			size_t size, int flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
  {
593012268   Al Viro   switch xattr_hand...
23
  	return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
  			      value, size, flags);
  }
17cd48e48   Rashika Kheria   fs: Mark function...
26
27
  static int ext2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
  			   void *fs_info)
10f47e6a1   Stephen Smalley   [PATCH] ext2: Ena...
28
  {
9d8f13ba3   Mimi Zohar   security: new sec...
29
30
  	const struct xattr *xattr;
  	int err = 0;
10f47e6a1   Stephen Smalley   [PATCH] ext2: Ena...
31

9d8f13ba3   Mimi Zohar   security: new sec...
32
33
34
35
36
37
  	for (xattr = xattr_array; xattr->name != NULL; xattr++) {
  		err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY,
  				     xattr->name, xattr->value,
  				     xattr->value_len, 0);
  		if (err < 0)
  			break;
10f47e6a1   Stephen Smalley   [PATCH] ext2: Ena...
38
  	}
10f47e6a1   Stephen Smalley   [PATCH] ext2: Ena...
39
40
  	return err;
  }
9d8f13ba3   Mimi Zohar   security: new sec...
41
42
43
44
45
46
47
  int
  ext2_init_security(struct inode *inode, struct inode *dir,
  		   const struct qstr *qstr)
  {
  	return security_inode_init_security(inode, dir, qstr,
  					    &ext2_initxattrs, NULL);
  }
749c72efa   Stephen Hemminger   ext2: constify xa...
48
  const struct xattr_handler ext2_xattr_security_handler = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
  	.prefix	= XATTR_SECURITY_PREFIX,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
51
52
  	.get	= ext2_xattr_security_get,
  	.set	= ext2_xattr_security_set,
  };