]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add "+" prefix for options pattern (e.g findmnt -O)
authorKarel Zak <kzak@redhat.com>
Thu, 1 Dec 2011 17:28:42 +0000 (18:28 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 1 Dec 2011 17:28:42 +0000 (18:28 +0100)
Examples:

 * findmnt --fstab -O noauto
   Returns all entries where is not "auto" option (including entries
   with "noauto" option.

 * findmnt --fstab -O +noauto
   Returns all entries where is literally "noauto" option.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=758457
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/utils.c
misc-utils/findmnt.8

index 6cc3adf63b67352d2d0ee0daee78b33d367a7ca8..b3bb8dce458c0edc1164139e78f6677923b715c1 100644 (file)
@@ -259,7 +259,10 @@ static int check_option(const char *haystack, size_t len,
        const char *p;
        int no = 0;
 
-       if (needle_len >= 2 && !strncmp(needle, "no", 2)) {
+       if (needle_len >= 1 && *needle == '+') {
+               needle++;
+               needle_len--;
+       } else if (needle_len >= 2 && !strncmp(needle, "no", 2)) {
                no = 1;
                needle += 2;
                needle_len -= 2;
@@ -291,10 +294,20 @@ static int check_option(const char *haystack, size_t len,
  * Unlike fs type matching, nonetdev,user and nonetdev,nouser have
  * DIFFERENT meanings; each option is matched explicitly as specified.
  *
+ * The "no" prefix interpretation could be disable by "+" prefix, for example
+ * "+noauto" matches if @optstr literally contains "noauto" string.
+ *
  * "xxx,yyy,zzz" : "nozzz"     -> False
  *
  * "xxx,yyy,zzz" : "xxx,noeee" -> True
  *
+ * "bar,zzz"     : "nofoo"      -> True
+ *
+ * "nofoo,bar"   : "+nofoo"     -> True
+ *
+ * "bar,zzz"     : "+nofoo"     -> False
+ *
+ *
  * Returns: 1 if pattern is matching, else 0. This function also returns 0
  *          if @pattern is NULL and @optstr is non-NULL.
  */
index 776bf662e4c2eb341a51a90b6755e0494c757c9c..24e3a520b2aab05a79d85fb68dbd36bc3e8114d9 100644 (file)
@@ -89,9 +89,9 @@ options are cumulative in effect.  It is different from
 .B \-t
 in that each option is matched exactly; a leading
 .I no
-at the beginning
-of one option does not negate the rest.  For more details see
-.BR mount (8).
+at the beginning does not have global meaning. The "no" could used for
+individual items in the list. The "no" prefix interpratation could be disabled
+by "+" prefix.
 .IP "\fB\-o, \-\-output \fIlist\fP"
 Define output columns.  Currently supported are
 .BR ACTION,