From: Karel Zak Date: Thu, 1 Dec 2011 17:28:42 +0000 (+0100) Subject: libmount: add "+" prefix for options pattern (e.g findmnt -O) X-Git-Tag: v2.21-rc1~145 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ede8a60e05598ce1cf27889ce9293f8facf94278;p=thirdparty%2Futil-linux.git libmount: add "+" prefix for options pattern (e.g findmnt -O) 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 --- diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 6cc3adf63b..b3bb8dce45 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -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. */ diff --git a/misc-utils/findmnt.8 b/misc-utils/findmnt.8 index 776bf662e4..24e3a520b2 100644 --- a/misc-utils/findmnt.8 +++ b/misc-utils/findmnt.8 @@ -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,