1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #include <tracefs.h> 3 #include <stdbool.h> 4 5 enum action_type { 6 ACTION_NONE = 0, 7 ACTION_TRACE_OUTPUT, 8 ACTION_SIGNAL, 9 ACTION_SHELL, 10 ACTION_CONTINUE, 11 ACTION_FIELD_N 12 }; 13 14 struct action { 15 enum action_type type; 16 union { 17 struct { 18 /* For ACTION_TRACE_OUTPUT */ 19 char *trace_output; 20 }; 21 struct { 22 /* For ACTION_SIGNAL */ 23 int signal; 24 int pid; 25 }; 26 struct { 27 /* For ACTION_SHELL */ 28 char *command; 29 }; 30 }; 31 }; 32 33 static const int action_default_size = 8; 34 35 struct actions { 36 struct action *list; 37 int len, size; 38 bool present[ACTION_FIELD_N]; 39 bool continue_flag; 40 41 /* External dependencies */ 42 struct tracefs_instance *trace_output_inst; 43 }; 44 45 void actions_init(struct actions *self); 46 void actions_destroy(struct actions *self); 47 int actions_add_trace_output(struct actions *self, const char *trace_output); 48 int actions_add_signal(struct actions *self, int signal, int pid); 49 int actions_add_shell(struct actions *self, const char *command); 50 int actions_add_continue(struct actions *self); 51 int actions_parse(struct actions *self, const char *trigger); 52 int actions_perform(struct actions *self); 53