]> git.sesse.net Git - bcachefs-tools-debian/blob - include/linux/xattr.h
Add upstream files
[bcachefs-tools-debian] / include / linux / xattr.h
1 /*
2   File: linux/xattr.h
3
4   Extended attributes handling.
5
6   Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
7   Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
8   Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
9 */
10 #ifndef _LINUX_XATTR_H
11 #define _LINUX_XATTR_H
12
13
14 #include <linux/slab.h>
15 #include <linux/types.h>
16 #include <linux/spinlock.h>
17 #include <uapi/linux/xattr.h>
18
19 #ifndef XATTR_CREATE
20 #define XATTR_CREATE    0x1
21 #endif
22
23 #ifndef XATTR_REPLACE
24 #define XATTR_REPLACE   0x2
25 #endif
26
27 struct inode;
28 struct dentry;
29
30 /*
31  * struct xattr_handler: When @name is set, match attributes with exactly that
32  * name.  When @prefix is set instead, match attributes with that prefix and
33  * with a non-empty suffix.
34  */
35 struct xattr_handler {
36         const char *name;
37         const char *prefix;
38         int flags;      /* fs private flags */
39         bool (*list)(struct dentry *dentry);
40         int (*get)(const struct xattr_handler *, struct dentry *dentry,
41                    struct inode *inode, const char *name, void *buffer,
42                    size_t size);
43         int (*set)(const struct xattr_handler *, struct dentry *dentry,
44                    struct inode *inode, const char *name, const void *buffer,
45                    size_t size, int flags);
46 };
47
48 const char *xattr_full_name(const struct xattr_handler *, const char *);
49
50 struct xattr {
51         const char *name;
52         void *value;
53         size_t value_len;
54 };
55
56 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
57 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
58 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
59 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
60 int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int);
61 int vfs_removexattr(struct dentry *, const char *);
62
63 ssize_t generic_getxattr(struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size);
64 ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
65 int generic_setxattr(struct dentry *dentry, struct inode *inode,
66                      const char *name, const void *value, size_t size, int flags);
67 int generic_removexattr(struct dentry *dentry, const char *name);
68 ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name,
69                            char **xattr_value, size_t size, gfp_t flags);
70
71 static inline const char *xattr_prefix(const struct xattr_handler *handler)
72 {
73         return handler->prefix ?: handler->name;
74 }
75
76 #endif  /* _LINUX_XATTR_H */