netfilter: fix ebtables dependencies
[linux-2.6/mini2440.git] / fs / reiserfs / xattr_trusted.c
blob60abe2bb1f980bbb11de6d2b161ea16946bc595a
1 #include <linux/reiserfs_fs.h>
2 #include <linux/capability.h>
3 #include <linux/errno.h>
4 #include <linux/fs.h>
5 #include <linux/pagemap.h>
6 #include <linux/xattr.h>
7 #include <linux/reiserfs_xattr.h>
8 #include <asm/uaccess.h>
10 static int
11 trusted_get(struct inode *inode, const char *name, void *buffer, size_t size)
13 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
14 return -EINVAL;
16 if (!reiserfs_xattrs(inode->i_sb))
17 return -EOPNOTSUPP;
19 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
20 return -EPERM;
22 return reiserfs_xattr_get(inode, name, buffer, size);
25 static int
26 trusted_set(struct inode *inode, const char *name, const void *buffer,
27 size_t size, int flags)
29 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
30 return -EINVAL;
32 if (!reiserfs_xattrs(inode->i_sb))
33 return -EOPNOTSUPP;
35 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
36 return -EPERM;
38 return reiserfs_xattr_set(inode, name, buffer, size, flags);
41 static int trusted_del(struct inode *inode, const char *name)
43 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
44 return -EINVAL;
46 if (!reiserfs_xattrs(inode->i_sb))
47 return -EOPNOTSUPP;
49 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
50 return -EPERM;
52 return 0;
55 static int
56 trusted_list(struct inode *inode, const char *name, int namelen, char *out)
58 int len = namelen;
60 if (!reiserfs_xattrs(inode->i_sb))
61 return 0;
63 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
64 return 0;
66 if (out)
67 memcpy(out, name, len);
69 return len;
72 struct reiserfs_xattr_handler trusted_handler = {
73 .prefix = XATTR_TRUSTED_PREFIX,
74 .get = trusted_get,
75 .set = trusted_set,
76 .del = trusted_del,
77 .list = trusted_list,