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.
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.
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]
23 * Copyright (C) 2011 Lawrence Livermore National Security, LLC.
29 #include <linux/posix_acl_xattr.h>
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.
38 #ifdef HAVE_CONST_XATTR_HANDLER
39 typedef const struct xattr_handler xattr_handler_t
;
41 typedef struct xattr_handler xattr_handler_t
;
46 * The xattr_hander->get() callback was changed to take a dentry
47 * instead of an inode, and a handler_flags argument was added.
49 #ifdef HAVE_DENTRY_XATTR_GET
50 #define ZPL_XATTR_GET_WRAPPER(fn) \
52 fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
53 int unused_handler_flags) \
55 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
59 * The xattr_hander->get() callback was changed to take a xattr_handler,
60 * and handler_flags argument was removed and should be accessed by
63 #elif defined(HAVE_HANDLER_XATTR_GET)
64 #define ZPL_XATTR_GET_WRAPPER(fn) \
66 fn(const struct xattr_handler *handler, struct dentry *dentry, \
67 const char *name, void *buffer, size_t size) \
69 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
72 #define ZPL_XATTR_GET_WRAPPER(fn) \
74 fn(struct inode *ip, const char *name, void *buffer, size_t size) \
76 return (__ ## fn(ip, name, buffer, size)); \
78 #endif /* HAVE_DENTRY_XATTR_GET */
82 * The xattr_hander->set() callback was changed to take a dentry
83 * instead of an inode, and a handler_flags argument was added.
85 #ifdef HAVE_DENTRY_XATTR_SET
86 #define ZPL_XATTR_SET_WRAPPER(fn) \
88 fn(struct dentry *dentry, const char *name, const void *buffer, \
89 size_t size, int flags, int unused_handler_flags) \
91 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
95 * The xattr_hander->set() callback was changed to take a xattr_handler,
96 * and handler_flags argument was removed and should be accessed by
99 #elif defined(HAVE_HANDLER_XATTR_SET)
100 #define ZPL_XATTR_SET_WRAPPER(fn) \
102 fn(const struct xattr_handler *handler, struct dentry *dentry, \
103 const char *name, const void *buffer, size_t size, int flags) \
105 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
108 #define ZPL_XATTR_SET_WRAPPER(fn) \
110 fn(struct inode *ip, const char *name, const void *buffer, \
111 size_t size, int flags) \
113 return (__ ## fn(ip, name, buffer, size, flags)); \
115 #endif /* HAVE_DENTRY_XATTR_SET */
117 #ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY
118 #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
119 security_inode_init_security(ip, dip, qstr, nm, val, len)
121 #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
122 security_inode_init_security(ip, dip, nm, val, len)
123 #endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */
126 * Linux 3.7 API change. posix_acl_{from,to}_xattr gained the user_ns
127 * parameter. For the HAVE_POSIX_ACL_FROM_XATTR_USERNS version the
128 * userns _may_ not be correct because it's used outside the RCU.
130 #ifdef HAVE_POSIX_ACL_FROM_XATTR_USERNS
131 static inline struct posix_acl
*
132 zpl_acl_from_xattr(const void *value
, int size
)
134 return (posix_acl_from_xattr(CRED()->user_ns
, value
, size
));
138 zpl_acl_to_xattr(struct posix_acl
*acl
, void *value
, int size
)
140 return (posix_acl_to_xattr(CRED()->user_ns
, acl
, value
, size
));
145 static inline struct posix_acl
*
146 zpl_acl_from_xattr(const void *value
, int size
)
148 return (posix_acl_from_xattr(value
, size
));
152 zpl_acl_to_xattr(struct posix_acl
*acl
, void *value
, int size
)
154 return (posix_acl_to_xattr(acl
, value
, size
));
156 #endif /* HAVE_POSIX_ACL_FROM_XATTR_USERNS */
158 #endif /* _ZFS_XATTR_H */