]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - lib/match.c
2 * Copyright (C) 2011 Karel Zak <kzak@redhat.com>
4 * This file may be redistributed under the terms of the
5 * GNU Lesser General Public License.
14 * @type: filesystem type
15 * @pattern: filesystem name or comma delimited list of names
17 * The @pattern list of filesystem can be prefixed with a global
18 * "no" prefix to invert matching of the whole list. The "no" could
19 * also be used for individual items in the @pattern list. So,
20 * "nofoo,bar" has the same meaning as "nofoo,nobar".
22 int match_fstype(const char *type
, const char *pattern
)
24 int no
= 0; /* negated types list */
28 if (!pattern
&& !type
)
33 if (!strncmp(pattern
, "no", 2)) {
38 /* Does type occur in types, separated by commas? */
42 if (!strncmp(p
, "no", 2) && !strncasecmp(p
+2, type
, len
) &&
43 (p
[len
+2] == 0 || p
[len
+2] == ','))
45 if (strncasecmp(p
, type
, len
) == 0 && (p
[len
] == 0 || p
[len
] == ','))