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
)
63 fprintf(stderr
, "Error: Missing argument\n");
64 fprintf(stderr
, "USAGE: %s PATH_WAIT_FILE\n", argv
[0]);
72 * Wait for the start_file to be created by an external process
73 * (typically the test script) before executing the syscalls.
75 ret
= wait_on_file(start_file
);
81 * Start generating syscalls. We use syscall(2) to prevent libc to change
82 * the underlying syscall. e.g. calling openat(2) instead of open(2).
84 ret
= open_read_close("/proc/cpuinfo");
90 ret
= open_read_close("/proc/cmdline");
This page took 0.039075 seconds and 6 git commands to generate.