2 * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
10 #include <sys/syscall.h>
18 int open_read_close(const char *path
)
23 * Start generating syscalls. We use syscall(2) to prevent libc to change
24 * the underlying syscall. e.g. calling openat(2) instead of open(2).
26 fd
= syscall(SYS_openat
, AT_FDCWD
, path
, O_RDONLY
);
33 ret
= syscall(SYS_read
, fd
, buf
, MAX_LEN
);
40 ret
= syscall(SYS_close
, fd
);
52 * The process waits for the creation of a file passed as argument from an
53 * external processes to execute a syscall and exiting. This is useful for tests
54 * in combinaison with LTTng's PID tracker feature where we can trace the kernel
55 * events generated by our test process only.
57 int main(int argc
, char **argv
)
60 const char *start_file
, *path1
, *path2
;
63 fprintf(stderr
, "Error: Missing argument\n");
64 fprintf(stderr
, "USAGE: %s PATH_WAIT_FILE PATH1_TO_OPEN PATH2_TO_OPEN\n", argv
[0]);
65 fprintf(stderr
, "USAGE: %s PATH_WAIT_FILE\n", argv
[0]);
75 * Wait for the start_file to be created by an external process
76 * (typically the test script) before executing the syscalls.
78 ret
= wait_on_file(start_file
);
84 * Start generating syscalls. We use syscall(2) to prevent libc to change
85 * the underlying syscall. e.g. calling openat(2) instead of open(2).
87 ret
= open_read_close(path1
);
93 ret
= open_read_close(path2
);
This page took 0.034468 seconds and 5 git commands to generate.