Format the codebase

This commit is contained in:
Xavier L'Heureux
2020-01-20 15:00:26 -05:00
parent a6af6a9289
commit 58f2d28ff5
17 changed files with 804 additions and 463 deletions
+25 -26
View File
@@ -1,14 +1,14 @@
use std::{fs, sync, thread, time};
use std::ops::DerefMut;
use std::path::Path;
use std::process::Command;
use std::{fs, sync, thread, time};
use crate::{DiskSparse, FileSystem};
fn with_redoxfs<T, F>(callback: F)
-> T where
T: Send + Sync + 'static,
F: FnMut(&Path) -> T + Send + Sync + 'static
fn with_redoxfs<T, F>(callback: F) -> T
where
T: Send + Sync + 'static,
F: FnMut(&Path) -> T + Send + Sync + 'static,
{
let disk_path = "image.bin";
let mount_path = "image";
@@ -17,13 +17,14 @@ fn with_redoxfs<T, F>(callback: F)
let disk = DiskSparse::create(dbg!(disk_path)).unwrap();
if cfg!(not(target_os = "redox")) {
if ! Path::new(mount_path).exists() {
if !Path::new(mount_path).exists() {
dbg!(fs::create_dir(dbg!(mount_path))).unwrap();
}
}
let ctime = dbg!(time::SystemTime::now().duration_since(time::UNIX_EPOCH)).unwrap();
let fs = FileSystem::create_reserved(disk, &[], ctime.as_secs(), ctime.subsec_nanos()).unwrap();
let fs =
FileSystem::create_reserved(disk, &[], ctime.as_secs(), ctime.subsec_nanos()).unwrap();
let callback_mutex = sync::Arc::new(sync::Mutex::new(callback));
let join_handle = crate::mount(fs, dbg!(mount_path), move |real_path| {
@@ -45,20 +46,19 @@ fn with_redoxfs<T, F>(callback: F)
.arg(mount_path)
.status()
} else {
Command::new("umount")
.arg(mount_path)
.status()
Command::new("umount").arg(mount_path).status()
};
let status = dbg!(status_res).unwrap();
if ! status.success() {
if !status.success() {
panic!("umount failed");
}
}
res
})
}).unwrap();
})
.unwrap();
join_handle.join().unwrap()
};
@@ -92,23 +92,24 @@ fn mmap() {
let path = dbg!(path.join("test"));
let mmap_inner = |write: bool| {
let fd = dbg!(
syscall::open(
path.as_os_str().as_bytes(),
syscall::O_CREAT | syscall::O_RDWR | syscall::O_CLOEXEC
)
).unwrap();
let fd = dbg!(syscall::open(
path.as_os_str().as_bytes(),
syscall::O_CREAT | syscall::O_RDWR | syscall::O_CLOEXEC
))
.unwrap();
let map = unsafe {
slice::from_raw_parts_mut(
dbg!(
syscall::fmap(fd, &syscall::Map {
dbg!(syscall::fmap(
fd,
&syscall::Map {
offset: 0,
size: 128,
flags: syscall::PROT_READ | syscall::PROT_WRITE
})
).unwrap() as *mut u8,
128
}
))
.unwrap() as *mut u8,
128,
)
};
@@ -124,9 +125,7 @@ fn mmap() {
//TODO: add msync
unsafe {
assert_eq!(dbg!(
syscall::funmap(map.as_mut_ptr() as usize)
), Ok(0));
assert_eq!(dbg!(syscall::funmap(map.as_mut_ptr() as usize)), Ok(0));
}
};