Switch to using std::fs::File to open disk files
This commit is contained in:
parent
3190f78d0b
commit
5ad4c54f47
@ -14,8 +14,6 @@ sharded-slab = "0.1.7"
|
|||||||
syslog_msg_ipc = { version = "0.1.0", path = "../syslog/syslog_msg_ipc" }
|
syslog_msg_ipc = { version = "0.1.0", path = "../syslog/syslog_msg_ipc" }
|
||||||
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
||||||
uuid = "1.10.0"
|
uuid = "1.10.0"
|
||||||
vfs_rpc = { version = "0.1.0", path = "../vfs/vfs_rpc" }
|
|
||||||
|
|
||||||
|
|
||||||
# [profile.release]
|
# [profile.release]
|
||||||
# strip = true
|
# strip = true
|
||||||
|
17
src/main.rs
17
src/main.rs
@ -1,7 +1,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{Read, Seek, SeekFrom},
|
io::{Read, Seek, SeekFrom},
|
||||||
os::mikros::{ipc, syscalls, Errno, FileCreationMode, FileOpenMode, FileWriteMode},
|
os::mikros::{fs::FileExt, ipc, syscalls, Errno, FileOpenMode},
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{atomic::{AtomicU64, Ordering}, Arc},
|
sync::{atomic::{AtomicU64, Ordering}, Arc},
|
||||||
};
|
};
|
||||||
@ -224,12 +224,7 @@ fn main() {
|
|||||||
break pid;
|
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);
|
let syslog_client = syslog_rpc::Client::new(syslog_pid);
|
||||||
|
|
||||||
syslog_client.subscribe_to_binary("blockdev".to_string(), vec![0]);
|
syslog_client.subscribe_to_binary("blockdev".to_string(), vec![0]);
|
||||||
@ -279,9 +274,7 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let drive_file = vfs_client
|
let drive_file = std::fs::File::open(Path::new(&format!("/dev/{}", dev_name))).unwrap().get_pid_fd();
|
||||||
.open(Path::new(&format!("/dev/{}", dev_name)), FileOpenMode::ReadWrite(FileWriteMode::Start, FileCreationMode::NoCreate))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
for (i, part) in gpt_entries.iter().enumerate() {
|
for (i, part) in gpt_entries.iter().enumerate() {
|
||||||
let part_dev_name = format!("{dev_name}p{i}");
|
let part_dev_name = format!("{dev_name}p{i}");
|
||||||
@ -312,9 +305,7 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
println!("Disk has MBR");
|
println!("Disk has MBR");
|
||||||
|
|
||||||
let drive_file = vfs_client
|
let drive_file = std::fs::File::open(Path::new(&format!("/dev/{}", dev_name))).unwrap().get_pid_fd();
|
||||||
.open(Path::new(&format!("/dev/{}", dev_name)), FileOpenMode::ReadWrite(FileWriteMode::Start, FileCreationMode::NoCreate))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
for (i, part) in mbr_entries.iter().enumerate() {
|
for (i, part) in mbr_entries.iter().enumerate() {
|
||||||
if part.size == 0 {
|
if part.size == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user