Merge tag 'md-3.7' of git://neil.brown.name/md
[firefly-linux-kernel-4.4.55.git] / include / linux / xattr.h
index e5d122031542f5e3628d5a3bbbd044f0f36f51a3..cc13e1115970455e4240ff09e69d34f610cf337d 100644 (file)
@@ -33,6 +33,9 @@
 #define XATTR_EVM_SUFFIX "evm"
 #define XATTR_NAME_EVM XATTR_SECURITY_PREFIX XATTR_EVM_SUFFIX
 
+#define XATTR_IMA_SUFFIX "ima"
+#define XATTR_NAME_IMA XATTR_SECURITY_PREFIX XATTR_IMA_SUFFIX
+
 #define XATTR_SELINUX_SUFFIX "selinux"
 #define XATTR_NAME_SELINUX XATTR_SECURITY_PREFIX XATTR_SELINUX_SUFFIX
 
@@ -59,7 +62,9 @@
 
 #ifdef  __KERNEL__
 
+#include <linux/slab.h>
 #include <linux/types.h>
+#include <linux/spinlock.h>
 
 struct inode;
 struct dentry;
@@ -96,6 +101,52 @@ ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name,
                           char **xattr_value, size_t size, gfp_t flags);
 int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
                  const char *value, size_t size, gfp_t flags);
+
+struct simple_xattrs {
+       struct list_head head;
+       spinlock_t lock;
+};
+
+struct simple_xattr {
+       struct list_head list;
+       char *name;
+       size_t size;
+       char value[0];
+};
+
+/*
+ * initialize the simple_xattrs structure
+ */
+static inline void simple_xattrs_init(struct simple_xattrs *xattrs)
+{
+       INIT_LIST_HEAD(&xattrs->head);
+       spin_lock_init(&xattrs->lock);
+}
+
+/*
+ * free all the xattrs
+ */
+static inline void simple_xattrs_free(struct simple_xattrs *xattrs)
+{
+       struct simple_xattr *xattr, *node;
+
+       list_for_each_entry_safe(xattr, node, &xattrs->head, list) {
+               kfree(xattr->name);
+               kfree(xattr);
+       }
+}
+
+struct simple_xattr *simple_xattr_alloc(const void *value, size_t size);
+int simple_xattr_get(struct simple_xattrs *xattrs, const char *name,
+                    void *buffer, size_t size);
+int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
+                    const void *value, size_t size, int flags);
+int simple_xattr_remove(struct simple_xattrs *xattrs, const char *name);
+ssize_t simple_xattr_list(struct simple_xattrs *xattrs, char *buffer,
+                         size_t size);
+void simple_xattr_list_add(struct simple_xattrs *xattrs,
+                          struct simple_xattr *new_xattr);
+
 #endif  /*  __KERNEL__  */
 
 #endif /* _LINUX_XATTR_H */