16ea082b1STomas Glozar /* SPDX-License-Identifier: GPL-2.0 */ 26ea082b1STomas Glozar #include <tracefs.h> 36ea082b1STomas Glozar #include <stdbool.h> 46ea082b1STomas Glozar 56ea082b1STomas Glozar enum action_type { 66ea082b1STomas Glozar ACTION_NONE = 0, 76ea082b1STomas Glozar ACTION_TRACE_OUTPUT, 86ea082b1STomas Glozar ACTION_SIGNAL, 96ea082b1STomas Glozar ACTION_SHELL, 10*8d933d5cSTomas Glozar ACTION_CONTINUE, 116ea082b1STomas Glozar ACTION_FIELD_N 126ea082b1STomas Glozar }; 136ea082b1STomas Glozar 146ea082b1STomas Glozar struct action { 156ea082b1STomas Glozar enum action_type type; 166ea082b1STomas Glozar union { 176ea082b1STomas Glozar struct { 186ea082b1STomas Glozar /* For ACTION_TRACE_OUTPUT */ 196ea082b1STomas Glozar char *trace_output; 206ea082b1STomas Glozar }; 216ea082b1STomas Glozar struct { 226ea082b1STomas Glozar /* For ACTION_SIGNAL */ 236ea082b1STomas Glozar int signal; 246ea082b1STomas Glozar int pid; 256ea082b1STomas Glozar }; 266ea082b1STomas Glozar struct { 276ea082b1STomas Glozar /* For ACTION_SHELL */ 286ea082b1STomas Glozar char *command; 296ea082b1STomas Glozar }; 306ea082b1STomas Glozar }; 316ea082b1STomas Glozar }; 326ea082b1STomas Glozar 336ea082b1STomas Glozar static const int action_default_size = 8; 346ea082b1STomas Glozar 356ea082b1STomas Glozar struct actions { 366ea082b1STomas Glozar struct action *list; 376ea082b1STomas Glozar int len, size; 386ea082b1STomas Glozar bool present[ACTION_FIELD_N]; 39*8d933d5cSTomas Glozar bool continue_flag; 406ea082b1STomas Glozar 416ea082b1STomas Glozar /* External dependencies */ 426ea082b1STomas Glozar struct tracefs_instance *trace_output_inst; 436ea082b1STomas Glozar }; 446ea082b1STomas Glozar 456ea082b1STomas Glozar void actions_init(struct actions *self); 466ea082b1STomas Glozar void actions_destroy(struct actions *self); 476ea082b1STomas Glozar int actions_add_trace_output(struct actions *self, const char *trace_output); 486ea082b1STomas Glozar int actions_add_signal(struct actions *self, int signal, int pid); 496ea082b1STomas Glozar int actions_add_shell(struct actions *self, const char *command); 50*8d933d5cSTomas Glozar int actions_add_continue(struct actions *self); 516ea082b1STomas Glozar int actions_parse(struct actions *self, const char *trigger); 52*8d933d5cSTomas Glozar int actions_perform(struct actions *self); 53