syscalls: Make the flags and mode fields of open[at] enumerations
authorGeneviève Bastien <gbastien@versatic.net>
Wed, 11 Mar 2020 16:33:04 +0000 (12:33 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 23 Mar 2020 20:00:53 +0000 (16:00 -0400)
The open and openat system call have a flags and mode fields, whose values
are defined in the linux/fcntl.h file. These fields are now
enumerations that can be read as a bit field enum, to make the values more
readable / meaningful.

Here's an example babeltrace output of the open system call:

[...] syscall_entry_openat: { cpu_id = 0 }, { dfd = -100,
filename = "/tmp/edg0_383407",
flags = ( "O_RDWR" | "O_CREAT" | "O_TRUNC" : container = 578 ),
mode = ( "S_IWOTH" | "S_IROTH" | "S_IWGRP" | "S_IRGRP" |
   "S_IWUSR" | "S_IRUSR" : container = 438 ) }

Change-Id: Id7a516670b03e52fc75f9ff3c6ba8114c61a3865
Signed-off-by: Geneviève Bastien <gbastien@versatic.net>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/syscalls/headers/syscalls_pointers_override.h
lttng-syscalls.c

index e6821214679ab8ff89a1b0a5e8b099159187508f..c081b217ca1227661ac43998d4e75265f8c90989 100644 (file)
@@ -884,4 +884,86 @@ SC_LTTNG_TRACEPOINT_EVENT(socketpair,
 )
 #endif /* (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
 
+/*
+ * Enumeration of the open flags, as described in the 'open'
+ * system call man page.
+ */
+SC_LTTNG_TRACEPOINT_ENUM(lttng_file_status_flags,
+       TP_ENUM_VALUES(
+               ctf_enum_value("O_RDONLY", O_RDONLY)
+               ctf_enum_value("O_WRONLY", O_WRONLY)
+               ctf_enum_value("O_RDWR", O_RDWR)
+               ctf_enum_value("O_CREAT", O_CREAT)
+               ctf_enum_value("O_EXCL", O_EXCL)
+               ctf_enum_value("O_NOCTTY", O_NOCTTY)
+               ctf_enum_value("O_TRUNC", O_TRUNC)
+               ctf_enum_value("O_APPEND", O_APPEND)
+               ctf_enum_value("O_NONBLOCK", O_NONBLOCK)
+               ctf_enum_value("O_DSYNC", O_DSYNC)
+               ctf_enum_value("FASYNC", FASYNC)
+               ctf_enum_value("O_DIRECT", O_DIRECT)
+               ctf_enum_value("O_LARGEFILE", O_LARGEFILE)
+               ctf_enum_value("O_DIRECTORY", O_DIRECTORY)
+               ctf_enum_value("O_NOFOLLOW", O_NOFOLLOW)
+               ctf_enum_value("O_NOATIME", O_NOATIME)
+               ctf_enum_value("O_CLOEXEC", O_CLOEXEC)
+               ctf_enum_value("O_SYNC", __O_SYNC)
+               ctf_enum_value("O_PATH", O_PATH)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+               ctf_enum_value("O_TMPFILE", __O_TMPFILE)
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
+       )
+)
+
+/*
+ * Enumeration of the open flags, as described in the 'open'
+ * system call man page.
+ */
+SC_LTTNG_TRACEPOINT_ENUM(lttng_file_mode,
+       TP_ENUM_VALUES(
+               ctf_enum_value("S_IRWXU", S_IRWXU)
+               ctf_enum_value("S_IRUSR", S_IRUSR)
+               ctf_enum_value("S_IWUSR", S_IWUSR)
+               ctf_enum_value("S_IXUSR", S_IXUSR)
+               ctf_enum_value("S_IRWXG", S_IRWXG)
+               ctf_enum_value("S_IRGRP", S_IRGRP)
+               ctf_enum_value("S_IWGRP", S_IWGRP)
+               ctf_enum_value("S_IXGRP", S_IXGRP)
+               ctf_enum_value("S_IRWXO", S_IRWXO)
+               ctf_enum_value("S_IROTH", S_IROTH)
+               ctf_enum_value("S_IWOTH", S_IWOTH)
+               ctf_enum_value("S_IXOTH", S_IXOTH)
+               ctf_enum_value("S_ISUID", S_ISUID)
+               ctf_enum_value("S_ISGID", S_ISGID)
+               ctf_enum_value("S_ISVTX", S_ISVTX)
+       )
+)
+
+#define OVERRIDE_32_openat
+#define OVERRIDE_64_openat
+SC_LTTNG_TRACEPOINT_EVENT(openat,
+       TP_PROTO(sc_exit(long ret,) int dfd, const char * filename, int flags, umode_t mode),
+       TP_ARGS(sc_exit(ret,) dfd, filename, flags, mode),
+       TP_FIELDS(
+               sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, dfd, dfd))
+               sc_in(ctf_user_string(filename, filename))
+               sc_in(ctf_enum(lttng_file_status_flags, int, flags, flags))
+               sc_in(ctf_enum(lttng_file_mode, umode_t, mode, mode))
+       )
+)
+
+#define OVERRIDE_32_open
+#define OVERRIDE_64_open
+SC_LTTNG_TRACEPOINT_EVENT(open,
+       TP_PROTO(sc_exit(long ret,) const char * filename, int flags, umode_t mode),
+       TP_ARGS(sc_exit(ret,) filename, flags, mode),
+       TP_FIELDS(
+               sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_user_string(filename, filename))
+               sc_in(ctf_enum(lttng_file_status_flags, int, flags, flags))
+               sc_in(ctf_enum(lttng_file_mode, umode_t, mode, mode))
+       )
+)
+
 #endif /* CREATE_SYSCALL_TABLE */
index fb14f6b043a877a77176e94a5ff3926a4b180b07..a4ec3d5cf7313114f2ac3adfd1ee772c2713b10e 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/stringify.h>
 #include <linux/file.h>
 #include <linux/anon_inodes.h>
+#include <linux/fcntl.h>
 #include <asm/ptrace.h>
 #include <asm/syscall.h>
 
This page took 0.02711 seconds and 4 git commands to generate.