xref: /openbmc/linux/fs/ocfs2/xattr.h (revision c25a1e06)
1cf1d6c76STiger Yang /* -*- mode: c; c-basic-offset: 8; -*-
2cf1d6c76STiger Yang  * vim: noexpandtab sw=8 ts=8 sts=0:
3cf1d6c76STiger Yang  *
4cf1d6c76STiger Yang  * xattr.h
5cf1d6c76STiger Yang  *
6c3cb6827STiger Yang  * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
7cf1d6c76STiger Yang  *
8cf1d6c76STiger Yang  * This program is free software; you can redistribute it and/or
9cf1d6c76STiger Yang  * modify it under the terms of the GNU General Public
10c3cb6827STiger Yang  * License version 2 as published by the Free Software Foundation.
11cf1d6c76STiger Yang  *
12cf1d6c76STiger Yang  * This program is distributed in the hope that it will be useful,
13cf1d6c76STiger Yang  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cf1d6c76STiger Yang  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cf1d6c76STiger Yang  * General Public License for more details.
16cf1d6c76STiger Yang  */
17cf1d6c76STiger Yang 
18cf1d6c76STiger Yang #ifndef OCFS2_XATTR_H
19cf1d6c76STiger Yang #define OCFS2_XATTR_H
20cf1d6c76STiger Yang 
21cf1d6c76STiger Yang #include <linux/init.h>
22cf1d6c76STiger Yang #include <linux/xattr.h>
23cf1d6c76STiger Yang 
24cf1d6c76STiger Yang enum ocfs2_xattr_type {
25cf1d6c76STiger Yang 	OCFS2_XATTR_INDEX_USER = 1,
26cf1d6c76STiger Yang 	OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS,
27cf1d6c76STiger Yang 	OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT,
28cf1d6c76STiger Yang 	OCFS2_XATTR_INDEX_TRUSTED,
29cf1d6c76STiger Yang 	OCFS2_XATTR_INDEX_SECURITY,
30cf1d6c76STiger Yang 	OCFS2_XATTR_MAX
31cf1d6c76STiger Yang };
32cf1d6c76STiger Yang 
33534eadddSTiger Yang struct ocfs2_security_xattr_info {
34534eadddSTiger Yang 	int enable;
359548906bSTetsuo Handa 	const char *name;
36534eadddSTiger Yang 	void *value;
37534eadddSTiger Yang 	size_t value_len;
38534eadddSTiger Yang };
39534eadddSTiger Yang 
40537d81caSStephen Hemminger extern const struct xattr_handler ocfs2_xattr_user_handler;
41537d81caSStephen Hemminger extern const struct xattr_handler ocfs2_xattr_trusted_handler;
42537d81caSStephen Hemminger extern const struct xattr_handler ocfs2_xattr_security_handler;
43537d81caSStephen Hemminger extern const struct xattr_handler *ocfs2_xattr_handlers[];
44cf1d6c76STiger Yang 
450030e001STiger Yang ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
464e3e9d02STiger Yang int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
474e3e9d02STiger Yang 			   const char *, void *, size_t);
480030e001STiger Yang int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
490030e001STiger Yang 		    size_t, int);
506c3faba4STiger Yang int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
516c3faba4STiger Yang 			   int, const char *, const void *, size_t, int,
526c3faba4STiger Yang 			   struct ocfs2_alloc_context *,
536c3faba4STiger Yang 			   struct ocfs2_alloc_context *);
548b2c0dbaSTao Ma int ocfs2_has_inline_xattr_value_outside(struct inode *inode,
558b2c0dbaSTao Ma 					 struct ocfs2_dinode *di);
560030e001STiger Yang int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
57534eadddSTiger Yang int ocfs2_init_security_get(struct inode *, struct inode *,
582a7dba39SEric Paris 			    const struct qstr *,
59534eadddSTiger Yang 			    struct ocfs2_security_xattr_info *);
60534eadddSTiger Yang int ocfs2_init_security_set(handle_t *, struct inode *,
61534eadddSTiger Yang 			    struct buffer_head *,
62534eadddSTiger Yang 			    struct ocfs2_security_xattr_info *,
63534eadddSTiger Yang 			    struct ocfs2_alloc_context *,
64534eadddSTiger Yang 			    struct ocfs2_alloc_context *);
65534eadddSTiger Yang int ocfs2_calc_security_init(struct inode *,
66534eadddSTiger Yang 			     struct ocfs2_security_xattr_info *,
67534eadddSTiger Yang 			     int *, int *, struct ocfs2_alloc_context **);
6889c38bd0STiger Yang int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *,
6967697cbdSAl Viro 			  umode_t, struct ocfs2_security_xattr_info *,
709b7895efSMark Fasheh 			  int *, int *, int *);
710c044f0bSTao Ma 
722a50a743SJoel Becker /*
732a50a743SJoel Becker  * xattrs can live inside an inode, as part of an external xattr block,
742a50a743SJoel Becker  * or inside an xattr bucket, which is the leaf of a tree rooted in an
752a50a743SJoel Becker  * xattr block.  Some of the xattr calls, especially the value setting
762a50a743SJoel Becker  * functions, want to treat each of these locations as equal.  Let's wrap
772a50a743SJoel Becker  * them in a structure that we can pass around instead of raw buffer_heads.
782a50a743SJoel Becker  */
792a50a743SJoel Becker struct ocfs2_xattr_value_buf {
802a50a743SJoel Becker 	struct buffer_head		*vb_bh;
812a50a743SJoel Becker 	ocfs2_journal_access_func	vb_access;
822a50a743SJoel Becker 	struct ocfs2_xattr_value_root	*vb_xv;
832a50a743SJoel Becker };
842a50a743SJoel Becker 
850129241eSTao Ma int ocfs2_xattr_attach_refcount_tree(struct inode *inode,
860129241eSTao Ma 				     struct buffer_head *fe_bh,
870129241eSTao Ma 				     struct ocfs2_caching_info *ref_ci,
880129241eSTao Ma 				     struct buffer_head *ref_root_bh,
890129241eSTao Ma 				     struct ocfs2_cached_dealloc_ctxt *dealloc);
902999d12fSTao Ma int ocfs2_reflink_xattrs(struct inode *old_inode,
912999d12fSTao Ma 			 struct buffer_head *old_bh,
922999d12fSTao Ma 			 struct inode *new_inode,
930fe9b66cSTao Ma 			 struct buffer_head *new_bh,
940fe9b66cSTao Ma 			 bool preserve_security);
950fe9b66cSTao Ma int ocfs2_init_security_and_acl(struct inode *dir,
962a7dba39SEric Paris 				struct inode *inode,
97c25a1e06SJunxiao Bi 				const struct qstr *qstr);
98cf1d6c76STiger Yang #endif /* OCFS2_XATTR_H */
99