Blame view
fs/reiserfs/xattr_security.c
2.74 KB
f466c6fdb move private bits... |
1 |
#include "reiserfs.h" |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 |
#include <linux/errno.h> #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/xattr.h> |
5a0e3ad6a include cleanup: ... |
6 |
#include <linux/slab.h> |
c45ac8887 take private bits... |
7 |
#include "xattr.h" |
57fe60df6 reiserfs: add ato... |
8 |
#include <linux/security.h> |
17093991a fs/reiserfs: use ... |
9 |
#include <linux/uaccess.h> |
1da177e4c Linux-2.6.12-rc2 |
10 |
|
1da177e4c Linux-2.6.12-rc2 |
11 |
static int |
d9a82a040 xattr handlers: P... |
12 13 |
security_get(const struct xattr_handler *handler, struct dentry *dentry, const char *name, void *buffer, size_t size) |
1da177e4c Linux-2.6.12-rc2 |
14 |
{ |
bd4c625c0 reiserfs: run scr... |
15 16 |
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
17 |
|
2b0143b5c VFS: normal files... |
18 |
if (IS_PRIVATE(d_inode(dentry))) |
bd4c625c0 reiserfs: run scr... |
19 |
return -EPERM; |
1da177e4c Linux-2.6.12-rc2 |
20 |
|
2b0143b5c VFS: normal files... |
21 |
return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); |
1da177e4c Linux-2.6.12-rc2 |
22 23 24 |
} static int |
d9a82a040 xattr handlers: P... |
25 26 |
security_set(const struct xattr_handler *handler, struct dentry *dentry, const char *name, const void *buffer, size_t size, int flags) |
1da177e4c Linux-2.6.12-rc2 |
27 |
{ |
bd4c625c0 reiserfs: run scr... |
28 29 |
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
30 |
|
2b0143b5c VFS: normal files... |
31 |
if (IS_PRIVATE(d_inode(dentry))) |
bd4c625c0 reiserfs: run scr... |
32 |
return -EPERM; |
1da177e4c Linux-2.6.12-rc2 |
33 |
|
2b0143b5c VFS: normal files... |
34 |
return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); |
1da177e4c Linux-2.6.12-rc2 |
35 |
} |
764a5c6b1 xattr handlers: S... |
36 |
static bool security_list(struct dentry *dentry) |
1da177e4c Linux-2.6.12-rc2 |
37 |
{ |
764a5c6b1 xattr handlers: S... |
38 |
return !IS_PRIVATE(d_inode(dentry)); |
1da177e4c Linux-2.6.12-rc2 |
39 |
} |
57fe60df6 reiserfs: add ato... |
40 41 42 43 |
/* Initializes the security context for a new inode and returns the number * of blocks needed for the transaction. If successful, reiserfs_security * must be released using reiserfs_security_free when the caller is done. */ int reiserfs_security_init(struct inode *dir, struct inode *inode, |
2a7dba391 fs/vfs/security: ... |
44 |
const struct qstr *qstr, |
57fe60df6 reiserfs: add ato... |
45 46 47 |
struct reiserfs_security_handle *sec) { int blocks = 0; |
b82bb72ba reiserfs: dont as... |
48 49 50 51 52 53 54 |
int error; sec->name = NULL; /* Don't add selinux attributes on xattrs - they'll never get used */ if (IS_PRIVATE(dir)) return 0; |
9d8f13ba3 security: new sec... |
55 56 |
error = security_old_inode_init_security(inode, dir, qstr, &sec->name, &sec->value, &sec->length); |
57fe60df6 reiserfs: add ato... |
57 58 59 60 61 62 63 64 65 |
if (error) { if (error == -EOPNOTSUPP) error = 0; sec->name = NULL; sec->value = NULL; sec->length = 0; return error; } |
6cb4aff0a reiserfs: fix oop... |
66 |
if (sec->length && reiserfs_xattrs_initialized(inode->i_sb)) { |
57fe60df6 reiserfs: add ato... |
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
blocks = reiserfs_xattr_jcreate_nblocks(inode) + reiserfs_xattr_nblocks(inode, sec->length); /* We don't want to count the directories twice if we have * a default ACL. */ REISERFS_I(inode)->i_flags |= i_has_xattr_dir; } return blocks; } int reiserfs_security_write(struct reiserfs_transaction_handle *th, struct inode *inode, struct reiserfs_security_handle *sec) { int error; if (strlen(sec->name) < sizeof(XATTR_SECURITY_PREFIX)) return -EINVAL; error = reiserfs_xattr_set_handle(th, inode, sec->name, sec->value, sec->length, XATTR_CREATE); if (error == -ENODATA || error == -EOPNOTSUPP) error = 0; return error; } void reiserfs_security_free(struct reiserfs_security_handle *sec) { kfree(sec->name); kfree(sec->value); sec->name = NULL; sec->value = NULL; } |
94d09a98c reiserfs: constif... |
99 |
const struct xattr_handler reiserfs_xattr_security_handler = { |
1da177e4c Linux-2.6.12-rc2 |
100 101 102 |
.prefix = XATTR_SECURITY_PREFIX, .get = security_get, .set = security_set, |
1da177e4c Linux-2.6.12-rc2 |
103 104 |
.list = security_list, }; |