summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
diff options
context:
space:
mode:
authorKarel Zak2011-12-01 18:28:42 +0100
committerKarel Zak2011-12-01 18:28:42 +0100
commitede8a60e05598ce1cf27889ce9293f8facf94278 (patch)
treec6dfa2962639f6cadf9def5fe6fd2207c2b6de1a /libmount/src/utils.c
parentlibmount: add -a to umount(8) sample (diff)
downloadkernel-qcow2-util-linux-ede8a60e05598ce1cf27889ce9293f8facf94278.tar.gz
kernel-qcow2-util-linux-ede8a60e05598ce1cf27889ce9293f8facf94278.tar.xz
kernel-qcow2-util-linux-ede8a60e05598ce1cf27889ce9293f8facf94278.zip
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 <kzak@redhat.com>
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r--libmount/src/utils.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 6cc3adf63..b3bb8dce4 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.
*/