about summary refs log tree commit diff
path: root/tests/openat.c
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-07-22 22:43:00 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-07-22 22:43:00 +0200
commitd9ad9d226fd4613509c73b99e13f11606c10ff0d (patch)
tree54e25ba99e915e0905d272ad5e293958a38fc7db /tests/openat.c
parentfs-tracer: open files should be referenced with pid+fd (diff)
downloadfs-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/openat.c')
-rw-r--r--tests/openat.c15
1 files changed, 11 insertions, 4 deletions
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;
 }