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 * Preferred XATTR_NAME_* definitions introduced, these are mapped to
47 * the previous definitions for older kernels.
49 #ifndef XATTR_NAME_POSIX_ACL_DEFAULT
50 #define XATTR_NAME_POSIX_ACL_DEFAULT POSIX_ACL_XATTR_DEFAULT
53 #ifndef XATTR_NAME_POSIX_ACL_ACCESS
54 #define XATTR_NAME_POSIX_ACL_ACCESS POSIX_ACL_XATTR_ACCESS
60 #if defined(HAVE_XATTR_LIST_SIMPLE)
61 #define ZPL_XATTR_LIST_WRAPPER(fn) \
63 fn(struct dentry *dentry) \
65 return (!!__ ## fn(dentry->d_inode, NULL, 0, NULL, 0)); \
70 #elif defined(HAVE_XATTR_LIST_DENTRY)
71 #define ZPL_XATTR_LIST_WRAPPER(fn) \
73 fn(struct dentry *dentry, char *list, size_t list_size, \
74 const char *name, size_t name_len, int type) \
76 return (__ ## fn(dentry->d_inode, \
77 list, list_size, name, name_len)); \
82 #elif defined(HAVE_XATTR_LIST_HANDLER)
83 #define ZPL_XATTR_LIST_WRAPPER(fn) \
85 fn(const struct xattr_handler *handler, struct dentry *dentry, \
86 char *list, size_t list_size, const char *name, size_t name_len) \
88 return (__ ## fn(dentry->d_inode, \
89 list, list_size, name, name_len)); \
94 #elif defined(HAVE_XATTR_LIST_INODE)
95 #define ZPL_XATTR_LIST_WRAPPER(fn) \
97 fn(struct inode *ip, char *list, size_t list_size, \
98 const char *name, size_t name_len) \
100 return (__ ## fn(ip, list, list_size, name, name_len)); \
106 * The xattr_handler->get() callback was changed to take a both dentry and
107 * inode, because the dentry might not be attached to an inode yet.
109 #if defined(HAVE_XATTR_GET_DENTRY_INODE)
110 #define ZPL_XATTR_GET_WRAPPER(fn) \
112 fn(const struct xattr_handler *handler, struct dentry *dentry, \
113 struct inode *inode, const char *name, void *buffer, size_t size) \
115 return (__ ## fn(inode, name, buffer, size)); \
119 * The xattr_handler->get() callback was changed to take a xattr_handler,
120 * and handler_flags argument was removed and should be accessed by
123 #elif defined(HAVE_XATTR_GET_HANDLER)
124 #define ZPL_XATTR_GET_WRAPPER(fn) \
126 fn(const struct xattr_handler *handler, struct dentry *dentry, \
127 const char *name, void *buffer, size_t size) \
129 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
133 * The xattr_handler->get() callback was changed to take a dentry
134 * instead of an inode, and a handler_flags argument was added.
136 #elif defined(HAVE_XATTR_GET_DENTRY)
137 #define ZPL_XATTR_GET_WRAPPER(fn) \
139 fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
140 int unused_handler_flags) \
142 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
147 #elif defined(HAVE_XATTR_GET_INODE)
148 #define ZPL_XATTR_GET_WRAPPER(fn) \
150 fn(struct inode *ip, const char *name, void *buffer, size_t size) \
152 return (__ ## fn(ip, name, buffer, size)); \
158 * The xattr_handler->set() callback was changed to take a both dentry and
159 * inode, because the dentry might not be attached to an inode yet.
161 #if defined(HAVE_XATTR_SET_DENTRY_INODE)
162 #define ZPL_XATTR_SET_WRAPPER(fn) \
164 fn(const struct xattr_handler *handler, struct dentry *dentry, \
165 struct inode *inode, const char *name, const void *buffer, \
166 size_t size, int flags) \
168 return (__ ## fn(inode, name, buffer, size, flags)); \
172 * The xattr_handler->set() callback was changed to take a xattr_handler,
173 * and handler_flags argument was removed and should be accessed by
176 #elif defined(HAVE_XATTR_SET_HANDLER)
177 #define ZPL_XATTR_SET_WRAPPER(fn) \
179 fn(const struct xattr_handler *handler, struct dentry *dentry, \
180 const char *name, const void *buffer, size_t size, int flags) \
182 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
186 * The xattr_handler->set() callback was changed to take a dentry
187 * instead of an inode, and a handler_flags argument was added.
189 #elif defined(HAVE_XATTR_SET_DENTRY)
190 #define ZPL_XATTR_SET_WRAPPER(fn) \
192 fn(struct dentry *dentry, const char *name, const void *buffer, \
193 size_t size, int flags, int unused_handler_flags) \
195 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
200 #elif defined(HAVE_XATTR_SET_INODE)
201 #define ZPL_XATTR_SET_WRAPPER(fn) \
203 fn(struct inode *ip, const char *name, const void *buffer, \
204 size_t size, int flags) \
206 return (__ ## fn(ip, name, buffer, size, flags)); \
210 #ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY
211 #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
212 security_inode_init_security(ip, dip, qstr, nm, val, len)
214 #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
215 security_inode_init_security(ip, dip, nm, val, len)
216 #endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */
219 * Linux 3.7 API change. posix_acl_{from,to}_xattr gained the user_ns
220 * parameter. All callers are expected to pass the &init_user_ns which
221 * is available through the init credential (kcred).
223 #ifdef HAVE_POSIX_ACL_FROM_XATTR_USERNS
224 static inline struct posix_acl
*
225 zpl_acl_from_xattr(const void *value
, int size
)
227 return (posix_acl_from_xattr(kcred
->user_ns
, value
, size
));
231 zpl_acl_to_xattr(struct posix_acl
*acl
, void *value
, int size
)
233 return (posix_acl_to_xattr(kcred
->user_ns
, acl
, value
, size
));
238 static inline struct posix_acl
*
239 zpl_acl_from_xattr(const void *value
, int size
)
241 return (posix_acl_from_xattr(value
, size
));
245 zpl_acl_to_xattr(struct posix_acl
*acl
, void *value
, int size
)
247 return (posix_acl_to_xattr(acl
, value
, size
));
249 #endif /* HAVE_POSIX_ACL_FROM_XATTR_USERNS */
251 #endif /* _ZFS_XATTR_H */