diff options
Diffstat (limited to 'include/linux/xattr.h')
-rw-r--r-- | include/linux/xattr.h | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/include/linux/xattr.h b/include/linux/xattr.h index e5d122031542..fdbafc6841cf 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h | |||
@@ -10,56 +10,11 @@ | |||
10 | #ifndef _LINUX_XATTR_H | 10 | #ifndef _LINUX_XATTR_H |
11 | #define _LINUX_XATTR_H | 11 | #define _LINUX_XATTR_H |
12 | 12 | ||
13 | #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ | ||
14 | #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ | ||
15 | |||
16 | /* Namespaces */ | ||
17 | #define XATTR_OS2_PREFIX "os2." | ||
18 | #define XATTR_OS2_PREFIX_LEN (sizeof (XATTR_OS2_PREFIX) - 1) | ||
19 | |||
20 | #define XATTR_SECURITY_PREFIX "security." | ||
21 | #define XATTR_SECURITY_PREFIX_LEN (sizeof (XATTR_SECURITY_PREFIX) - 1) | ||
22 | |||
23 | #define XATTR_SYSTEM_PREFIX "system." | ||
24 | #define XATTR_SYSTEM_PREFIX_LEN (sizeof (XATTR_SYSTEM_PREFIX) - 1) | ||
25 | |||
26 | #define XATTR_TRUSTED_PREFIX "trusted." | ||
27 | #define XATTR_TRUSTED_PREFIX_LEN (sizeof (XATTR_TRUSTED_PREFIX) - 1) | ||
28 | |||
29 | #define XATTR_USER_PREFIX "user." | ||
30 | #define XATTR_USER_PREFIX_LEN (sizeof (XATTR_USER_PREFIX) - 1) | ||
31 | |||
32 | /* Security namespace */ | ||
33 | #define XATTR_EVM_SUFFIX "evm" | ||
34 | #define XATTR_NAME_EVM XATTR_SECURITY_PREFIX XATTR_EVM_SUFFIX | ||
35 | |||
36 | #define XATTR_SELINUX_SUFFIX "selinux" | ||
37 | #define XATTR_NAME_SELINUX XATTR_SECURITY_PREFIX XATTR_SELINUX_SUFFIX | ||
38 | |||
39 | #define XATTR_SMACK_SUFFIX "SMACK64" | ||
40 | #define XATTR_SMACK_IPIN "SMACK64IPIN" | ||
41 | #define XATTR_SMACK_IPOUT "SMACK64IPOUT" | ||
42 | #define XATTR_SMACK_EXEC "SMACK64EXEC" | ||
43 | #define XATTR_SMACK_TRANSMUTE "SMACK64TRANSMUTE" | ||
44 | #define XATTR_SMACK_MMAP "SMACK64MMAP" | ||
45 | #define XATTR_NAME_SMACK XATTR_SECURITY_PREFIX XATTR_SMACK_SUFFIX | ||
46 | #define XATTR_NAME_SMACKIPIN XATTR_SECURITY_PREFIX XATTR_SMACK_IPIN | ||
47 | #define XATTR_NAME_SMACKIPOUT XATTR_SECURITY_PREFIX XATTR_SMACK_IPOUT | ||
48 | #define XATTR_NAME_SMACKEXEC XATTR_SECURITY_PREFIX XATTR_SMACK_EXEC | ||
49 | #define XATTR_NAME_SMACKTRANSMUTE XATTR_SECURITY_PREFIX XATTR_SMACK_TRANSMUTE | ||
50 | #define XATTR_NAME_SMACKMMAP XATTR_SECURITY_PREFIX XATTR_SMACK_MMAP | ||
51 | |||
52 | #define XATTR_CAPS_SUFFIX "capability" | ||
53 | #define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX | ||
54 | |||
55 | #define XATTR_POSIX_ACL_ACCESS "posix_acl_access" | ||
56 | #define XATTR_NAME_POSIX_ACL_ACCESS XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_ACCESS | ||
57 | #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default" | ||
58 | #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT | ||
59 | |||
60 | #ifdef __KERNEL__ | ||
61 | 13 | ||
14 | #include <linux/slab.h> | ||
62 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/spinlock.h> | ||
17 | #include <uapi/linux/xattr.h> | ||
63 | 18 | ||
64 | struct inode; | 19 | struct inode; |
65 | struct dentry; | 20 | struct dentry; |
@@ -96,6 +51,50 @@ ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name, | |||
96 | char **xattr_value, size_t size, gfp_t flags); | 51 | char **xattr_value, size_t size, gfp_t flags); |
97 | int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name, | 52 | int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name, |
98 | const char *value, size_t size, gfp_t flags); | 53 | const char *value, size_t size, gfp_t flags); |
99 | #endif /* __KERNEL__ */ | 54 | |
55 | struct simple_xattrs { | ||
56 | struct list_head head; | ||
57 | spinlock_t lock; | ||
58 | }; | ||
59 | |||
60 | struct simple_xattr { | ||
61 | struct list_head list; | ||
62 | char *name; | ||
63 | size_t size; | ||
64 | char value[0]; | ||
65 | }; | ||
66 | |||
67 | /* | ||
68 | * initialize the simple_xattrs structure | ||
69 | */ | ||
70 | static inline void simple_xattrs_init(struct simple_xattrs *xattrs) | ||
71 | { | ||
72 | INIT_LIST_HEAD(&xattrs->head); | ||
73 | spin_lock_init(&xattrs->lock); | ||
74 | } | ||
75 | |||
76 | /* | ||
77 | * free all the xattrs | ||
78 | */ | ||
79 | static inline void simple_xattrs_free(struct simple_xattrs *xattrs) | ||
80 | { | ||
81 | struct simple_xattr *xattr, *node; | ||
82 | |||
83 | list_for_each_entry_safe(xattr, node, &xattrs->head, list) { | ||
84 | kfree(xattr->name); | ||
85 | kfree(xattr); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | struct simple_xattr *simple_xattr_alloc(const void *value, size_t size); | ||
90 | int simple_xattr_get(struct simple_xattrs *xattrs, const char *name, | ||
91 | void *buffer, size_t size); | ||
92 | int simple_xattr_set(struct simple_xattrs *xattrs, const char *name, | ||
93 | const void *value, size_t size, int flags); | ||
94 | int simple_xattr_remove(struct simple_xattrs *xattrs, const char *name); | ||
95 | ssize_t simple_xattr_list(struct simple_xattrs *xattrs, char *buffer, | ||
96 | size_t size); | ||
97 | void simple_xattr_list_add(struct simple_xattrs *xattrs, | ||
98 | struct simple_xattr *new_xattr); | ||
100 | 99 | ||
101 | #endif /* _LINUX_XATTR_H */ | 100 | #endif /* _LINUX_XATTR_H */ |