summary refs log tree commit diff
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-07-31 20:17:19 +0000
committeredef <edef@unfathomable.blue>2022-07-31 20:17:19 +0000
commit619a33cc77f508b75e713bd4e12e58c16ca1267b (patch)
tree79feca247115bceff8fd1adb0187e88baf413612
parentdbd1db43fc8db263134e85cbf9e8312cdd0e4c2b (diff)
downloadunf-legacy-619a33cc77f508b75e713bd4e12e58c16ca1267b.tar.zst
ripple/minitrace/maps_file: represent protection bits with ProtFlags
Change-Id: Ia9dbddcd13da3fcb0c0ef30082d6f6750e4014da
-rw-r--r--ripple/minitrace/src/maps_file.rs40
1 files changed, 25 insertions, 15 deletions
diff --git a/ripple/minitrace/src/maps_file.rs b/ripple/minitrace/src/maps_file.rs
index 7a48147..86e118a 100644
--- a/ripple/minitrace/src/maps_file.rs
+++ b/ripple/minitrace/src/maps_file.rs
@@ -2,7 +2,7 @@
 // SPDX-License-Identifier: OSL-3.0
 
 use {
-	crate::syscall_abi::Device,
+	crate::syscall_abi::{Device, ProtFlags},
 	anyhow::bail,
 	nom::{
 		branch::alt,
@@ -107,14 +107,26 @@ fn mapping(input: &str) -> IResult<&str, Mapping> {
 		_ => unreachable!(),
 	};
 
+	let mut prot = ProtFlags::empty();
+
+	if perm_read {
+		prot |= ProtFlags::READ;
+	}
+
+	if perm_write {
+		prot |= ProtFlags::WRITE;
+	}
+
+	if perm_exec {
+		prot |= ProtFlags::EXEC;
+	}
+
 	Ok((
 		input,
 		Mapping {
 			start,
 			end,
-			perm_read,
-			perm_write,
-			perm_exec,
+			prot,
 			shared,
 			offset,
 			inode,
@@ -135,9 +147,7 @@ pub(crate) fn parse_mapping_line(line: &str) -> anyhow::Result<Mapping> {
 pub(crate) struct Mapping {
 	pub(crate) start: u64,
 	pub(crate) end: u64,
-	pub(crate) perm_read: bool,
-	pub(crate) perm_write: bool,
-	pub(crate) perm_exec: bool,
+	pub(crate) prot: ProtFlags,
 	pub(crate) shared: bool,
 	pub(crate) offset: u64,
 	pub(crate) inode: Option<Inode>,
@@ -157,9 +167,7 @@ impl Debug for Mapping {
 		let Mapping {
 			start,
 			end,
-			perm_read,
-			perm_write,
-			perm_exec,
+			prot,
 			shared,
 			offset,
 			inode,
@@ -172,8 +180,12 @@ impl Debug for Mapping {
 
 		write!(f, "{start:016x}-{end:016x} ")?;
 
-		for (c, p) in [('r', perm_read), ('w', perm_write), ('x', perm_exec)] {
-			f.write_char(if p { c } else { '-' })?;
+		for (c, p) in [
+			('r', ProtFlags::READ),
+			('w', ProtFlags::WRITE),
+			('x', ProtFlags::EXEC),
+		] {
+			f.write_char(if prot.contains(p) { c } else { '-' })?;
 		}
 		f.write_char(if shared { 's' } else { 'p' })?;
 		f.write_char(' ')?;
@@ -193,9 +205,7 @@ fn golden_mapping() {
 	let golden = Mapping {
 		start: 0x00400000,
 		end: 0x00407000,
-		perm_read: true,
-		perm_write: false,
-		perm_exec: false,
+		prot: ProtFlags::READ,
 		shared: false,
 		offset: 0,
 		inode: Some(Inode {