summary refs log tree commit diff
path: root/ripple/minitrace
diff options
context:
space:
mode:
Diffstat (limited to 'ripple/minitrace')
-rw-r--r--ripple/minitrace/Cargo.toml3
-rw-r--r--ripple/minitrace/src/main.rs23
2 files changed, 20 insertions, 6 deletions
diff --git a/ripple/minitrace/Cargo.toml b/ripple/minitrace/Cargo.toml
index 8eb58f0..95de7a4 100644
--- a/ripple/minitrace/Cargo.toml
+++ b/ripple/minitrace/Cargo.toml
@@ -8,4 +8,5 @@ edition = "2018"
 
 [dependencies]
 nix = "0.23.1"
-anyhow = "1.0.43"
+anyhow = "1.0.53"
+bitflags = "1.3.2"
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;
+	}
+}