Merge tag 'md-3.7' of git://neil.brown.name/md
[firefly-linux-kernel-4.4.55.git] / include / linux / xattr.h
index 77a3e686d56627cba522616bd9425ae551b0ce35..cc13e1115970455e4240ff09e69d34f610cf337d 100644 (file)
@@ -62,7 +62,9 @@
 
 #ifdef  __KERNEL__
 
+#include <linux/slab.h>
 #include <linux/types.h>
+#include <linux/spinlock.h>
 
 struct inode;
 struct dentry;
@@ -99,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 */