Skip to content

Commit 6b1bc4c

Browse files
committed
WIP
1 parent f77ed8f commit 6b1bc4c

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

uefi-test-runner/src/fs/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,16 @@ pub fn test(sfs: ScopedProtocol<SimpleFileSystem>) {
3939
.collect::<Vec<_>>();
4040
assert_eq!(&[".", "..", "foo", "barfoo"], entries.as_slice());
4141

42-
fs.create_dir_all("/test_file_system_abs/1/2/3/4/5/6/7").unwrap();
43-
fs.try_exists("/test_file_system_abs/1/2/3/4/5/6/7").unwrap();
44-
fs.remove_dir_all("/test_file_system_abs/1/2/3/4/5/6/7").unwrap();
45-
let x = fs.try_exists("/test_file_system_abs/1/2/3/4/5/6/7");
42+
/*fs.create_dir("/deeply_nested_test").unwrap();
43+
fs.create_dir("/deeply_nested_test/1").unwrap();
44+
fs.create_dir("/deeply_nested_test/1/2").unwrap();
45+
fs.create_dir("/deeply_nested_test/1/2/3").unwrap();
46+
fs.create_dir("/deeply_nested_test/1/2/3/4").unwrap();*/
47+
fs.create_dir_all("/deeply_nested_test/1/2/3/4/5/6/7").unwrap();
48+
fs.try_exists("/deeply_nested_test/1/2/3/4/5/6/7").unwrap();
49+
//fs.remove_dir_all("/deeply_nested_test/1/2/3/4/5/6/7").unwrap();
50+
fs.remove_dir("/deeply_nested_test/1/2/3/4/5/6/7").unwrap();
51+
let x = fs.try_exists("/deeply_nested_test/1/2/3/4/5/6/7");
4652
assert!(x.is_err());
4753
}
4854

uefi/src/fs/file_system.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ use derive_more::Display;
1414
use uefi::proto::media::file::{FileAttribute, FileInfo, FileType};
1515
use uefi::table::boot::ScopedProtocol;
1616
use alloc::format;
17+
use log::info;
18+
use uefi::fs::path::Component;
19+
use crate::fs::path::Components;
1720

1821
/// All errors that can happen when working with the [`FileSystem`].
1922
#[derive(Debug, Clone, Display, PartialEq, Eq)]
@@ -108,11 +111,17 @@ impl<'boot_services> FileSystem<'boot_services> {
108111
let iter = || normalized_path_pathref.components(NormalizedPath::SEPARATOR);
109112
iter()
110113
.scan(String::new(), |path_acc, component| {
111-
*path_acc += "/";
112-
*path_acc += format!("{component}").as_str();
114+
if component != Component::RootDir {
115+
*path_acc += "/";
116+
*path_acc += format!("{component}").as_str();
117+
}
118+
info!("path_acc: {path_acc}, component: {component}");
113119
Some((component, path_acc.clone()))
114120
})
115-
.try_for_each(|(_component, full_path)| self.create_dir(full_path.as_str()))
121+
.try_for_each(|(_component, full_path)| {
122+
log::info!("fuck this shit! '{full_path}'");
123+
self.create_dir(full_path.as_str())
124+
})
116125
}
117126

118127
/// Given a path, query the file system to get information about a file,
@@ -193,25 +202,8 @@ impl<'boot_services> FileSystem<'boot_services> {
193202

194203
/// Removes a directory at this path, after removing all its contents. Use
195204
/// carefully!
196-
pub fn remove_dir_all(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()> {
197-
let path = path.as_ref();
198-
let normalized_path = NormalizedPath::new("\\", path)?;
199-
let normalized_path_string = normalized_path.to_string();
200-
let normalized_path_pathref = Path::new(&normalized_path_string);
201-
let iter = || normalized_path_pathref.components(NormalizedPath::SEPARATOR);
202-
203-
let paths = iter()
204-
.scan(String::new(), |path_acc, component| {
205-
*path_acc += "/";
206-
*path_acc += format!("{component}").as_str();
207-
Some((component, path_acc.clone()))
208-
})
209-
.collect::<Vec<_>>();
210-
211-
paths
212-
.iter()
213-
.rev()
214-
.try_for_each(|(_component, full_path)| self.remove_dir(full_path.as_str()))
205+
pub fn remove_dir_all(&mut self, _path: impl AsRef<Path>) -> FileSystemResult<()> {
206+
todo!()
215207
}
216208

217209
/// Removes a file from the filesystem.

uefi/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ pub mod allocator;
115115
pub mod logger;
116116

117117
/// See [`fs`].
118+
// Heavy usage of allocations in fs module
119+
#[cfg(feature = "alloc")]
118120
pub mod fs;
119121

120122
// As long as this is behind "alloc", we can simplify cfg-feature attributes in this module.

xtask/src/qemu.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{net, platform};
88
use anyhow::{anyhow, bail, Context, Result};
99
use regex::bytes::Regex;
1010
use serde_json::{json, Value};
11-
use std::env;
11+
use std::{env, fs};
1212
use std::ffi::OsString;
1313
use std::io::{BufRead, BufReader, Read, Write};
1414
use std::path::{Path, PathBuf};
@@ -630,6 +630,12 @@ pub fn run_qemu(arch: UefiArch, opt: &QemuOpt) -> Result<()> {
630630
echo_service.stop();
631631
}
632632

633+
eprintln!("HELLO");
634+
eprintln!("HELLO");
635+
eprintln!("HELLO");
636+
eprintln!("HELLO");
637+
fs::copy(&test_disk, "/home/pschuster/Desktop/qemu.img").unwrap();
638+
633639
// Propagate earlier error if necessary.
634640
res?;
635641

0 commit comments

Comments
 (0)