Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <tracefs.h>
|
|
#include <stdbool.h>
|
|
|
|
enum action_type {
|
|
ACTION_NONE = 0,
|
|
ACTION_TRACE_OUTPUT,
|
|
ACTION_SIGNAL,
|
|
ACTION_SHELL,
|
|
ACTION_CONTINUE,
|
|
ACTION_FIELD_N
|
|
};
|
|
|
|
struct action {
|
|
enum action_type type;
|
|
union {
|
|
struct {
|
|
/* For ACTION_TRACE_OUTPUT */
|
|
char *trace_output;
|
|
};
|
|
struct {
|
|
/* For ACTION_SIGNAL */
|
|
int signal;
|
|
int pid;
|
|
};
|
|
struct {
|
|
/* For ACTION_SHELL */
|
|
char *command;
|
|
};
|
|
};
|
|
};
|
|
|
|
static const int action_default_size = 8;
|
|
|
|
struct actions {
|
|
struct action *list;
|
|
int len, size;
|
|
bool present[ACTION_FIELD_N];
|
|
bool continue_flag;
|
|
|
|
/* External dependencies */
|
|
struct tracefs_instance *trace_output_inst;
|
|
};
|
|
|
|
void actions_init(struct actions *self);
|
|
void actions_destroy(struct actions *self);
|
|
int actions_add_trace_output(struct actions *self, const char *trace_output);
|
|
int actions_add_signal(struct actions *self, int signal, int pid);
|
|
int actions_add_shell(struct actions *self, const char *command);
|
|
int actions_add_continue(struct actions *self);
|
|
int actions_parse(struct actions *self, const char *trigger, const char *tracefn);
|
|
int actions_perform(struct actions *self);
|