blob: 19f134e896a9a8bdd69a387015819e4ebc3c2705 [file] [log] [blame]
Tiger Yangcf1d6c72008-08-18 17:11:00 +08001/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * xattr.h
5 *
Tiger Yangc3cb6822008-10-23 16:33:03 +08006 * Copyright (C) 2004, 2008 Oracle. All rights reserved.
Tiger Yangcf1d6c72008-08-18 17:11:00 +08007 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
Tiger Yangc3cb6822008-10-23 16:33:03 +080010 * License version 2 as published by the Free Software Foundation.
Tiger Yangcf1d6c72008-08-18 17:11:00 +080011 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
Tiger Yangcf1d6c72008-08-18 17:11:00 +080016 */
17
18#ifndef OCFS2_XATTR_H
19#define OCFS2_XATTR_H
20
21#include <linux/init.h>
22#include <linux/xattr.h>
23
24enum ocfs2_xattr_type {
25 OCFS2_XATTR_INDEX_USER = 1,
26 OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS,
27 OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT,
28 OCFS2_XATTR_INDEX_TRUSTED,
29 OCFS2_XATTR_INDEX_SECURITY,
30 OCFS2_XATTR_MAX
31};
32
Tiger Yang534eadd2008-11-14 11:16:41 +080033struct ocfs2_security_xattr_info {
34 int enable;
Tetsuo Handa95489062013-07-25 05:44:02 +090035 const char *name;
Tiger Yang534eadd2008-11-14 11:16:41 +080036 void *value;
37 size_t value_len;
38};
39
Stephen Hemminger537d81c2010-05-13 17:53:22 -070040extern const struct xattr_handler ocfs2_xattr_user_handler;
41extern const struct xattr_handler ocfs2_xattr_trusted_handler;
42extern const struct xattr_handler ocfs2_xattr_security_handler;
43extern const struct xattr_handler ocfs2_xattr_acl_access_handler;
44extern const struct xattr_handler ocfs2_xattr_acl_default_handler;
45extern const struct xattr_handler *ocfs2_xattr_handlers[];
Tiger Yangcf1d6c72008-08-18 17:11:00 +080046
Tiger Yang0030e002008-10-23 16:33:33 +080047ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
Tiger Yang4e3e9d02008-11-14 11:16:53 +080048int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
49 const char *, void *, size_t);
Tiger Yang0030e002008-10-23 16:33:33 +080050int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
51 size_t, int);
Tiger Yang6c3faba2008-11-14 11:16:03 +080052int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
53 int, const char *, const void *, size_t, int,
54 struct ocfs2_alloc_context *,
55 struct ocfs2_alloc_context *);
Tao Ma8b2c0db2009-08-18 11:43:49 +080056int ocfs2_has_inline_xattr_value_outside(struct inode *inode,
57 struct ocfs2_dinode *di);
Tiger Yang0030e002008-10-23 16:33:33 +080058int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
Tiger Yang534eadd2008-11-14 11:16:41 +080059int ocfs2_init_security_get(struct inode *, struct inode *,
Eric Paris2a7dba32011-02-01 11:05:39 -050060 const struct qstr *,
Tiger Yang534eadd2008-11-14 11:16:41 +080061 struct ocfs2_security_xattr_info *);
62int ocfs2_init_security_set(handle_t *, struct inode *,
63 struct buffer_head *,
64 struct ocfs2_security_xattr_info *,
65 struct ocfs2_alloc_context *,
66 struct ocfs2_alloc_context *);
67int ocfs2_calc_security_init(struct inode *,
68 struct ocfs2_security_xattr_info *,
69 int *, int *, struct ocfs2_alloc_context **);
Tiger Yang89c38bd2008-11-14 11:17:41 +080070int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *,
Al Viro67697cb2011-07-26 02:55:32 -040071 umode_t, struct ocfs2_security_xattr_info *,
Mark Fasheh9b7895e2008-11-12 16:27:44 -080072 int *, int *, int *);
Tao Ma0c044f02008-08-18 17:38:50 +080073
Joel Becker2a50a742008-12-09 14:24:33 -080074/*
75 * xattrs can live inside an inode, as part of an external xattr block,
76 * or inside an xattr bucket, which is the leaf of a tree rooted in an
77 * xattr block. Some of the xattr calls, especially the value setting
78 * functions, want to treat each of these locations as equal. Let's wrap
79 * them in a structure that we can pass around instead of raw buffer_heads.
80 */
81struct ocfs2_xattr_value_buf {
82 struct buffer_head *vb_bh;
83 ocfs2_journal_access_func vb_access;
84 struct ocfs2_xattr_value_root *vb_xv;
85};
86
Tao Ma01292412009-09-21 13:04:19 +080087int ocfs2_xattr_attach_refcount_tree(struct inode *inode,
88 struct buffer_head *fe_bh,
89 struct ocfs2_caching_info *ref_ci,
90 struct buffer_head *ref_root_bh,
91 struct ocfs2_cached_dealloc_ctxt *dealloc);
Tao Ma2999d122009-08-18 11:43:55 +080092int ocfs2_reflink_xattrs(struct inode *old_inode,
93 struct buffer_head *old_bh,
94 struct inode *new_inode,
Tao Ma0fe9b662009-08-18 11:47:56 +080095 struct buffer_head *new_bh,
96 bool preserve_security);
97int ocfs2_init_security_and_acl(struct inode *dir,
Eric Paris2a7dba32011-02-01 11:05:39 -050098 struct inode *inode,
99 const struct qstr *qstr);
Tiger Yangcf1d6c72008-08-18 17:11:00 +0800100#endif /* OCFS2_XATTR_H */