Lines Matching +full:default +full:- +full:trigger
1 // SPDX-License-Identifier: Apache-2.0
5 * debug-trigger listens for an external signal that the BMC is in some way unresponsive. When a
9 * Usage: debug-trigger [SOURCE] [SINK]
12 * --sink-actions=ACTION
17 * debug-trigger
18 * Set the source as stdin, the sink as stdout, and use the default 'sysrq' set of sink
21 * debug-trigger --sink-actions=sysrq
25 * debug-trigger /dev/serio_raw0 /proc/sysrq-trigger
26 * Open /dev/serio_raw0 as the source and /proc/sysrq-trigger as the sink, with the default
28 * /proc/sysrq-trigger, causing a kernel panic. When 'R' is read from /dev/serio_raw0 'b' will
29 * be written to /proc/sysrq-trigger, causing an immediate reboot of the system.
31 * dbug-trigger --sink-actions=dbus /dev/serio_raw0
33 * read from /dev/serio_raw0 create a dump via phosphor-debug-collector by calling through its
34 * D-Bus interface, then reboot the system by starting systemd's 'reboot.target'
102 …/* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-gui… in sysrq_sink_debug()
108 if ((rc = write(sysrq->sink, &action, sizeof(action))) == sizeof(action)) in sysrq_sink_debug()
111 if (rc == -1) { in sysrq_sink_debug()
121 …/* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-gui… in sysrq_sink_reboot()
127 if ((rc = write(sysrq->sink, &action, sizeof(action))) == sizeof(action)) in sysrq_sink_reboot()
130 if (rc == -1) { in sysrq_sink_reboot()
142 if ((ingress = read(basic->source, op, 1)) != 1) { in basic_source_poll()
145 return -errno; in basic_source_poll()
165 #include <systemd/sd-bus.h>
180 strerror(-rc)); in dbus_sink_dump_progress()
209 strerror(-rc)); in dbus_sink_dump_progress()
217 strerror(-rc)); in dbus_sink_dump_progress()
227 strerror(-rc)); in dbus_sink_dump_progress()
236 member, strerror(-rc)); in dbus_sink_dump_progress()
254 sd_bus_slot *slot = sd_bus_get_current_slot(dbus->bus); in dbus_sink_dump_progress()
273 rc = sd_bus_call_method(dbus->bus, in dbus_sink_debug()
281 warnx("Failed to call CreateDump: %s", strerror(-rc)); in dbus_sink_debug()
288 warnx("Failed to extract dump object path: %s", strerror(-rc)); in dbus_sink_debug()
293 rc = sd_bus_match_signal(dbus->bus, in dbus_sink_debug()
303 path, strerror(-rc)); in dbus_sink_debug()
321 path, strerror(-rc)); in dbus_sink_debug()
328 rc = sd_bus_get_property_string(dbus->bus, in dbus_sink_debug()
337 path, strerror(-rc)); in dbus_sink_debug()
366 rc = sd_bus_call_method(dbus->bus, in dbus_sink_reboot()
375 "replace-irreversibly"); in dbus_sink_reboot()
377 warnx("Failed to start reboot.target: %s", strerror(-rc)); in dbus_sink_reboot()
391 dbus->pfds[DBUS_SOURCE_PFD_DBUS].fd = sd_bus_get_fd(dbus->bus); in dbus_source_poll()
392 dbus->pfds[DBUS_SOURCE_PFD_DBUS].events = sd_bus_get_events(dbus->bus); in dbus_source_poll()
393 rc = sd_bus_get_timeout(dbus->bus, &dbusto); in dbus_source_poll()
399 } else if (dbus->pfds[DBUS_SOURCE_PFD_DBUS].events == 0) { in dbus_source_poll()
411 if ((rc = ppoll(dbus->pfds, ARRAY_SIZE(dbus->pfds), ptsto, NULL)) < 0) { in dbus_source_poll()
413 return -errno; in dbus_source_poll()
416 if (dbus->pfds[DBUS_SOURCE_PFD_SOURCE].revents) { in dbus_source_poll()
419 if ((ingress = read(dbus->pfds[DBUS_SOURCE_PFD_SOURCE].fd, op, 1)) != 1) { in dbus_source_poll()
422 return -errno; in dbus_source_poll()
431 if (dbus->pfds[DBUS_SOURCE_PFD_DBUS].revents) { in dbus_source_poll()
432 if ((rc = sd_bus_process(dbus->bus, NULL)) < 0) { in dbus_source_poll()
433 warnx("Failed processing inbound D-Bus messages: %s", in dbus_source_poll()
434 strerror(-rc)); in dbus_source_poll()
471 while (!(rc = source->ops->poll(source->ctx, &command))) { in process()
475 sink->ops->debug(sink->ctx); in process()
479 sink->ops->reboot(sink->ctx); in process()
481 default: in process()
487 warnx("Failed to poll source: %s", strerror(-rc)); in process()
509 {"sink-actions", required_argument, 0, 's'}, in main()
515 if (c == -1) in main()
522 default: in main()
528 * The default behaviour sets the source file descriptor as stdin and the sink file in main()
529 * descriptor as stdout. This allows trivial testing on the command-line with just a in main()
545 devpath[PATH_MAX - 1] = '\0'; in main()
549 strncat(devnode, devid, sizeof(devnode) - strlen("/dev/")); in main()
550 devnode[PATH_MAX - 1] = '\0'; in main()
552 if ((sourcefd = open(devnode, O_RDONLY)) == -1) in main()
560 * --sink-actions option, then default to 'sysrq'. Otherwise, if --sink-actions=sysrq has in main()
569 if ((sinkfd = open(argv[optind], O_WRONLY)) == -1) in main()
584 /* Set up the dbus sink actions if requested via --sink-actions=dbus */ in main()
592 strerror(-rc)); in main()
606 /* Check we're done with the command-line */ in main()
608 errx(EXIT_FAILURE, "Found %d unexpected arguments", argc - optind); in main()
616 /* Trigger the actions on the sink when we receive an event from the source */ in main()