]> bbs.cooldavid.org Git - net-next-2.6.git/blame - fs/reiserfs/xattr_security.c
reiserfs: use generic xattr handlers
[net-next-2.6.git] / fs / reiserfs / xattr_security.c
CommitLineData
1da177e4
LT
1#include <linux/reiserfs_fs.h>
2#include <linux/errno.h>
3#include <linux/fs.h>
4#include <linux/pagemap.h>
5#include <linux/xattr.h>
6#include <linux/reiserfs_xattr.h>
7#include <asm/uaccess.h>
8
1da177e4 9static int
bd4c625c 10security_get(struct inode *inode, const char *name, void *buffer, size_t size)
1da177e4 11{
bd4c625c
LT
12 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
13 return -EINVAL;
1da177e4 14
6dfede69 15 if (IS_PRIVATE(inode))
bd4c625c 16 return -EPERM;
1da177e4 17
bd4c625c 18 return reiserfs_xattr_get(inode, name, buffer, size);
1da177e4
LT
19}
20
21static int
bd4c625c
LT
22security_set(struct inode *inode, const char *name, const void *buffer,
23 size_t size, int flags)
1da177e4 24{
bd4c625c
LT
25 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
26 return -EINVAL;
1da177e4 27
6dfede69 28 if (IS_PRIVATE(inode))
bd4c625c 29 return -EPERM;
1da177e4 30
bd4c625c 31 return reiserfs_xattr_set(inode, name, buffer, size, flags);
1da177e4
LT
32}
33
48b32a35
JM
34static size_t security_list(struct inode *inode, char *list, size_t list_len,
35 const char *name, size_t namelen)
1da177e4 36{
48b32a35 37 const size_t len = namelen + 1;
1da177e4 38
6dfede69 39 if (IS_PRIVATE(inode))
bd4c625c 40 return 0;
1da177e4 41
48b32a35
JM
42 if (list && len <= list_len) {
43 memcpy(list, name, namelen);
44 list[namelen] = '\0';
45 }
1da177e4 46
bd4c625c 47 return len;
1da177e4
LT
48}
49
48b32a35 50struct xattr_handler reiserfs_xattr_security_handler = {
1da177e4
LT
51 .prefix = XATTR_SECURITY_PREFIX,
52 .get = security_get,
53 .set = security_set,
1da177e4
LT
54 .list = security_list,
55};