<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Yiyang Wu via Linux-erofs <<a href="mailto:linux-erofs@lists.ozlabs.org">linux-erofs@lists.ozlabs.org</a>> 于2024年9月16日周一 21:57写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This patch introduce device data structure in Rust.<br>
It can later support chunk based block maps.<br>
<br>
Signed-off-by: Yiyang Wu <<a href="mailto:toolmanp@tlmp.cc" target="_blank">toolmanp@tlmp.cc</a>><br>
---<br>
fs/erofs/rust/<a href="http://erofs_sys.rs" rel="noreferrer" target="_blank">erofs_sys.rs</a> | 1 +<br>
fs/erofs/rust/erofs_sys/<a href="http://devices.rs" rel="noreferrer" target="_blank">devices.rs</a> | 28 ++++++++++++++++++++++++++++<br>
2 files changed, 29 insertions(+)<br>
create mode 100644 fs/erofs/rust/erofs_sys/<a href="http://devices.rs" rel="noreferrer" target="_blank">devices.rs</a><br>
<br>
diff --git a/fs/erofs/rust/<a href="http://erofs_sys.rs" rel="noreferrer" target="_blank">erofs_sys.rs</a> b/fs/erofs/rust/<a href="http://erofs_sys.rs" rel="noreferrer" target="_blank">erofs_sys.rs</a><br>
index 8cca2cd9b75f..f1a1e491caec 100644<br>
--- a/fs/erofs/rust/<a href="http://erofs_sys.rs" rel="noreferrer" target="_blank">erofs_sys.rs</a><br>
+++ b/fs/erofs/rust/<a href="http://erofs_sys.rs" rel="noreferrer" target="_blank">erofs_sys.rs</a><br>
@@ -25,6 +25,7 @@<br>
<br>
pub(crate) mod alloc_helper;<br>
pub(crate) mod data;<br>
+pub(crate) mod devices;<br>
pub(crate) mod errnos;<br>
pub(crate) mod inode;<br>
pub(crate) mod superblock;<br>
diff --git a/fs/erofs/rust/erofs_sys/<a href="http://devices.rs" rel="noreferrer" target="_blank">devices.rs</a> b/fs/erofs/rust/erofs_sys/<a href="http://devices.rs" rel="noreferrer" target="_blank">devices.rs</a><br>
new file mode 100644<br>
index 000000000000..097676ee8720<br>
--- /dev/null<br>
+++ b/fs/erofs/rust/erofs_sys/<a href="http://devices.rs" rel="noreferrer" target="_blank">devices.rs</a><br>
@@ -0,0 +1,28 @@<br>
+// Copyright 2024 Yiyang Wu<br>
+// SPDX-License-Identifier: MIT or GPL-2.0-or-later<br>
+<br>
+use alloc::vec::Vec;<br>
+<br>
+/// Device specification.<br>
+#[derive(Copy, Clone, Debug)]<br>
+pub(crate) struct DeviceSpec {<br>
+ pub(crate) tags: [u8; 64],<br></blockquote><div><br></div><div>I think we don't need to keep tags in the memory. It's not used in flatdev mode <br>or when mount with "-o device". It can be replaced with a string like the C version, <br>since it may represent a file path of variable length, or ignore this field for now.<br></div><div><br></div><div>Thanks,</div><div>Jianan</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ pub(crate) blocks: u32,<br>
+ pub(crate) mapped_blocks: u32,<br>
+}<br>
+<br>
+/// Device slot.<br>
+#[derive(Copy, Clone, Debug)]<br>
+#[repr(C)]<br>
+pub(crate) struct DeviceSlot {<br>
+ tags: [u8; 64],<br>
+ blocks: u32,<br>
+ mapped_blocks: u32,<br>
+ reserved: [u8; 56],<br>
+}<br>
+<br>
+/// Device information.<br>
+pub(crate) struct DeviceInfo {<br>
+ pub(crate) mask: u16,<br>
+ pub(crate) specs: Vec<DeviceSpec>,<br>
+}<br>
-- <br>
2.46.0<br>
<br>
</blockquote></div></div>