blob: 9c80382da1f5062c7e8eeaf8f0fcf21dcb463fc8 [file] [log] [blame]
Thomas Gleixner1802d0b2019-05-27 08:55:21 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Tiger Yangcf1d6c72008-08-18 17:11:00 +08002/* -*- mode: c; c-basic-offset: 8; -*-
3 * vim: noexpandtab sw=8 ts=8 sts=0:
4 *
5 * xattr.h
6 *
Tiger Yangc3cb6822008-10-23 16:33:03 +08007 * Copyright (C) 2004, 2008 Oracle. All rights reserved.
Tiger Yangcf1d6c72008-08-18 17:11:00 +08008 */
9
10#ifndef OCFS2_XATTR_H
11#define OCFS2_XATTR_H
12
13#include <linux/init.h>
14#include <linux/xattr.h>
15
16enum ocfs2_xattr_type {
17 OCFS2_XATTR_INDEX_USER = 1,
18 OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS,
19 OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT,
20 OCFS2_XATTR_INDEX_TRUSTED,
21 OCFS2_XATTR_INDEX_SECURITY,
22 OCFS2_XATTR_MAX
23};
24
Tiger Yang534eadd2008-11-14 11:16:41 +080025struct ocfs2_security_xattr_info {
26 int enable;
Tetsuo Handa95489062013-07-25 05:44:02 +090027 const char *name;
Tiger Yang534eadd2008-11-14 11:16:41 +080028 void *value;
29 size_t value_len;
30};
31
Stephen Hemminger537d81c2010-05-13 17:53:22 -070032extern const struct xattr_handler ocfs2_xattr_user_handler;
33extern const struct xattr_handler ocfs2_xattr_trusted_handler;
34extern const struct xattr_handler ocfs2_xattr_security_handler;
Stephen Hemminger537d81c2010-05-13 17:53:22 -070035extern const struct xattr_handler *ocfs2_xattr_handlers[];
Tiger Yangcf1d6c72008-08-18 17:11:00 +080036
Tiger Yang0030e002008-10-23 16:33:33 +080037ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
Tiger Yang4e3e9d02008-11-14 11:16:53 +080038int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
39 const char *, void *, size_t);
Tiger Yang0030e002008-10-23 16:33:33 +080040int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
41 size_t, int);
Tiger Yang6c3faba2008-11-14 11:16:03 +080042int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
43 int, const char *, const void *, size_t, int,
44 struct ocfs2_alloc_context *,
45 struct ocfs2_alloc_context *);
Tao Ma8b2c0db2009-08-18 11:43:49 +080046int ocfs2_has_inline_xattr_value_outside(struct inode *inode,
47 struct ocfs2_dinode *di);
Tiger Yang0030e002008-10-23 16:33:33 +080048int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
Tiger Yang534eadd2008-11-14 11:16:41 +080049int ocfs2_init_security_get(struct inode *, struct inode *,
Eric Paris2a7dba32011-02-01 11:05:39 -050050 const struct qstr *,
Tiger Yang534eadd2008-11-14 11:16:41 +080051 struct ocfs2_security_xattr_info *);
52int ocfs2_init_security_set(handle_t *, struct inode *,
53 struct buffer_head *,
54 struct ocfs2_security_xattr_info *,
55 struct ocfs2_alloc_context *,
56 struct ocfs2_alloc_context *);
57int ocfs2_calc_security_init(struct inode *,
58 struct ocfs2_security_xattr_info *,
59 int *, int *, struct ocfs2_alloc_context **);
Tiger Yang89c38bd2008-11-14 11:17:41 +080060int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *,
Al Viro67697cb2011-07-26 02:55:32 -040061 umode_t, struct ocfs2_security_xattr_info *,
Mark Fasheh9b7895e2008-11-12 16:27:44 -080062 int *, int *, int *);
Tao Ma0c044f02008-08-18 17:38:50 +080063
Joel Becker2a50a742008-12-09 14:24:33 -080064/*
65 * xattrs can live inside an inode, as part of an external xattr block,
66 * or inside an xattr bucket, which is the leaf of a tree rooted in an
67 * xattr block. Some of the xattr calls, especially the value setting
68 * functions, want to treat each of these locations as equal. Let's wrap
69 * them in a structure that we can pass around instead of raw buffer_heads.
70 */
71struct ocfs2_xattr_value_buf {
72 struct buffer_head *vb_bh;
73 ocfs2_journal_access_func vb_access;
74 struct ocfs2_xattr_value_root *vb_xv;
75};
76
Tao Ma01292412009-09-21 13:04:19 +080077int ocfs2_xattr_attach_refcount_tree(struct inode *inode,
78 struct buffer_head *fe_bh,
79 struct ocfs2_caching_info *ref_ci,
80 struct buffer_head *ref_root_bh,
81 struct ocfs2_cached_dealloc_ctxt *dealloc);
Tao Ma2999d122009-08-18 11:43:55 +080082int ocfs2_reflink_xattrs(struct inode *old_inode,
83 struct buffer_head *old_bh,
84 struct inode *new_inode,
Tao Ma0fe9b662009-08-18 11:47:56 +080085 struct buffer_head *new_bh,
86 bool preserve_security);
87int ocfs2_init_security_and_acl(struct inode *dir,
Eric Paris2a7dba32011-02-01 11:05:39 -050088 struct inode *inode,
Junxiao Bic25a1e02016-05-12 15:42:18 -070089 const struct qstr *qstr);
Tiger Yangcf1d6c72008-08-18 17:11:00 +080090#endif /* OCFS2_XATTR_H */