diff options
author | edef <edef@unfathomable.blue> | 2022-07-27 15:04:28 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-07-27 15:04:28 +0000 |
commit | 1186ca99272815713af1bbdfad63377fd9ccc604 (patch) | |
tree | 55aa20e842f20fe1e86ffdd229d98d9f52c70407 | |
parent | 528da0264c80ac03e4c823fa3503ba2cdf01a4f7 (diff) | |
download | unf-legacy-1186ca99272815713af1bbdfad63377fd9ccc604.tar.zst |
ripple/minitrace: implement SyscallArg for bitflags
Change-Id: I1b4e7e01b5d5c840ac2e94f9637552f71e61ed04
-rw-r--r-- | ripple/minitrace/src/main.rs | 18 |
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) + } +} |