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.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs
index cd0c004..98bf4d5 100644
--- a/ripple/minitrace/src/main.rs
+++ b/ripple/minitrace/src/main.rs
@@ -212,11 +212,11 @@ define_syscalls! {
 		fn arch_prctl(option: i32, arg2: u64) -> i64 = 158;
 		fn set_tid_address(tidptr: *mut i32) -> i64 = 218;
 		fn exit_group(error_code: i32) -> i64 = 231;
-		fn openat(dfd: i32, filename: *const u8, flags: i32, mode: u16) -> i64 = 257;
+		fn openat(dfd: i32, filename: *const u8, flags: OpenFlags, mode: u16) -> i64 = 257;
 		fn newfstatat(dfd: i32, filename: *const u8, statbuf: *mut Stat, flag: i32) -> i64 = 262;
 		fn set_robust_list(head: *mut RobustListHead, len: usize) -> i64 = 273;
 		fn prlimit64(pid: i32, resource: u32, new_rlim: *const RLimit64, old_rlim: *mut RLimit64) -> i64 = 302;
-		fn getrandom(ubuf: *mut u8, len: usize, flags: u32) -> i64 = 318;
+		fn getrandom(ubuf: *mut u8, len: usize, flags: GrndFlags) -> i64 = 318;
 	}
 }
 
@@ -370,7 +370,6 @@ fn check_syscall(process: &Process, entry: SyscallEntry) -> bool {
 			}
 
 			let pathname = process.read_mem_cstr(filename as u64).unwrap();
-			let flags = OpenFlags::from_bits(flags).expect("unknown openat flags");
 
 			println!("openat(AT_FDCWD, {:?}, {:?}, ..)", pathname, flags);
 		}
@@ -415,7 +414,6 @@ fn check_syscall(process: &Process, entry: SyscallEntry) -> bool {
 			len,
 			flags,
 		} => {
-			let flags = GrndFlags::from_bits(flags).expect("unknown getrandom(2) flags");
 			println!("getrandom(.., {}, {:?})", len, flags);
 		}
 		_ => {}
@@ -437,3 +435,15 @@ bitflags! {
 		const GRND_RANDOM = 1 << 1;
 	}
 }
+
+impl SyscallArg for OpenFlags {
+	fn try_from_reg(reg: u64) -> Option<Self> {
+		SyscallArg::try_from_reg(reg).and_then(Self::from_bits)
+	}
+}
+
+impl SyscallArg for GrndFlags {
+	fn try_from_reg(reg: u64) -> Option<Self> {
+		SyscallArg::try_from_reg(reg).and_then(Self::from_bits)
+	}
+}