]> git.sesse.net Git - bcachefs-tools-debian/blob - c_src/include/linux/xattr.h
rust: bump rpassword to v7.x
[bcachefs-tools-debian] / c_src / 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 struct user_namespace;
30
31 /*
32  * struct xattr_handler: When @name is set, match attributes with exactly that
33  * name.  When @prefix is set instead, match attributes with that prefix and
34  * with a non-empty suffix.
35  */
36 struct xattr_handler {
37         const char *name;
38         const char *prefix;
39         int flags;      /* fs private flags */
40         bool (*list)(struct dentry *dentry);
41         int (*get)(const struct xattr_handler *, struct dentry *dentry,
42                    struct inode *inode, const char *name, void *buffer,
43                    size_t size);
44         int (*set)(const struct xattr_handler *,
45                    struct mnt_idmap *idmap, struct dentry *dentry,
46                    struct inode *inode, const char *name, const void *buffer,
47                    size_t size, int flags);
48 };
49
50 const char *xattr_full_name(const struct xattr_handler *, const char *);
51
52 struct xattr {
53         const char *name;
54         void *value;
55         size_t value_len;
56 };
57
58 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
59 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
60 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
61 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
62 int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int);
63 int vfs_removexattr(struct dentry *, const char *);
64
65 ssize_t generic_getxattr(struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size);
66 ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
67 int generic_setxattr(struct dentry *dentry, struct inode *inode,
68                      const char *name, const void *value, size_t size, int flags);
69 int generic_removexattr(struct dentry *dentry, const char *name);
70 ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name,
71                            char **xattr_value, size_t size, gfp_t flags);
72
73 static inline const char *xattr_prefix(const struct xattr_handler *handler)
74 {
75         return handler->prefix ?: handler->name;
76 }
77
78 #endif  /* _LINUX_XATTR_H */