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 typedef const struct xattr_handler xattr_handler_t;
43 #if defined(HAVE_XATTR_LIST_SIMPLE)
44 #define ZPL_XATTR_LIST_WRAPPER(fn) \
46 fn(struct dentry *dentry) \
48 return (!!__ ## fn(dentry->d_inode, NULL, 0, NULL, 0)); \
53 #elif defined(HAVE_XATTR_LIST_DENTRY)
54 #define ZPL_XATTR_LIST_WRAPPER(fn) \
56 fn(struct dentry *dentry, char *list, size_t list_size, \
57 const char *name, size_t name_len, int type) \
59 return (__ ## fn(dentry->d_inode, \
60 list, list_size, name, name_len)); \
65 #elif defined(HAVE_XATTR_LIST_HANDLER)
66 #define ZPL_XATTR_LIST_WRAPPER(fn) \
68 fn(const struct xattr_handler *handler, struct dentry *dentry, \
69 char *list, size_t list_size, const char *name, size_t name_len) \
71 return (__ ## fn(dentry->d_inode, \
72 list, list_size, name, name_len)); \
75 #error "Unsupported kernel"
80 * The xattr_handler->get() callback was changed to take a both dentry and
81 * inode, because the dentry might not be attached to an inode yet.
83 #if defined(HAVE_XATTR_GET_DENTRY_INODE)
84 #define ZPL_XATTR_GET_WRAPPER(fn) \
86 fn(const struct xattr_handler *handler, struct dentry *dentry, \
87 struct inode *inode, const char *name, void *buffer, size_t size) \
89 return (__ ## fn(inode, name, buffer, size)); \
93 * The xattr_handler->get() callback was changed to take a xattr_handler,
94 * and handler_flags argument was removed and should be accessed by
97 #elif defined(HAVE_XATTR_GET_HANDLER)
98 #define ZPL_XATTR_GET_WRAPPER(fn) \
100 fn(const struct xattr_handler *handler, struct dentry *dentry, \
101 const char *name, void *buffer, size_t size) \
103 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
107 * The xattr_handler->get() callback was changed to take a dentry
108 * instead of an inode, and a handler_flags argument was added.
110 #elif defined(HAVE_XATTR_GET_DENTRY)
111 #define ZPL_XATTR_GET_WRAPPER(fn) \
113 fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
114 int unused_handler_flags) \
116 return (__ ## fn(dentry->d_inode, name, buffer, size)); \
119 #error "Unsupported kernel"
124 * The xattr_handler->set() callback was changed to take a both dentry and
125 * inode, because the dentry might not be attached to an inode yet.
127 #if defined(HAVE_XATTR_SET_DENTRY_INODE)
128 #define ZPL_XATTR_SET_WRAPPER(fn) \
130 fn(const struct xattr_handler *handler, struct dentry *dentry, \
131 struct inode *inode, const char *name, const void *buffer, \
132 size_t size, int flags) \
134 return (__ ## fn(inode, name, buffer, size, flags)); \
138 * The xattr_handler->set() callback was changed to take a xattr_handler,
139 * and handler_flags argument was removed and should be accessed by
142 #elif defined(HAVE_XATTR_SET_HANDLER)
143 #define ZPL_XATTR_SET_WRAPPER(fn) \
145 fn(const struct xattr_handler *handler, struct dentry *dentry, \
146 const char *name, const void *buffer, size_t size, int flags) \
148 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
152 * The xattr_handler->set() callback was changed to take a dentry
153 * instead of an inode, and a handler_flags argument was added.
155 #elif defined(HAVE_XATTR_SET_DENTRY)
156 #define ZPL_XATTR_SET_WRAPPER(fn) \
158 fn(struct dentry *dentry, const char *name, const void *buffer, \
159 size_t size, int flags, int unused_handler_flags) \
161 return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
164 #error "Unsupported kernel"
168 * Linux 3.7 API change. posix_acl_{from,to}_xattr gained the user_ns
169 * parameter. All callers are expected to pass the &init_user_ns which
170 * is available through the init credential (kcred).
172 static inline struct posix_acl *
173 zpl_acl_from_xattr(const void *value, int size)
175 return (posix_acl_from_xattr(kcred->user_ns, value, size));
179 zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
181 return (posix_acl_to_xattr(kcred->user_ns, acl, value, size));
184 #endif /* _ZFS_XATTR_H */