Blame view
fs/ext2/xattr_trusted.c
1.5 KB
1da177e4c
|
1 2 3 4 5 6 7 8 9 |
/* * linux/fs/ext2/xattr_trusted.c * Handler for trusted extended attributes. * * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org> */ #include <linux/module.h> #include <linux/string.h> |
16f7e0fe2
|
10 |
#include <linux/capability.h> |
1da177e4c
|
11 |
#include <linux/fs.h> |
1da177e4c
|
12 13 |
#include <linux/ext2_fs.h> #include "xattr.h" |
1da177e4c
|
14 |
static size_t |
431547b3c
|
15 16 |
ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, const char *name, size_t name_len, int type) |
1da177e4c
|
17 |
{ |
f905f06fc
|
18 |
const int prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
1da177e4c
|
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
const size_t total_len = prefix_len + name_len + 1; if (!capable(CAP_SYS_ADMIN)) return 0; if (list && total_len <= list_size) { memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len); memcpy(list+prefix_len, name, name_len); list[prefix_len + name_len] = '\0'; } return total_len; } static int |
431547b3c
|
33 34 |
ext2_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) |
1da177e4c
|
35 36 37 |
{ if (strcmp(name, "") == 0) return -EINVAL; |
431547b3c
|
38 |
return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, |
1da177e4c
|
39 40 41 42 |
buffer, size); } static int |
431547b3c
|
43 44 |
ext2_xattr_trusted_set(struct dentry *dentry, const char *name, const void *value, size_t size, int flags, int type) |
1da177e4c
|
45 46 47 |
{ if (strcmp(name, "") == 0) return -EINVAL; |
431547b3c
|
48 |
return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, |
1da177e4c
|
49 50 |
value, size, flags); } |
749c72efa
|
51 |
const struct xattr_handler ext2_xattr_trusted_handler = { |
1da177e4c
|
52 53 54 55 56 |
.prefix = XATTR_TRUSTED_PREFIX, .list = ext2_xattr_trusted_list, .get = ext2_xattr_trusted_get, .set = ext2_xattr_trusted_set, }; |