From: Philippe Proulx Date: Sun, 19 Feb 2017 01:01:34 +0000 (-0500) Subject: Add support for star globbing patterns in event names X-Git-Tag: v2.10.0-rc1~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4993071a89f88f92444cf62abdc0935efbc6c460;p=lttng-modules.git Add support for star globbing patterns in event names This patch adds support for full star-only globbing patterns used in the event names (enabler names). strutils_star_glob_match() is always used to perform the match when the enabler is LTTNG_ENABLER_STAR_GLOB. This enabler is set when it is detected that its name contains at least one non-escaped star with strutils_is_star_glob_pattern(). The match is performed by strutils_star_glob_match(), the same function that the filter interpreter uses. Signed-off-by: Philippe Proulx Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-abi.c b/lttng-abi.c index 40f96eb5..f2b207cb 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -1068,8 +1069,12 @@ int lttng_abi_create_event(struct file *channel_file, || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) { struct lttng_enabler *enabler; - if (event_param->name[strlen(event_param->name) - 1] == '*') { - enabler = lttng_enabler_create(LTTNG_ENABLER_WILDCARD, + if (strutils_is_star_glob_pattern(event_param->name)) { + /* + * If the event name is a star globbing pattern, + * we create the special star globbing enabler. + */ + enabler = lttng_enabler_create(LTTNG_ENABLER_STAR_GLOB, event_param, channel); } else { enabler = lttng_enabler_create(LTTNG_ENABLER_NAME, diff --git a/lttng-abi.h b/lttng-abi.h index 822b8839..dac86584 100644 --- a/lttng-abi.h +++ b/lttng-abi.h @@ -30,7 +30,7 @@ * should be increased when an incompatible ABI change is done. */ #define LTTNG_MODULES_ABI_MAJOR_VERSION 2 -#define LTTNG_MODULES_ABI_MINOR_VERSION 2 +#define LTTNG_MODULES_ABI_MINOR_VERSION 3 #define LTTNG_KERNEL_SYM_NAME_LEN 256 diff --git a/lttng-events.c b/lttng-events.c index d0070146..6bfe710f 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -1142,11 +1143,10 @@ fd_error: * Enabler management. */ static -int lttng_match_enabler_wildcard(const char *desc_name, - const char *name) +int lttng_match_enabler_star_glob(const char *desc_name, + const char *pattern) { - /* Compare excluding final '*' */ - if (strncmp(desc_name, name, strlen(name) - 1)) + if (!strutils_star_glob_match(pattern, -1ULL, desc_name, -1ULL)) return 0; return 1; } @@ -1191,8 +1191,8 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc, return -EINVAL; } switch (enabler->type) { - case LTTNG_ENABLER_WILDCARD: - return lttng_match_enabler_wildcard(desc_name, enabler_name); + case LTTNG_ENABLER_STAR_GLOB: + return lttng_match_enabler_star_glob(desc_name, enabler_name); case LTTNG_ENABLER_NAME: return lttng_match_enabler_name(desc_name, enabler_name); default: diff --git a/lttng-events.h b/lttng-events.h index 173f369f..f55bf663 100644 --- a/lttng-events.h +++ b/lttng-events.h @@ -324,7 +324,7 @@ struct lttng_event { }; enum lttng_enabler_type { - LTTNG_ENABLER_WILDCARD, + LTTNG_ENABLER_STAR_GLOB, LTTNG_ENABLER_NAME, };