]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
condition: for completenes sake at != comparator for ConditionKernelVersion=
authorLennart Poettering <lennart@poettering.net>
Mon, 18 Mar 2019 16:43:29 +0000 (17:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 19 Mar 2019 14:55:08 +0000 (15:55 +0100)
man/systemd.unit.xml
src/shared/condition.c

index 7338b11280cb6f42a3d74659bfba3dca0c7219b1..8f317c25a77e337ca552141b77675dadfda0e518 100644 (file)
         the exact assignment is looked for with right and left hand
         side matching.</para>
 
-        <para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel version (as reported
-        by <command>uname -r</command>) matches a certain expression (or if prefixed with the exclamation mark does not
-        match it). The argument must be a single string. If the string starts with one of <literal>&lt;</literal>,
-        <literal>&lt;=</literal>, <literal>=</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> a relative
-        version comparison is done, otherwise the specified string is matched with shell-style globs.</para>
+        <para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel version (as
+        reported by <command>uname -r</command>) matches a certain expression (or if prefixed with the
+        exclamation mark does not match it). The argument must be a single string. If the string starts with
+        one of <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>=</literal>,
+        <literal>!=</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> a relative version
+        comparison is done, otherwise the specified string is matched with shell-style globs.</para>
 
         <para>Note that using the kernel version string is an unreliable way to determine which features are supported
         by a kernel, because of the widespread practice of backporting drivers, features, and fixes from newer upstream
index 5853b4d61f66b95e871ba999391366df547b6a1e..38ebaef62bfe0ab8617564c8559371c70743e552 100644 (file)
@@ -138,6 +138,7 @@ typedef enum {
         ORDER_LOWER,
         ORDER_GREATER,
         ORDER_EQUAL,
+        ORDER_UNEQUAL,
         _ORDER_MAX,
         _ORDER_INVALID = -1
 } OrderOperator;
@@ -150,6 +151,7 @@ static OrderOperator parse_order(const char **s) {
                 [ORDER_LOWER] = "<",
                 [ORDER_GREATER] = ">",
                 [ORDER_EQUAL] = "=",
+                [ORDER_UNEQUAL] = "!=",
         };
 
         OrderOperator i;
@@ -180,6 +182,9 @@ static bool test_order(int k, OrderOperator p) {
         case ORDER_EQUAL:
                 return k == 0;
 
+        case ORDER_UNEQUAL:
+                return k != 0;
+
         case ORDER_GREATER_OR_EQUAL:
                 return k >= 0;