From 26aeaad5ea9013bbd8ae104ab2edaf800228113e Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 29 Jul 2022 17:14:15 +0000 Subject: ripple/minitrace: replace read_mem_cstr calls with CString arguments Change-Id: Ib8aec16cfca88db69765e7fa25aeaf8ea240f18d --- ripple/minitrace/src/main.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'ripple/minitrace') diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 09b694c..0f1d278 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -278,16 +278,16 @@ define_syscalls! { fn rt_sigaction(sig: i32, act: *const SigAction, oact: *mut SigAction, sigsetsize: usize) -> i64 = 13; fn ioctl(fd: FileDesc, cmd: u32, arg: u64) -> i64 = 16; fn pread64(fd: FileDesc, buf: *mut u8, count: usize, pos: u64) -> i64 = 17; - fn access(filename: *const u8, mode: i32) -> i64 = 21; + fn access(filename: CString, mode: i32) -> i64 = 21; fn getcwd(buf: *mut u8, size: u64) -> i64 = 79; - fn readlink(path: *const u8, buf: *mut u8, bufsiz: i32) -> i64 = 89; + fn readlink(path: CString, buf: *mut u8, bufsiz: i32) -> i64 = 89; fn sysinfo(info: *mut SysInfo) -> i64 = 99; fn times(tbuf: *mut Tms) -> i64 = 100; 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: FileDesc, filename: *const u8, flags: OpenFlags, mode: u16) -> i64 = 257; - fn newfstatat(dfd: FileDesc, filename: *const u8, statbuf: *mut Stat, flags: i32) -> i64 = 262; + fn openat(dfd: FileDesc, filename: CString, flags: OpenFlags, mode: u16) -> i64 = 257; + fn newfstatat(dfd: FileDesc, filename: CString, statbuf: *mut Stat, flags: 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: GrndFlags) -> i64 = 318; @@ -411,16 +411,17 @@ fn check_syscall(process: &Process, entry: &SyscallEntry) -> bool { _ => return false, } } - SyscallEntry::access { filename, mode: _ } => { - let filename = process.read_mem_cstr(filename as u64).unwrap(); + SyscallEntry::access { + ref filename, + mode: _, + } => { println!("access({filename:?}, ..)"); } SyscallEntry::readlink { - path, + ref path, buf: _, bufsiz: _, } => { - let path = process.read_mem_cstr(path as u64).unwrap(); println!("readlink({path:?}, ..)"); } SyscallEntry::arch_prctl { option, arg2: _ } => { @@ -435,7 +436,7 @@ fn check_syscall(process: &Process, entry: &SyscallEntry) -> bool { } SyscallEntry::openat { dfd, - filename, + ref filename, flags, mode: _, } => { @@ -443,17 +444,14 @@ fn check_syscall(process: &Process, entry: &SyscallEntry) -> bool { return false; } - let filename = process.read_mem_cstr(filename as u64).unwrap(); - println!("openat(AT_FDCWD, {filename:?}, {flags:?}, ..)"); } SyscallEntry::newfstatat { dfd, - filename, + ref filename, statbuf: _, flags: _, } => { - let filename = process.read_mem_cstr(filename as u64).unwrap(); if dfd == AT_FDCWD { println!("newfstatat(AT_FDCWD, {filename:?}, ..)"); } else if filename.as_bytes() == b"" { -- cgit 1.4.1