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 xattr_handler,
107 * and handler_flags argument was removed and should be accessed by
110 #if defined(HAVE_XATTR_GET_HANDLER)
111 #define ZPL_XATTR_GET_WRAPPER(fn) \
113 fn(const struct xattr_handler *handler, struct dentry *dentry, \
114 const char *name, void *buffer, size_t size) \
116 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
120 * The xattr_handler->get() callback was changed to take a dentry
121 * instead of an inode, and a handler_flags argument was added.
123 #elif defined(HAVE_XATTR_GET_DENTRY)
124 #define ZPL_XATTR_GET_WRAPPER(fn) \
126 fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
127 int unused_handler_flags) \
129 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
134 #elif defined(HAVE_XATTR_GET_INODE)
135 #define ZPL_XATTR_GET_WRAPPER(fn) \
137 fn(struct inode *ip, const char *name, void *buffer, size_t size) \
139 return (__ ## fn(ip, name, buffer, size)); \
145 * The xattr_handler->set() callback was changed to take a xattr_handler,
146 * and handler_flags argument was removed and should be accessed by
149 #if defined(HAVE_XATTR_SET_HANDLER)
150 #define ZPL_XATTR_SET_WRAPPER(fn) \
152 fn(const struct xattr_handler *handler, struct dentry *dentry, \
153 const char *name, const void *buffer, size_t size, int flags) \
155 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
159 * The xattr_handler->set() callback was changed to take a dentry
160 * instead of an inode, and a handler_flags argument was added.
162 #elif defined(HAVE_XATTR_SET_DENTRY)
163 #define ZPL_XATTR_SET_WRAPPER(fn) \
165 fn(struct dentry *dentry, const char *name, const void *buffer, \
166 size_t size, int flags, int unused_handler_flags) \
168 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
173 #elif defined(HAVE_XATTR_SET_INODE)
174 #define ZPL_XATTR_SET_WRAPPER(fn) \
176 fn(struct inode *ip, const char *name, const void *buffer, \
177 size_t size, int flags) \
179 return (__ ## fn(ip, name, buffer, size, flags)); \
183 #ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY
184 #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
185 security_inode_init_security(ip, dip, qstr, nm, val, len)
187 #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
188 security_inode_init_security(ip, dip, nm, val, len)
189 #endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */
192 * Linux 3.7 API change. posix_acl_{from,to}_xattr gained the user_ns
193 * parameter. All callers are expected to pass the &init_user_ns which
194 * is available through the init credential (kcred).
196 #ifdef HAVE_POSIX_ACL_FROM_XATTR_USERNS
197 static inline struct posix_acl
*
198 zpl_acl_from_xattr(const void *value
, int size
)
200 return (posix_acl_from_xattr(kcred
->user_ns
, value
, size
));
204 zpl_acl_to_xattr(struct posix_acl
*acl
, void *value
, int size
)
206 return (posix_acl_to_xattr(kcred
->user_ns
, acl
, value
, size
));
211 static inline struct posix_acl
*
212 zpl_acl_from_xattr(const void *value
, int size
)
214 return (posix_acl_from_xattr(value
, size
));
218 zpl_acl_to_xattr(struct posix_acl
*acl
, void *value
, int size
)
220 return (posix_acl_to_xattr(acl
, value
, size
));
222 #endif /* HAVE_POSIX_ACL_FROM_XATTR_USERNS */
224 #endif /* _ZFS_XATTR_H */