[RFC PATCH 08/24] erofs: add device data structure in Rust
Jianan Huang
jnhuang95 at gmail.com
Sat Sep 21 19:18:29 AEST 2024
Yiyang Wu via Linux-erofs <linux-erofs at lists.ozlabs.org> 于2024年9月16日周一
21:57写道:
> This patch introduce device data structure in Rust.
> It can later support chunk based block maps.
>
> Signed-off-by: Yiyang Wu <toolmanp at tlmp.cc>
> ---
> fs/erofs/rust/erofs_sys.rs | 1 +
> fs/erofs/rust/erofs_sys/devices.rs | 28 ++++++++++++++++++++++++++++
> 2 files changed, 29 insertions(+)
> create mode 100644 fs/erofs/rust/erofs_sys/devices.rs
>
> diff --git a/fs/erofs/rust/erofs_sys.rs b/fs/erofs/rust/erofs_sys.rs
> index 8cca2cd9b75f..f1a1e491caec 100644
> --- a/fs/erofs/rust/erofs_sys.rs
> +++ b/fs/erofs/rust/erofs_sys.rs
> @@ -25,6 +25,7 @@
>
> pub(crate) mod alloc_helper;
> pub(crate) mod data;
> +pub(crate) mod devices;
> pub(crate) mod errnos;
> pub(crate) mod inode;
> pub(crate) mod superblock;
> diff --git a/fs/erofs/rust/erofs_sys/devices.rs b/fs/erofs/rust/erofs_sys/
> devices.rs
> new file mode 100644
> index 000000000000..097676ee8720
> --- /dev/null
> +++ b/fs/erofs/rust/erofs_sys/devices.rs
> @@ -0,0 +1,28 @@
> +// Copyright 2024 Yiyang Wu
> +// SPDX-License-Identifier: MIT or GPL-2.0-or-later
> +
> +use alloc::vec::Vec;
> +
> +/// Device specification.
> +#[derive(Copy, Clone, Debug)]
> +pub(crate) struct DeviceSpec {
> + pub(crate) tags: [u8; 64],
>
I think we don't need to keep tags in the memory. It's not used in flatdev
mode
or when mount with "-o device". It can be replaced with a string like the C
version,
since it may represent a file path of variable length, or ignore this field
for now.
Thanks,
Jianan
> + pub(crate) blocks: u32,
> + pub(crate) mapped_blocks: u32,
> +}
> +
> +/// Device slot.
> +#[derive(Copy, Clone, Debug)]
> +#[repr(C)]
> +pub(crate) struct DeviceSlot {
> + tags: [u8; 64],
> + blocks: u32,
> + mapped_blocks: u32,
> + reserved: [u8; 56],
> +}
> +
> +/// Device information.
> +pub(crate) struct DeviceInfo {
> + pub(crate) mask: u16,
> + pub(crate) specs: Vec<DeviceSpec>,
> +}
> --
> 2.46.0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20240921/524d40db/attachment.htm>
More information about the Linux-erofs
mailing list