Initial commit

This commit is contained in:
pjht 2024-09-04 10:44:46 -05:00
commit db15daee83
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E
6 changed files with 822 additions and 0 deletions

5
.cargo/config.toml Normal file
View File

@ -0,0 +1,5 @@
[build]
target = "x86_64-unknown-mikros"
[install]
root = "../os_build/sysroot"

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

489
Cargo.lock generated Normal file
View File

@ -0,0 +1,489 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "atomic-polyfill"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
dependencies = [
"critical-section",
]
[[package]]
name = "autocfg"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "bitflags"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cobs"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
[[package]]
name = "critical-section"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f64009896348fc5af4222e9cf7d7d82a95a256c634ebcf61c53e4ea461422242"
[[package]]
name = "crossbeam-utils"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "dashmap"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28"
dependencies = [
"cfg-if",
"crossbeam-utils",
"hashbrown",
"lock_api",
"once_cell",
"parking_lot_core",
]
[[package]]
name = "dev_driver_rpc"
version = "0.1.0"
dependencies = [
"parking_lot",
"postcard",
"serde",
]
[[package]]
name = "devfs_rpc"
version = "0.1.0"
dependencies = [
"parking_lot",
"postcard",
"serde",
]
[[package]]
name = "either"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]]
name = "embedded-io"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
[[package]]
name = "embedded-io"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
[[package]]
name = "file_rpc"
version = "0.1.0"
dependencies = [
"parking_lot",
"postcard",
"serde",
]
[[package]]
name = "hash32"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
dependencies = [
"byteorder",
]
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "heapless"
version = "0.7.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
dependencies = [
"atomic-polyfill",
"hash32",
"rustc_version",
"serde",
"spin",
"stable_deref_trait",
]
[[package]]
name = "humansize"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
dependencies = [
"libm",
]
[[package]]
name = "itertools"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.158"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
[[package]]
name = "libm"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "parking_lot"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
]
[[package]]
name = "partserv"
version = "0.1.0"
dependencies = [
"dashmap",
"dev_driver_rpc",
"devfs_rpc",
"file_rpc",
"humansize",
"itertools",
"sharded-slab",
"syslog_msg_ipc",
"syslog_rpc",
"uuid",
"vfs_rpc",
]
[[package]]
name = "postcard"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e"
dependencies = [
"cobs",
"embedded-io 0.4.0",
"embedded-io 0.6.1",
"heapless",
"postcard-derive",
"serde",
]
[[package]]
name = "postcard-derive"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0239fa9c1d225d4b7eb69925c25c5e082307a141e470573fbbe3a817ce6a7a37"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "proc-macro2"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
dependencies = [
"bitflags",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]]
name = "serde"
version = "1.0.209"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.209"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.76",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]]
name = "smallvec"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
dependencies = [
"lock_api",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syslog_msg_ipc"
version = "0.1.0"
dependencies = [
"parking_lot",
"postcard",
"syslog_structs",
]
[[package]]
name = "syslog_rpc"
version = "0.1.0"
dependencies = [
"parking_lot",
"postcard",
"syslog_structs",
]
[[package]]
name = "syslog_structs"
version = "0.1.0"
dependencies = [
"serde",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "uuid"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314"
[[package]]
name = "vfs_rpc"
version = "0.1.0"
dependencies = [
"parking_lot",
"postcard",
"serde",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

24
Cargo.toml Normal file
View File

@ -0,0 +1,24 @@
[package]
name = "partserv"
version = "0.1.0"
edition = "2021"
[dependencies]
dashmap = "6.0.1"
dev_driver_rpc = { version = "0.1.0", path = "../dev_driver_rpc" }
devfs_rpc = { version = "0.1.0", path = "../devfs/devfs_rpc" }
file_rpc = { version = "0.1.0", path = "../file_rpc" }
humansize = "2.1.3"
itertools = "0.13.0"
sharded-slab = "0.1.7"
syslog_msg_ipc = { version = "0.1.0", path = "../syslog/syslog_msg_ipc" }
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
uuid = "1.10.0"
vfs_rpc = { version = "0.1.0", path = "../vfs/vfs_rpc" }
# [profile.release]
# strip = true
# lto = true
# opt-level = "z"
# codegen-units=1

2
rust-toolchain.toml Normal file
View File

@ -0,0 +1,2 @@
[toolchain]
channel = "dev-x86_64-unknown-mikros"

301
src/main.rs Normal file
View File

@ -0,0 +1,301 @@
use std::{
fs::File,
io::{Read, Seek, SeekFrom},
os::mikros::{ipc, syscalls},
path::Path,
sync::Arc,
};
use dashmap::DashMap;
use itertools::Itertools;
use sharded_slab::Slab;
use uuid::Uuid;
#[derive(Clone, Copy, Debug, Default)]
#[allow(unused)]
struct MbrEntry {
active: bool,
typ: u8,
start: u32,
size: u32,
}
#[derive(Clone, Debug, Default)]
#[allow(unused)]
struct GptEntry {
type_guid: Uuid,
entry_guid: Uuid,
start: u64,
len: u64,
name: String,
}
#[derive(Clone)]
struct Serv {
parts: Arc<DashMap<String, ((u64, u64), u64, usize)>>,
open_files: Arc<Slab<((u64, u64), u64, usize)>>,
}
impl dev_driver_rpc::Server for Serv {
fn open(&self, path: &std::path::Path) -> Result<u64, ()> {
let part = *(self.parts.get(path.to_str().unwrap()).ok_or(())?);
Ok(self.open_files.insert(part).unwrap() as u64)
}
}
impl file_rpc::Server for Serv {
fn read(&self, fd: u64, pos: u64, len: usize) -> Result<std::borrow::Cow<'_, [u8]>, ()> {
let &(drive_file, offset, part_len) = &*self.open_files.get(fd as usize).ok_or(())?;
if pos.saturating_add(len as u64) > part_len as u64 {
return Err(());
}
Ok(file_rpc::Client::new(drive_file.0)
.read(drive_file.1, offset + pos, len)?
.into())
}
fn write(&self, _fd: u64, _pos: u64, _data: &[u8]) -> Result<(), ()> {
todo!()
}
fn close(&self, _fd: u64) {}
fn size(&self, fd: u64) -> Option<u64> {
Some(self.open_files.get(fd as usize)?.2 as u64)
}
}
fn parse_mbr(mut disk: &File) -> Vec<MbrEntry> {
let mut mbr = [0; 512];
disk.read_exact(&mut mbr).unwrap();
(0..4)
.map(|i| {
let entry_offset = 0x1BE + 0x10 * i;
let active = mbr[entry_offset] & 0x80 == 0x80;
let typ = mbr[entry_offset + 0x4];
let start = u32::from_le_bytes(
mbr[entry_offset + 0x8..entry_offset + 0xC]
.try_into()
.unwrap(),
);
let size = u32::from_le_bytes(
mbr[entry_offset + 0xC..entry_offset + 0x10]
.try_into()
.unwrap(),
);
MbrEntry {
active,
typ,
start,
size,
}
})
.collect_vec()
}
fn parse_gpt(mut disk: &File) -> Result<(Uuid, Vec<GptEntry>), ()> {
let mut gpt_header = [0; 512];
disk.seek(SeekFrom::Start(512)).unwrap();
disk.read_exact(&mut gpt_header).unwrap();
if &gpt_header[0..8] != b"EFI PART" {
return Err(());
}
let disk_guid = Uuid::from_bytes_le(gpt_header[56..72].try_into().unwrap());
let part_table_start_lba = u64::from_le_bytes(gpt_header[72..80].try_into().unwrap()) as usize;
let num_parts = u32::from_le_bytes(gpt_header[80..84].try_into().unwrap()) as usize;
let entry_len = u32::from_le_bytes(gpt_header[84..88].try_into().unwrap()) as usize;
let part_table_len = num_parts * entry_len;
let mut gpt_part_table = vec![0; part_table_len.next_multiple_of(512)];
disk.seek(SeekFrom::Start((part_table_start_lba * 512) as u64))
.unwrap();
disk.read_exact(&mut gpt_part_table).unwrap();
let mut parts = Vec::new();
for i in 0..num_parts {
let entry_offset = i * entry_len;
let entry_data = &gpt_part_table[entry_offset..(entry_offset + entry_len)];
if entry_data[0..16] == [0; 16] {
continue;
}
let type_guid = Uuid::from_bytes_le(entry_data[0..16].try_into().unwrap());
let entry_guid = Uuid::from_bytes_le(entry_data[16..32].try_into().unwrap());
let start = u64::from_le_bytes(entry_data[32..40].try_into().unwrap());
let end = u64::from_le_bytes(entry_data[40..48].try_into().unwrap());
let len = end - start;
let name = &entry_data[56..]
.iter()
.tuples::<(_, _)>()
.map(|(&x, &y)| u16::from_le_bytes([x, y]))
.collect_vec();
let name = String::from_utf16(name)
.unwrap()
.trim_matches([' ', '\0'])
.to_owned();
parts.push(GptEntry {
type_guid,
entry_guid,
start,
len,
name,
})
}
Ok((disk_guid, parts))
}
fn main() {
syslog_msg_ipc::register_callback();
let syslog_pid = loop {
if let Some(pid) = syscalls::try_get_registered(2) {
break pid;
}
};
let devfs_pid = loop {
if let Some(pid) = syscalls::try_get_registered(1) {
break pid;
}
};
let vfs_pid = loop {
if let Some(pid) = syscalls::try_get_registered(0) {
break pid;
}
};
let vfs_client = vfs_rpc::Client::new(vfs_pid);
let syslog_client = syslog_rpc::Client::new(syslog_pid);
syslog_client.subscribe_to_binary("blockdev".to_string(), vec![0]);
syslog_client
.send_text_message("partserv", "Partition table server initialized")
.unwrap();
let parts = Arc::new(DashMap::new());
let serv = Serv {
parts: Arc::clone(&parts),
open_files: Arc::new(Slab::new()),
};
dev_driver_rpc::register_server(Box::new(serv.clone()));
file_rpc::register_server(Box::new(serv));
loop {
ipc::process_messages();
while let Some(msg) = syslog_msg_ipc::try_get_syslog_msg() {
if msg.from == "blockdev" {
if let Some(binary) = msg.binary {
if binary.kind != 0 {
continue;
}
let dev_name = std::str::from_utf8(binary.data.as_slice()).unwrap();
let disk = File::open(format!("/dev/{}", dev_name)).unwrap();
let mbr_entries = parse_mbr(&disk);
if mbr_entries[0].typ == 0xEE {
let Ok((disk_guid, gpt_entries)) = parse_gpt(&disk) else {
syslog_client
.send_text_message(
"partserv",
format!("/dev/{dev_name}: GPT table has invalid magic!"),
)
.unwrap();
continue;
};
syslog_client
.send_text_message(
"partserv",
format!("/dev/{dev_name}: GPT table, UUID {disk_guid:X}"),
)
.unwrap();
let drive_file = vfs_client
.open(Path::new(&format!("/dev/{}", dev_name)))
.unwrap();
for (i, part) in gpt_entries.iter().enumerate() {
let part_dev_name = format!("{dev_name}p{i}");
syslog_client
.send_text_message(
"partserv",
format!(
"/dev/{part_dev_name}: UUID {:X}, start {}, size {}, type {:X}, name {:?}",
part.entry_guid,
humansize::format_size(part.start * 512, humansize::BINARY),
humansize::format_size(part.len * 512, humansize::BINARY),
part.type_guid,
part.name,
),
)
.unwrap();
parts.insert(
part_dev_name.clone(),
(drive_file, part.start * 512, (part.len * 512) as usize),
);
devfs_rpc::Client::new(devfs_pid)
.register_dev(&part_dev_name)
.unwrap();
}
} else {
println!("Disk has MBR");
let drive_file = vfs_client
.open(Path::new(&format!("/dev/{}", dev_name)))
.unwrap();
for (i, part) in mbr_entries.iter().enumerate() {
if part.size == 0 {
continue;
}
let act_str = if part.active { ", active" } else { "" };
syslog_client
.send_text_message(
"partserv",
format!(
"/dev/{dev_name}p{i}: start {}, size {}, type {:#x}{act_str}",
humansize::format_size(part.start * 512, humansize::BINARY),
humansize::format_size(part.size * 512, humansize::BINARY),
part.typ,
),
)
.unwrap();
let part_dev_name = format!("{dev_name}p{i}");
parts.insert(
part_dev_name.clone(),
(
drive_file,
(part.start * 512) as u64,
(part.size * 512) as usize,
),
);
devfs_rpc::Client::new(devfs_pid)
.register_dev(&part_dev_name)
.unwrap();
}
}
}
}
}
}
}