From a071e4631d18dad45bd247ee2728be50ca33ed39 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 14 Jun 2023 12:05:54 +0200 Subject: cooker/calls: Actually add io.{c,h} Signed-off-by: Stefano Brivio --- cooker/calls/io.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ cooker/calls/io.h | 11 +++++ 2 files changed, 135 insertions(+) create mode 100644 cooker/calls/io.c create mode 100644 cooker/calls/io.h (limited to 'cooker/calls') diff --git a/cooker/calls/io.c b/cooker/calls/io.c new file mode 100644 index 0000000..41dbe71 --- /dev/null +++ b/cooker/calls/io.c @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/* seitan - Syscall Expressive Interpreter, Transformer and Notifier + * + * cooker/calls/io.c - Description of known input/output system calls + * + * Copyright 2023 Red Hat GmbH + * Author: Stefano Brivio + */ + +/* +read +write +open +close + +pread +pwrite +readv +writev +preadv +pwritev +copy_file_range +preadv2 +pwritev2 + +openat2 +*/ + +#include +#include + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include "../cooker.h" +#include "../calls.h" + +static struct num open_flags[] = { + { "rdonly", O_RDONLY }, + { "wronly", O_WRONLY }, + { "rdwr", O_RDWR }, + { 0 }, +}; + +static struct num open_modes[] = { + { "S_ISUID", S_ISUID }, + { "S_ISGID", S_ISGID }, + { "S_IRWXU", S_IRWXU }, + { "S_IRUSR", S_IRUSR }, + { "S_IWUSR", S_IWUSR }, + { "S_IXUSR", S_IXUSR }, + { "S_IRWXG", S_IRWXG }, + { "S_IRGRP", S_IRGRP }, + { "S_IWGRP", S_IWGRP }, + { "S_IXGRP", S_IXGRP }, + { "S_IRWXO", S_IRWXO }, + { "S_IROTH", S_IROTH }, + { "S_IWOTH", S_IWOTH }, + { "S_IXOTH", S_IXOTH }, + { "S_ISVTX", S_ISVTX }, + { 0 }, +}; + +static struct arg read_args[] = { + { 0, + { + "fd", INT, 0, 0, 0, + { 0 } + } + }, + { 0, + { + "path", FDPATH, 0, 0, 0, + { 0 } + } + }, + { 1, + { + "buf", STRING, RBUF, 0, BUFSIZ, + { 0 } + } + }, + { 2, + { + "count", LONG, SIZE, -1, 0, + { .d_size = (intptr_t)&read_args[1] } + } + }, + { 0 }, +}; + +static struct arg open_args[] = { + { 0, + { + "path", STRING, 0, + 0, PATH_MAX, + { 0 } + } + }, + { 1, + { + "flags", INT, MASK | FLAGS, 0, 0, + { .d_num = open_flags } + } + }, + { 2, + { + "mode", INT, MASK | FLAGS, 0, 0, + { .d_num = open_modes } + } + }, + { 0 }, +}; + +struct call syscalls_io[] = { + { __NR_read, "read", read_args }, + { __NR_open, "open", open_args }, + { 0 }, +}; diff --git a/cooker/calls/io.h b/cooker/calls/io.h new file mode 100644 index 0000000..aa08dbd --- /dev/null +++ b/cooker/calls/io.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2023 Red Hat GmbH + * Author: Stefano Brivio + */ + +#ifndef CALLS_IO_H +#define CALLS_IO_H + +extern struct call syscalls_io[]; + +#endif /* CALLS_IO_H */ -- cgit v1.2.3