xref: /linux/fs/ocfs2/xattr.h (revision d637475617d8468c2740a3436428681bcc8d3572)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * xattr.h
4  *
5  * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
6  */
7 
8 #ifndef OCFS2_XATTR_H
9 #define OCFS2_XATTR_H
10 
11 #include <linux/init.h>
12 #include <linux/xattr.h>
13 
14 enum ocfs2_xattr_type {
15 	OCFS2_XATTR_INDEX_USER = 1,
16 	OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS,
17 	OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT,
18 	OCFS2_XATTR_INDEX_TRUSTED,
19 	OCFS2_XATTR_INDEX_SECURITY,
20 	OCFS2_XATTR_MAX
21 };
22 
23 struct ocfs2_security_xattr {
24 	char *name;
25 	void *value;
26 	size_t value_len;
27 };
28 
29 struct ocfs2_security_xattr_info {
30 	int enable;
31 	struct ocfs2_security_xattr *xattrs;
32 	int count;
33 };
34 
35 extern const struct xattr_handler ocfs2_xattr_user_handler;
36 extern const struct xattr_handler ocfs2_xattr_trusted_handler;
37 extern const struct xattr_handler ocfs2_xattr_security_handler;
38 extern const struct xattr_handler * const ocfs2_xattr_handlers[];
39 
40 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
41 int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
42 			   const char *, void *, size_t);
43 int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
44 		    size_t, int);
45 int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
46 			   int, const char *, const void *, size_t, int,
47 			   struct ocfs2_alloc_context *,
48 			   struct ocfs2_alloc_context *);
49 int ocfs2_has_inline_xattr_value_outside(struct inode *inode,
50 					 struct ocfs2_dinode *di);
51 int ocfs2_validate_inode_xattr(struct super_block *sb, u64 blkno,
52 			       struct ocfs2_dinode *di);
53 int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
54 int ocfs2_init_security_get(struct inode *, struct inode *,
55 			    const struct qstr *,
56 			    struct ocfs2_security_xattr_info *);
57 void ocfs2_free_security_xattrs(struct ocfs2_security_xattr_info *);
58 int ocfs2_init_security_set(handle_t *, struct inode *,
59 			    struct buffer_head *,
60 			    struct ocfs2_security_xattr_info *,
61 			    struct ocfs2_alloc_context *,
62 			    struct ocfs2_alloc_context *);
63 int ocfs2_calc_security_init(struct inode *,
64 			     struct ocfs2_security_xattr_info *,
65 			     int *, int *, struct ocfs2_alloc_context **);
66 
67 struct ocfs2_acl_state;
68 void ocfs2_calc_xattr_init(struct inode *dir, umode_t mode,
69 			   struct ocfs2_security_xattr_info *si,
70 			   int *want_clusters, int *xattr_credits,
71 			   int *want_meta, struct ocfs2_acl_state *acl_state);
72 
73 /*
74  * xattrs can live inside an inode, as part of an external xattr block,
75  * or inside an xattr bucket, which is the leaf of a tree rooted in an
76  * xattr block.  Some of the xattr calls, especially the value setting
77  * functions, want to treat each of these locations as equal.  Let's wrap
78  * them in a structure that we can pass around instead of raw buffer_heads.
79  */
80 struct ocfs2_xattr_value_buf {
81 	struct buffer_head		*vb_bh;
82 	ocfs2_journal_access_func	vb_access;
83 	struct ocfs2_xattr_value_root	*vb_xv;
84 };
85 
86 int ocfs2_xattr_attach_refcount_tree(struct inode *inode,
87 				     struct buffer_head *fe_bh,
88 				     struct ocfs2_caching_info *ref_ci,
89 				     struct buffer_head *ref_root_bh,
90 				     struct ocfs2_cached_dealloc_ctxt *dealloc);
91 int ocfs2_reflink_xattrs(struct inode *old_inode,
92 			 struct buffer_head *old_bh,
93 			 struct inode *new_inode,
94 			 struct buffer_head *new_bh,
95 			 bool preserve_security);
96 int ocfs2_init_security_and_acl(struct inode *dir,
97 				struct inode *inode,
98 				const struct qstr *qstr);
99 #endif /* OCFS2_XATTR_H */
100