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