Whamcloud - gitweb
LU-12355 llite: include file linux/selinux.h removed
[fs/lustre-release.git] / lustre / llite / xattr.c
index 1bf2819..b8500df 100644 (file)
@@ -34,7 +34,9 @@
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/xattr.h>
+#ifdef HAVE_LINUX_SELINUX_IS_ENABLED
 #include <linux/selinux.h>
+#endif
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
@@ -52,6 +54,17 @@ static inline const char *xattr_prefix(const struct xattr_handler *handler)
 }
 #endif
 
+#ifdef HAVE_LINUX_SELINUX_IS_ENABLED
+# define test_xattr_is_selinux_disabled(handler, name) \
+               ((handler)->flags == XATTR_SECURITY_T && \
+               !selinux_is_enabled() && \
+               strcmp((name), "selinux") == 0)
+#else
+# define test_xattr_is_selinux_disabled(handler, name) \
+               ((handler)->flags == XATTR_SECURITY_T && \
+               strcmp((name), "selinux") == 0)
+#endif
+
 const struct xattr_handler *get_xattr_type(const char *name)
 {
        int i;
@@ -135,8 +148,7 @@ static int ll_xattr_set_common(const struct xattr_handler *handler,
                RETURN(0);
 
        /* LU-549:  Disable security.selinux when selinux is disabled */
-       if (handler->flags == XATTR_SECURITY_T && !selinux_is_enabled() &&
-           strcmp(name, "selinux") == 0)
+       if (test_xattr_is_selinux_disabled(handler, name))
                RETURN(-EOPNOTSUPP);
 
        /*
@@ -424,8 +436,7 @@ static int ll_xattr_get_common(const struct xattr_handler *handler,
                RETURN(rc);
 
        /* LU-549:  Disable security.selinux when selinux is disabled */
-       if (handler->flags == XATTR_SECURITY_T && !selinux_is_enabled() &&
-           !strcmp(name, "selinux"))
+       if (test_xattr_is_selinux_disabled(handler, name))
                RETURN(-EOPNOTSUPP);
 
 #ifdef CONFIG_FS_POSIX_ACL