From 58a2874ba52fa44bf8350c4fab259d237fe2d8b8 Mon Sep 17 00:00:00 2001 From: edef Date: Thu, 28 Jul 2022 00:29:57 +0000 Subject: ripple/minitrace: mark file descriptor parameters This doesn't specifically handle * the distinction between borrowed/owned file descriptors (in non-return positions, that only applies to `close`) * "nullable" fd parameters (-1 for not-present) * other sentinel fds, like AT_FDCWD * fd validity in general Change-Id: I00fa68ec94b8f24e28c661d0c007becb37c0a5f3 --- ripple/minitrace/src/main.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'ripple/minitrace/src') diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 7a70951..6db4747 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -209,6 +209,8 @@ impl SyscallArg for *mut u8 { } } +type FileDesc = i32; + type SigAction = (); type SysInfo = (); type Tms = (); @@ -230,15 +232,15 @@ impl SyscallArg for *const () { define_syscalls! { enum SyscallEntry { - fn read(fd: i32, buf: *mut u8, count: usize) -> i64 = 0; - fn write(fd: i32, buf: *const u8, count: usize) -> i64 = 1; - fn close(fd: i32) -> i64 = 3; - fn mmap(addr: u64, len: u64, prot: u64, flags: MapFlags, fd: i32, off: u64) -> i64 = 9; + fn read(fd: FileDesc, buf: *mut u8, count: usize) -> i64 = 0; + fn write(fd: FileDesc, buf: *const u8, count: usize) -> i64 = 1; + fn close(fd: FileDesc) -> i64 = 3; + fn mmap(addr: u64, len: u64, prot: u64, flags: MapFlags, fd: FileDesc, off: u64) -> i64 = 9; fn mprotect(addr: u64, len: usize, prot: u64) -> i64 = 10; fn brk(brk: u64) -> i64 = 12; fn rt_sigaction(sig: i32, act: *const SigAction, oact: *mut SigAction, sigsetsize: usize) -> i64 = 13; - fn ioctl(fd: u32, cmd: u32, arg: u64) -> i64 = 16; - fn pread64(fd: u32, buf: *mut u8, count: usize, pos: u64) -> i64 = 17; + 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 getcwd(buf: *mut u8, size: u64) -> i64 = 79; fn readlink(path: *const u8, buf: *mut u8, bufsiz: i32) -> i64 = 89; @@ -247,8 +249,8 @@ 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: OpenFlags, mode: u16) -> i64 = 257; - fn newfstatat(dfd: i32, filename: *const u8, statbuf: *mut Stat, flag: i32) -> i64 = 262; + fn openat(dfd: FileDesc, filename: *const u8, flags: OpenFlags, mode: u16) -> i64 = 257; + fn newfstatat(dfd: FileDesc, 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: GrndFlags) -> i64 = 318; -- cgit 1.4.1