From d9ad9d226fd4613509c73b99e13f11606c10ff0d Mon Sep 17 00:00:00 2001 From: Baitinq Date: Mon, 22 Jul 2024 22:43:00 +0200 Subject: fs-tracer: handle close syscall and properly serialize reqs --- tests/a.out | Bin 15872 -> 15872 bytes tests/openat.c | 15 +++++++++++---- tests/testfile | 5 +---- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/a.out b/tests/a.out index f601367..a6e5bdd 100755 Binary files a/tests/a.out and b/tests/a.out differ diff --git a/tests/openat.c b/tests/openat.c index 62628cc..d843d2f 100644 --- a/tests/openat.c +++ b/tests/openat.c @@ -8,19 +8,26 @@ int main(int argc, char** argv) { printf("PID: %d\n", getpid()); - int ret = syscall(SYS_openat, -100, "testfile", O_RDWR); - printf("Openat ret: %d\n", ret); + int fd = syscall(SYS_openat, -100, "testfile", O_RDWR); + printf("Openat ret: %d\n", fd); - if (ret == -1) { + if (fd == -1) { printf("Opneat error: %s\n", strerror(errno)); } - ret = syscall(SYS_write, ret, "writing this :)", 14); + int ret = syscall(SYS_write, fd, "I'm writing this :) pls.", 24); printf("Write ret: %d\n", ret); if (ret == -1) { printf("Write error: %s\n", strerror(errno)); } + + ret = syscall(SYS_close, fd); + printf("Close ret: %d\n", ret); + + if (ret == -1) { + printf("Close error: %s\n", strerror(errno)); + } return 0; } diff --git a/tests/testfile b/tests/testfile index f4ce76f..6426eb5 100644 --- a/tests/testfile +++ b/tests/testfile @@ -1,4 +1 @@ -writing this :t file - - -I have multiple lines :) +I'm writing this :) pls. \ No newline at end of file -- cgit 1.4.1