summary refs log tree commit diff
path: root/ripple/minitrace/src
diff options
context:
space:
mode:
Diffstat (limited to 'ripple/minitrace/src')
-rw-r--r--ripple/minitrace/src/main.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs
index 6b7c044..424c6f2 100644
--- a/ripple/minitrace/src/main.rs
+++ b/ripple/minitrace/src/main.rs
@@ -4,6 +4,7 @@
 
 use {
 	anyhow::{bail, Context, Result},
+	bitflags::bitflags,
 	nix::{
 		libc,
 		sys::{
@@ -263,17 +264,19 @@ fn check_syscall(process: &Process, entry: SyscallEntry) -> bool {
 
 		// openat
 		257 => {
-			let [dirfd, pathname, _flags, _mode, _, _] = entry.args;
+			let [dirfd, pathname, flags, _mode, _, _] = entry.args;
 			const AT_FDCWD: i32 = -100;
 
 			if dirfd.try_into() == Ok(AT_FDCWD) {
 				return false;
 			}
 
-			println!(
-				"openat(AT_FDCWD, {:?}, ..)",
-				process.read_mem_cstr(pathname).unwrap()
-			);
+			let pathname = process.read_mem_cstr(pathname).unwrap();
+
+			let flags: i32 = flags.try_into().expect("openat(2) flags don't fit in i32");
+			let flags = OpenFlags::from_bits(flags).expect("unknown openat flags");
+
+			println!("openat(AT_FDCWD, {:?}, {:?}, ..)", pathname, flags);
 		}
 
 		// newfstatat
@@ -296,3 +299,13 @@ fn check_syscall(process: &Process, entry: SyscallEntry) -> bool {
 	}
 	true
 }
+
+bitflags! {
+	struct OpenFlags: i32 {
+		const WRONLY  = 0o00000001;
+		const CREAT   = 0o00000100;
+		const NOCTTY  = 0o00000400;
+		const TRUNC   = 0o00001000;
+		const CLOEXEC = 0o02000000;
+	}
+}