From d6b184319d07dd6a9f50bc7cd1ae711ba7a29f48 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 --- src/main.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index a91209e..101bfc8 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, FileCreationMode, FileOpenMode, FileWriteMode}, 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 {