+#ifdef HAVE_XATTR_HANDLER_SIMPLIFIED
+static int ll_xattr_get_common_4_3(const struct xattr_handler *handler,
+ struct dentry *dentry, const char *name,
+ void *buffer, size_t size)
+{
+ return ll_xattr_get_common(handler, dentry, dentry->d_inode, name,
+ buffer, size);
+}
+
+static int ll_xattr_get_4_3(const struct xattr_handler *handler,
+ struct dentry *dentry, const char *name,
+ void *buffer, size_t size)
+{
+ return ll_xattr_get(handler, dentry, dentry->d_inode, name, buffer,
+ size);
+}
+
+static int ll_xattr_set_common_4_3(const struct xattr_handler *handler,
+ struct dentry *dentry, const char *name,
+ const void *value, size_t size, int flags)
+{
+ return ll_xattr_set_common(handler, dentry, dentry->d_inode, name,
+ value, size, flags);
+}
+
+static int ll_xattr_set_4_3(const struct xattr_handler *handler,
+ struct dentry *dentry, const char *name,
+ const void *value, size_t size, int flags)
+{
+ return ll_xattr_set(handler, dentry, dentry->d_inode, name, value,
+ size, flags);
+}
+
+#elif !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+const struct xattr_handler *get_xattr_handler(int handler_flag)
+{
+ int i = 0;
+
+ while (ll_xattr_handlers[i]) {
+ if (ll_xattr_handlers[i]->flags == handler_flag)
+ return ll_xattr_handlers[i];
+ i++;
+ }
+ return NULL;
+}
+
+static int ll_xattr_get_common_3_11(struct dentry *dentry, const char *name,
+ void *buffer, size_t size, int handler_flags)
+{
+ const struct xattr_handler *handler = get_xattr_handler(handler_flags);
+
+ if (!handler)
+ return -ENXIO;
+
+ return ll_xattr_get_common(handler, dentry, dentry->d_inode, name,
+ buffer, size);
+}
+
+static int ll_xattr_get_3_11(struct dentry *dentry, const char *name,
+ void *buffer, size_t size, int handler_flags)
+{
+ const struct xattr_handler *handler = get_xattr_handler(handler_flags);
+
+ if (!handler)
+ return -ENXIO;
+
+ return ll_xattr_get(handler, dentry, dentry->d_inode, name, buffer,
+ size);
+}
+
+static int ll_xattr_set_common_3_11(struct dentry *dentry, const char *name,
+ const void *value, size_t size, int flags,
+ int handler_flags)
+{
+ const struct xattr_handler *handler = get_xattr_handler(handler_flags);
+
+ if (!handler)
+ return -ENXIO;
+
+ return ll_xattr_set_common(handler, dentry, dentry->d_inode, name,
+ value, size, flags);
+}
+
+static int ll_xattr_set_3_11(struct dentry *dentry, const char *name,
+ const void *value, size_t size, int flags,
+ int handler_flags)
+{
+ const struct xattr_handler *handler = get_xattr_handler(handler_flags);
+
+ if (!handler)
+ return -ENXIO;
+
+ return ll_xattr_set(handler, dentry, dentry->d_inode, name, value,
+ size, flags);
+}
+#endif
+
+static const struct xattr_handler ll_user_xattr_handler = {
+ .prefix = XATTR_USER_PREFIX,
+ .flags = XATTR_USER_T,
+#if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
+ .get = ll_xattr_get_common_4_3,
+ .set = ll_xattr_set_common_4_3,
+#elif !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+ .get = ll_xattr_get_common_3_11,
+ .set = ll_xattr_set_common_3_11,
+#else
+ .get = ll_xattr_get_common,
+ .set = ll_xattr_set_common,
+#endif
+};
+
+static const struct xattr_handler ll_trusted_xattr_handler = {
+ .prefix = XATTR_TRUSTED_PREFIX,
+ .flags = XATTR_TRUSTED_T,
+#if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
+ .get = ll_xattr_get_4_3,
+ .set = ll_xattr_set_4_3,
+#elif !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+ .get = ll_xattr_get_3_11,
+ .set = ll_xattr_set_3_11,
+#else
+ .get = ll_xattr_get,
+ .set = ll_xattr_set,
+#endif
+};
+
+static const struct xattr_handler ll_security_xattr_handler = {
+ .prefix = XATTR_SECURITY_PREFIX,
+ .flags = XATTR_SECURITY_T,
+#if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
+ .get = ll_xattr_get_common_4_3,
+ .set = ll_xattr_set_common_4_3,
+#elif !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+ .get = ll_xattr_get_common_3_11,
+ .set = ll_xattr_set_common_3_11,
+#else
+ .get = ll_xattr_get_common,
+ .set = ll_xattr_set_common,
+#endif
+};
+
+static const struct xattr_handler ll_acl_access_xattr_handler = {
+#ifdef HAVE_XATTR_HANDLER_NAME
+ .name = XATTR_NAME_POSIX_ACL_ACCESS,
+#else
+ .prefix = XATTR_NAME_POSIX_ACL_ACCESS,
+#endif
+ .flags = XATTR_ACL_ACCESS_T,
+#if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
+ .get = ll_xattr_get_common_4_3,
+ .set = ll_xattr_set_common_4_3,
+#elif !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+ .get = ll_xattr_get_common_3_11,
+ .set = ll_xattr_set_common_3_11,
+#else
+ .get = ll_xattr_get_common,
+ .set = ll_xattr_set_common,
+#endif
+};
+
+static const struct xattr_handler ll_acl_default_xattr_handler = {
+#ifdef HAVE_XATTR_HANDLER_NAME
+ .name = XATTR_NAME_POSIX_ACL_DEFAULT,
+#else
+ .prefix = XATTR_NAME_POSIX_ACL_DEFAULT,
+#endif
+ .flags = XATTR_ACL_DEFAULT_T,
+#if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
+ .get = ll_xattr_get_common_4_3,
+ .set = ll_xattr_set_common_4_3,
+#elif !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+ .get = ll_xattr_get_common_3_11,
+ .set = ll_xattr_set_common_3_11,
+#else
+ .get = ll_xattr_get_common,
+ .set = ll_xattr_set_common,
+#endif
+};
+
+static const struct xattr_handler ll_lustre_xattr_handler = {
+ .prefix = XATTR_LUSTRE_PREFIX,
+ .flags = XATTR_LUSTRE_T,
+#if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
+ .get = ll_xattr_get_4_3,
+ .set = ll_xattr_set_4_3,
+#elif !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+ .get = ll_xattr_get_3_11,
+ .set = ll_xattr_set_3_11,
+#else
+ .get = ll_xattr_get,
+ .set = ll_xattr_set,
+#endif
+};
+
+const struct xattr_handler *ll_xattr_handlers[] = {
+ &ll_user_xattr_handler,
+ &ll_trusted_xattr_handler,
+ &ll_security_xattr_handler,
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+ &ll_acl_access_xattr_handler,
+ &ll_acl_default_xattr_handler,
+#endif
+ &ll_lustre_xattr_handler,
+ NULL,
+};