Switch to using std::fs::File to open disk files

This commit is contained in:
pjht 2024-11-17 21:59:24 -06:00
parent 3190f78d0b
commit d6b184319d
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -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 {