- if (x == '*') {
- /* Event is a subset of the excluder */
- ERR("Event %s: %.*s excludes all events from %s",
- event_name,
- excluder_length,
- next_excluder,
- event_name);
- goto error;
- }
- if (e == '*') {
- char *string;
- char **new_exclusion_list;
-
- /* Excluder is a proper subset of event */
- string = lttng_strndup(next_excluder, excluder_length);
- if (!string) {
- PERROR("lttng_strndup error");
- goto error;
- }
- new_exclusion_list = realloc(exclusion_list,
- sizeof(char *) * (exclusion_count + 1));
- if (!new_exclusion_list) {
- PERROR("realloc");
- free(string);
+ return ret;
+}
+
+static
+int create_exclusion_list_and_validate(const char *event_name,
+ const char *exclusions_arg,
+ char ***exclusion_list)
+{
+ int ret = 0;
+ char **exclusions = NULL;
+
+ /* Event name must be a valid globbing pattern to allow exclusions. */
+ if (!strutils_is_star_glob_pattern(event_name)) {
+ ERR("Event %s: Exclusions can only be used with a globbing pattern",
+ event_name);
+ goto error;
+ }
+
+ /* Split exclusions. */
+ exclusions = strutils_split(exclusions_arg, ',', true);
+ if (!exclusions) {
+ goto error;
+ }
+
+ /*
+ * If the event name is a star-at-end only globbing pattern,
+ * then we can validate the individual exclusions. Otherwise
+ * all exclusions are passed to the session daemon.
+ */
+ if (strutils_is_star_at_the_end_only_glob_pattern(event_name)) {
+ char * const *exclusion;
+
+ for (exclusion = exclusions; *exclusion; exclusion++) {
+ if (!strutils_is_star_glob_pattern(*exclusion) ||
+ strutils_is_star_at_the_end_only_glob_pattern(*exclusion)) {
+ ret = check_exclusion_subsets(event_name, *exclusion);
+ if (ret) {