summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ripple/Cargo.lock9
-rw-r--r--ripple/minitrace/Cargo.toml3
-rw-r--r--ripple/minitrace/src/main.rs23
3 files changed, 25 insertions, 10 deletions
diff --git a/ripple/Cargo.lock b/ripple/Cargo.lock
index 2a499f9..b20b671 100644
--- a/ripple/Cargo.lock
+++ b/ripple/Cargo.lock
@@ -4,9 +4,9 @@ version = 3
 
 [[package]]
 name = "anyhow"
-version = "1.0.43"
+version = "1.0.53"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf"
+checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
 
 [[package]]
 name = "arrayref"
@@ -28,9 +28,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
 
 [[package]]
 name = "bitflags"
-version = "1.3.1"
+version = "1.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
 [[package]]
 name = "blake3"
@@ -316,6 +316,7 @@ name = "minitrace"
 version = "0.0.0"
 dependencies = [
  "anyhow",
+ "bitflags",
  "nix",
 ]
 
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;
+	}
+}