diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-07-22 22:43:00 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-07-22 22:43:00 +0200 |
commit | d9ad9d226fd4613509c73b99e13f11606c10ff0d (patch) | |
tree | 54e25ba99e915e0905d272ad5e293958a38fc7db /tests | |
parent | fs-tracer: open files should be referenced with pid+fd (diff) | |
download | fs-tracer-d9ad9d226fd4613509c73b99e13f11606c10ff0d.tar.gz fs-tracer-d9ad9d226fd4613509c73b99e13f11606c10ff0d.tar.bz2 fs-tracer-d9ad9d226fd4613509c73b99e13f11606c10ff0d.zip |
fs-tracer: handle close syscall and properly serialize reqs
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/a.out | bin | 15872 -> 15872 bytes | |||
-rw-r--r-- | tests/openat.c | 15 | ||||
-rw-r--r-- | tests/testfile | 5 |
3 files changed, 12 insertions, 8 deletions
diff --git a/tests/a.out b/tests/a.out index f601367..a6e5bdd 100755 --- a/tests/a.out +++ b/tests/a.out Binary files differdiff --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 |