summary refs log tree commit diff
path: root/ripple
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-07-31 02:12:20 +0000
committeredef <edef@unfathomable.blue>2022-07-31 02:12:20 +0000
commit3eacf772994c05ece454c0899a32c4cf2afd4d59 (patch)
treedc2003dc72613fa64e838e9b937b593e235ff728 /ripple
parentd6da8cc095aa87488404fc796b0a6924e8f692cf (diff)
downloadunf-legacy-3eacf772994c05ece454c0899a32c4cf2afd4d59.tar.zst
ripple/minitrace: reduce check_syscall to just its namesake task
Printing gets moved into the main loop, and check_syscall gets a bunch
more compact.

Change-Id: Ifec602b92a5fb308148a474dd28247060ff15505
Diffstat (limited to 'ripple')
-rw-r--r--ripple/minitrace/src/main.rs42
1 files changed, 15 insertions, 27 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs
index c63cd88..811f6a9 100644
--- a/ripple/minitrace/src/main.rs
+++ b/ripple/minitrace/src/main.rs
@@ -263,6 +263,11 @@ fn main() -> Result<()> {
 					panic!("invalid syscall {entry:?}");
 				}
 
+				match entry {
+					SyscallEntry::times { .. } => {}
+					_ => println!("{entry:?}"),
+				}
+
 				syscall_state = Some(EntryExit::Entry(entry));
 			}
 			(Some(EntryExit::Entry(entry)), WaitStatus::PtraceSyscall(event_tid)) => {
@@ -304,30 +309,19 @@ fn check_syscall(entry: &SyscallEntry) -> bool {
 			}
 
 			match fd {
-				None => {
-					return flags.contains(MapFlags::ANONYMOUS) && off == 0;
-				}
+				None => flags.contains(MapFlags::ANONYMOUS) && off == 0,
 				Some(_) => {
-					return flags.intersection(MapFlags::PRIVATE | MapFlags::ANONYMOUS)
-						== MapFlags::PRIVATE;
+					flags.intersection(MapFlags::PRIVATE | MapFlags::ANONYMOUS) == MapFlags::PRIVATE
 				}
 			}
 		}
-		SyscallEntry::mprotect { addr, len, prot: _ } => {
-			return addr % 4096 == 0 && len % 4096 == 0;
-		}
+		SyscallEntry::mprotect { addr, len, prot: _ } => addr % 4096 == 0 && len % 4096 == 0,
 		SyscallEntry::openat {
 			dfd,
-			ref filename,
-			flags,
+			filename: _,
+			flags: _,
 			mode: _,
-		} => {
-			if dfd != DirFd::Cwd {
-				return false;
-			}
-
-			println!("openat({dfd:?}, {filename:?}, {flags:?}, ..)");
-		}
+		} => dfd == DirFd::Cwd,
 		SyscallEntry::newfstatat {
 			dfd,
 			ref filename,
@@ -337,18 +331,12 @@ fn check_syscall(entry: &SyscallEntry) -> bool {
 			match (dfd, filename.as_bytes()) {
 				(_, b"") if !flags.contains(AtFlags::EMPTY_PATH) => {
 					// empty path without AT_EMPTY_PATH
-					return false;
-				}
-				(DirFd::Cwd, _) | (_, b"") => {
-					println!("newfstatat({dfd:?}, {filename:?}, .., {flags:?})");
-				}
-				_ => {
-					return false;
+					false
 				}
+				(DirFd::Cwd, _) | (_, b"") => true,
+				_ => false,
 			}
 		}
-		SyscallEntry::times { .. } => {}
-		_ => println!("{entry:?}"),
+		_ => true,
 	}
-	true
 }