-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
789 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,72 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use Mstd::println; | ||
use Mstd::process::{exec, fork, wait}; | ||
extern crate alloc; | ||
|
||
use Mstd::process::{exec, exit, fork, waitpid}; | ||
use Mstd::system_shutdown; | ||
use Mstd::thread::m_yield; | ||
|
||
#[no_mangle] | ||
fn main() -> isize { | ||
if fork() == 0 { | ||
exec("/bin/shell\0", &[0 as *const u8], &[0 as *const u8]); | ||
} else { | ||
loop { | ||
// if fork() == 0 { | ||
// exec("/bin/shell\0", &[0 as *const u8], &[0 as *const u8]); | ||
// } else { | ||
// loop { | ||
// let mut exit_code: i32 = 0; | ||
// let tid = wait(&mut exit_code); | ||
// if tid == -1 { | ||
// m_yield(); | ||
// continue; | ||
// } | ||
// println!( | ||
// "[Init] Released a task, tid={}, exit_code={}", | ||
// tid, exit_code, | ||
// ); | ||
// } | ||
// } | ||
// 0 | ||
run_test(); | ||
system_shutdown(); | ||
} | ||
|
||
const ENV: &[*const u8] = &[ | ||
"SHELL=/bash\0".as_ptr(), | ||
"LOGNAME=root\0".as_ptr(), | ||
"HOME=/root\0".as_ptr(), | ||
"USER=root\0".as_ptr(), | ||
"SHLVL=0\0".as_ptr(), | ||
"OLDPWD=/root\0".as_ptr(), | ||
"PS1=\x1b[1m\x1b[32mAlien\x1b[0m:\x1b[1m\x1b[34m\\w\x1b[0m\\$ \0".as_ptr(), | ||
"_=/bin/bash\0".as_ptr(), | ||
"PATH=/:/bin\0".as_ptr(), | ||
"LD_LIBRARY_PATH=/\0".as_ptr(), | ||
core::ptr::null(), | ||
]; | ||
|
||
fn run_test() { | ||
let commands = [ | ||
"./time-test\0", | ||
"./run-static.sh\0", | ||
"./run-dynamic.sh\0", | ||
"./libc-bench2\0", | ||
"./lua_testcode.sh\0", | ||
"./busybox_testcode.sh\0", | ||
"./cyclictest_testcode.sh\0", | ||
"./unixbench_testcode.sh\0", | ||
"./lmbench_testcode.sh\0", | ||
"./iozone_testcode.sh\0", | ||
]; | ||
commands.into_iter().for_each(|app| { | ||
let args = [app.as_ptr()]; | ||
let pid = fork(); | ||
if pid == 0 { | ||
exec(app, &args, ENV); | ||
exit(0); | ||
} else { | ||
m_yield(); | ||
let mut exit_code: i32 = 0; | ||
let tid = wait(&mut exit_code); | ||
if tid == -1 { | ||
m_yield(); | ||
continue; | ||
} | ||
println!( | ||
"[Init] Released a task, tid={}, exit_code={}", | ||
tid, exit_code, | ||
); | ||
let _x = waitpid(pid as usize, &mut exit_code); | ||
} | ||
} | ||
0 | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Fat32 | ||
|
||
内核需要支持`fat32`文件系统,我们实现了自己的`fat32`,但是并没有使用,而是改造了社区中已有的项目。并将其接入到我们实现的`rvfs`框架中。 | ||
|
||
## Bugs | ||
|
||
无法直接删除文件,并回收空间 | ||
|
||
现象:在进行联合测试时,运行到`unixbench`以及`lmbench`时会触发写磁盘错误,通过单独测试,发现时此时已经没有磁盘空间。但是当单独测试其中的测例时又可以正常运行。 | ||
|
||
推测1:内核没有调用删除文件的函数? | ||
|
||
结果:通过打印debug信息,发现fat32-vfs中有处理删除文件的操作 | ||
|
||
推测2:fat32-vfs是否实现正确? | ||
|
||
结果:按照fat32-vfs的方式,我们在fat32原项目进行了删除文件测试,发现删除文件后磁盘空间没有减少,检查了github上是否有相关问题,没有查找到。 | ||
|
||
在阅读fat32的源代码时,发现有个`umount`函数,可以将磁盘元数据写回,回收空间,于是进行了尝试,发现空间并没有收回。 | ||
|
||
继续尝试,通过看源代码,在删除文件时没有看到回收占用空间的代码,于是查看其他函数,看哪个可以回收空间,在看到`truncate`时看到了相关的代码,于是我们在删除文件前将将文件的大小截断为0,并在删除后使用`umount`函数刷新元数据,再一次测试,在原项目通过后,我们又在fat32-vfs中修改了`unlink`的实现,按照这个步骤正确地删除文件,回收空间。 | ||
|
||
|
||
|
||
## 链接 | ||
|
||
[fat32-vfs](https://github.com/Godones/fat32-vfs.git) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.