]> git.proxmox.com Git - mirror_zfs.git/blame - include/linux/xattr_compat.h
cstyle: Resolve C style issues
[mirror_zfs.git] / include / linux / xattr_compat.h
CommitLineData
777d4af8
BB
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (C) 2011 Lawrence Livermore National Security, LLC.
24 */
25
26#ifndef _ZFS_XATTR_H
d1d7e268 27#define _ZFS_XATTR_H
777d4af8 28
023699cd
MM
29#include <linux/posix_acl_xattr.h>
30
777d4af8
BB
31/*
32 * 2.6.35 API change,
33 * The const keyword was added to the 'struct xattr_handler' in the
34 * generic Linux super_block structure. To handle this we define an
35 * appropriate xattr_handler_t typedef which can be used. This was
36 * the preferred solution because it keeps the code clean and readable.
37 */
38#ifdef HAVE_CONST_XATTR_HANDLER
39typedef const struct xattr_handler xattr_handler_t;
40#else
41typedef struct xattr_handler xattr_handler_t;
42#endif
43
f9637c6c
BB
44/*
45 * 2.6.33 API change,
46 * The xattr_hander->get() callback was changed to take a dentry
47 * instead of an inode, and a handler_flags argument was added.
48 */
49#ifdef HAVE_DENTRY_XATTR_GET
d1d7e268 50#define ZPL_XATTR_GET_WRAPPER(fn) \
f9637c6c
BB
51static int \
52fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
53 int unused_handler_flags) \
54{ \
d1d7e268 55 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
f9637c6c
BB
56}
57#else
d1d7e268 58#define ZPL_XATTR_GET_WRAPPER(fn) \
f9637c6c
BB
59static int \
60fn(struct inode *ip, const char *name, void *buffer, size_t size) \
61{ \
d1d7e268 62 return (__ ## fn(ip, name, buffer, size)); \
f9637c6c
BB
63}
64#endif /* HAVE_DENTRY_XATTR_GET */
65
66/*
67 * 2.6.33 API change,
68 * The xattr_hander->set() callback was changed to take a dentry
69 * instead of an inode, and a handler_flags argument was added.
70 */
71#ifdef HAVE_DENTRY_XATTR_SET
d1d7e268 72#define ZPL_XATTR_SET_WRAPPER(fn) \
f9637c6c
BB
73static int \
74fn(struct dentry *dentry, const char *name, const void *buffer, \
75 size_t size, int flags, int unused_handler_flags) \
76{ \
d1d7e268 77 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
f9637c6c
BB
78}
79#else
d1d7e268 80#define ZPL_XATTR_SET_WRAPPER(fn) \
f9637c6c
BB
81static int \
82fn(struct inode *ip, const char *name, const void *buffer, \
83 size_t size, int flags) \
84{ \
d1d7e268 85 return (__ ## fn(ip, name, buffer, size, flags)); \
f9637c6c
BB
86}
87#endif /* HAVE_DENTRY_XATTR_SET */
88
5c03efc3 89#ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY
d1d7e268 90#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
5c03efc3
BB
91 security_inode_init_security(ip, dip, qstr, nm, val, len)
92#else
d1d7e268 93#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
5c03efc3
BB
94 security_inode_init_security(ip, dip, nm, val, len)
95#endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */
96
023699cd
MM
97/*
98 * Linux 3.7 API change. posix_acl_{from,to}_xattr gained the user_ns
99 * parameter. For the HAVE_POSIX_ACL_FROM_XATTR_USERNS version the
100 * userns _may_ not be correct because it's used outside the RCU.
101 */
102#ifdef HAVE_POSIX_ACL_FROM_XATTR_USERNS
103static inline struct posix_acl *
104zpl_acl_from_xattr(const void *value, int size)
105{
d1d7e268 106 return (posix_acl_from_xattr(CRED()->user_ns, value, size));
023699cd
MM
107}
108
109static inline int
110zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
111{
d1d7e268 112 return (posix_acl_to_xattr(CRED()->user_ns, acl, value, size));
023699cd
MM
113}
114
115#else
116
117static inline struct posix_acl *
d1d7e268 118zpl_acl_from_xattr(const void *value, int size)
023699cd 119{
d1d7e268 120 return (posix_acl_from_xattr(value, size));
023699cd
MM
121}
122
123static inline int
124zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
125{
d1d7e268 126 return (posix_acl_to_xattr(acl, value, size));
023699cd
MM
127}
128#endif /* HAVE_POSIX_ACL_FROM_XATTR_USERNS */
129
777d4af8 130#endif /* _ZFS_XATTR_H */