Remove mount point prefix in virtual FS open
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
parent
5303ea4581
commit
7a443723e5
@ -92,7 +92,7 @@ impl IsoDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn matches(&self, path: &str) -> bool {
|
pub fn matches(&self, path: &str) -> bool {
|
||||||
self.get_idf() == path.as_bytes()
|
self.get_idf().to_ascii_uppercase() == path.as_bytes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
mod fd;
|
mod fd;
|
||||||
pub mod iso9660;
|
pub mod iso9660;
|
||||||
|
|
||||||
|
use crate::serial_println;
|
||||||
|
|
||||||
use crate::drivers::atapi::read_block;
|
use crate::drivers::atapi::read_block;
|
||||||
use crate::fd::FDt;
|
use crate::fd::FDt;
|
||||||
use crate::utils::unserialize;
|
use crate::utils::unserialize;
|
||||||
@ -37,18 +39,22 @@ impl FileSystem for IsoFS {
|
|||||||
let mut curr_entry: &IsoDir = unserialize(curr_entry_block.as_ptr());
|
let mut curr_entry: &IsoDir = unserialize(curr_entry_block.as_ptr());
|
||||||
|
|
||||||
let path_s: String = String::from(path);
|
let path_s: String = String::from(path);
|
||||||
let path_split: Vec<&str> = path_s.split("/").collect();
|
let path_split: Vec<String> = path_s
|
||||||
let path_it = path_s.split("/").filter(|p| p != &"");
|
.split("/")
|
||||||
|
.filter(|p| p != &"")
|
||||||
|
.map(|s| s.to_uppercase())
|
||||||
|
.collect();
|
||||||
|
let path_it = path_split.iter();
|
||||||
|
|
||||||
for path_component in path_it {
|
for path_component in path_it {
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
while curr_entry.idf_len != 0 {
|
while curr_entry.idf_len != 0 {
|
||||||
// Found entry
|
// Found entry
|
||||||
if curr_entry.matches(path_component) {
|
if curr_entry.matches(path_component.as_str()) {
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
// Not the last component, go 1 directory deeper
|
// Not the last component, go 1 directory deeper
|
||||||
if path_component != path_split[path_split.len() - 1] {
|
if path_component.as_str() != path_split[path_split.len() - 1] {
|
||||||
// Not a directory
|
// Not a directory
|
||||||
if curr_entry.file_type != iso9660::IsoFileType::ISDIR {
|
if curr_entry.file_type != iso9660::IsoFileType::ISDIR {
|
||||||
return None;
|
return None;
|
||||||
|
@ -55,6 +55,7 @@ impl VirtualFS {
|
|||||||
impl FileSystem for VirtualFS {
|
impl FileSystem for VirtualFS {
|
||||||
async fn open(&mut self, path: &str, flags: u32) -> Option<FDt> {
|
async fn open(&mut self, path: &str, flags: u32) -> Option<FDt> {
|
||||||
if let Some(map) = &self.map {
|
if let Some(map) = &self.map {
|
||||||
|
let mut mnt_relative_path: String = String::from("");
|
||||||
let path_s: String = String::from(path);
|
let path_s: String = String::from(path);
|
||||||
let mut path_split: Vec<String> = path_s
|
let mut path_split: Vec<String> = path_s
|
||||||
.split("/")
|
.split("/")
|
||||||
@ -64,10 +65,11 @@ impl FileSystem for VirtualFS {
|
|||||||
loop {
|
loop {
|
||||||
if let Some(fs) = map.find_exact(&path_split) {
|
if let Some(fs) = map.find_exact(&path_split) {
|
||||||
// TODO, remove path prefix of the mount point
|
// TODO, remove path prefix of the mount point
|
||||||
return fs.borrow_mut().open(path, flags).await;
|
return fs.borrow_mut().open(mnt_relative_path.as_str(), flags).await;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
path_split.truncate(path_split.len() - 1);
|
let component = path_split.remove(path_split.len() - 1);
|
||||||
|
mnt_relative_path = String::from("/") + component.as_str() + mnt_relative_path.as_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,7 +68,7 @@ async fn get_file() {
|
|||||||
let fd = fs::VIRTUAL_FS
|
let fd = fs::VIRTUAL_FS
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
.open("///boot/grub//grub.cfg", syscalls::io::O_RDONLY)
|
.open("/mnt/iso//boot/grub//grub.cfg", syscalls::io::O_RDONLY)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut buf: [u8; 100] = [0; 100];
|
let mut buf: [u8; 100] = [0; 100];
|
||||||
|
Loading…
Reference in New Issue
Block a user