+static inline int check_multiline(int change_fd)
+{
+ /* This string will be written to kernel Smack "change-rule" interface
+ * to check if it can handle multiple rules in one write.
+ * It consists of two rules, separated by '\n': first that does nothing
+ * and second that has invalid format. If kernel parses only the first
+ * line (pre-3.12 behavior), it won't see the invalid rule and succeed.
+ * If it parses both lines, an error will be returned.
+ */
+ static const char test_str[] = "^ ^ - -\n-";
+ int ret;
+
+ ret = write(change_fd, test_str, sizeof(test_str) - 1);
+ if (ret == -1 && errno == EINVAL)
+ return 1;
+ return 0;
+}
+