From c29157e78df7fa335c56d0d7f2cca7dc50bfffd6 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Tue, 2 May 2023 17:21:57 +0200 Subject: seitan: refactor operations Refactoring: - rename do_operations to eval and reduce the number of arguments - create macro HANDLE_OP - rename all functions with op_*(operation name) - exposed the op_* functions in the operations.h Fixes: - use pread for op_load --- seitan.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'seitan.c') diff --git a/seitan.c b/seitan.c index e2e5347..4a4cc86 100644 --- a/seitan.c +++ b/seitan.c @@ -184,6 +184,7 @@ int main(int argc, char **argv) struct epoll_event ev, events[EPOLL_EVENTS]; struct seccomp_notif *req = (struct seccomp_notif *)req_b; struct arguments arguments; + struct op operations[INST_MAX]; char path[PATH_MAX + 1]; bool running = true; int pidfd, notifier; @@ -236,19 +237,7 @@ int main(int argc, char **argv) /* The notifier fd was closed by the target */ running = false; } else if (notifier == events[i].data.fd) { - /* - * TODO: remove until we parse correctly the - * operations from the bytecode - */ - struct op operations[] = { - { .type = OP_CONT }, - }; - if (do_operations(NULL, operations, req, - sizeof(operations) / - sizeof(operations[0]), - notifier) == -1) - die(" failed executing operation"); - + eval(NULL, &operations[0], req, notifier); } } } -- cgit v1.2.3