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