From 5ad4c54f47a7eee85149f4c16395cbce9993d157 Mon Sep 17 00:00:00 2001 From: pjht Date: Sun, 17 Nov 2024 21:59:24 -0600 Subject: [PATCH] Switch to using std::fs::File to open disk files --- Cargo.toml | 2 -- src/main.rs | 17 ++++------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e449f18..d3e580b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,6 @@ 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 diff --git a/src/main.rs b/src/main.rs index a91209e..e4faba8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::{ fs::File, io::{Read, Seek, SeekFrom}, - os::mikros::{ipc, syscalls, Errno, FileCreationMode, FileOpenMode, FileWriteMode}, + os::mikros::{fs::FileExt, ipc, syscalls, Errno, FileOpenMode}, path::Path, sync::{atomic::{AtomicU64, Ordering}, Arc}, }; @@ -224,12 +224,7 @@ fn main() { 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]); @@ -279,9 +274,7 @@ fn main() { ) .unwrap(); - let drive_file = vfs_client - .open(Path::new(&format!("/dev/{}", dev_name)), FileOpenMode::ReadWrite(FileWriteMode::Start, FileCreationMode::NoCreate)) - .unwrap(); + let drive_file = std::fs::File::open(Path::new(&format!("/dev/{}", dev_name))).unwrap().get_pid_fd(); for (i, part) in gpt_entries.iter().enumerate() { let part_dev_name = format!("{dev_name}p{i}"); @@ -312,9 +305,7 @@ fn main() { } else { println!("Disk has MBR"); - let drive_file = vfs_client - .open(Path::new(&format!("/dev/{}", dev_name)), FileOpenMode::ReadWrite(FileWriteMode::Start, FileCreationMode::NoCreate)) - .unwrap(); + let drive_file = std::fs::File::open(Path::new(&format!("/dev/{}", dev_name))).unwrap().get_pid_fd(); for (i, part) in mbr_entries.iter().enumerate() { if part.size == 0 {