Open apengaaa opened 7 months ago
还有目前busybox支持的命令与测例中测试的busybox命令还不完全统一
d8888 .d88888b. .d8888b.
d88888 d88P" "Y88b d88P Y88b
d88P888 888 888 Y88b.
d88P 888 888d888 .d8888b .d88b. 888 888 "Y888b.
d88P 888 888P" d88P" d8P Y8b 888 888 "Y88b.
d88P 888 888 888 88888888 888 888 "888
d8888888888 888 Y88b. Y8b. Y88b. .d88P Y88b d88P
d88P 888 888 "Y8888P "Y8888 "Y88888P" "Y8888P"
arch = riscv64
platform = riscv64-qemu-virt
target = riscv64gc-unknown-none-elf
smp = 1
build_mode = release
log_level = off
sh: can't access tty; job control turned off
/E # help
Built-in commands:
------------------
. : [ [[ alias bg break cd chdir command continue echo eval exec
exit export false fg getopts hash help history jobs kill let
local printf pwd read readonly return set shift source test times
trap true type ulimit umask unalias unset wait
/E # ps
sh: ps: not found
/E # clear
sh: clear: not found
/E # date
sh: date: not found
/E # dmesg
sh: dmesg: not found
以下是测例中测试的命令:
echo "#### independent command test"
ash -c exit
sh -c exit
basename /aaa/bbb
cal
clear
date
df
dirname /aaa/bbb
dmesg
du
expr 1 + 1
false
true
which ls
uname
uptime
printf "abc\n"
ps
pwd
free
hwclock
kill 10
ls
sleep 1
echo "#### file opration test"
touch test.txt
echo "hello world" > test.txt
cat test.txt
cut -c 3 test.txt
od test.txt
head test.txt
tail test.txt
hexdump -C test.txt
md5sum test.txt
echo "ccccccc" >> test.txt
echo "bbbbbbb" >> test.txt
echo "aaaaaaa" >> test.txt
echo "2222222" >> test.txt
echo "1111111" >> test.txt
echo "bbbbbbb" >> test.txt
sort test.txt | ./busybox uniq
stat test.txt
strings test.txt
wc test.txt
[ -f test.txt ]
more test.txt
rm test.txt
mkdir test_dir
mv test_dir test
rmdir test
grep hello busybox_cmd.txt
cp busybox_cmd.txt busybox_cmd.bak
rm busybox_cmd.bak
find -name "busybox_cmd.txt"
这个问题被修复过,只是之前训练营被用来出题了( https://scpointer.github.io/rcore2oscomp/docs/lab3/ls.html ),所以暂时没实装到内核代码中。本周我会加进来。
单纯输入 help
只是一小部分内建命令,并不是全部。直接输入 busybox
并回车,可以看到实际支持的命令多得多。
目前测试的命令不是所有命令,只是个别常用命令,并且这些命令的输出不一定都正确。
Starry 没有完成全部所需功能。换句话说,测试的有些命令输出不正确是符合预期的,但我们仍然需要这一测试来方便后续的工作。
应该加 busybox
前缀再执行。可以看到虽然内容还不对(内核没完整支持相关 syscall),但框架是对的
/ # ./busybox ps
PID USER TIME COMMAND
/ # ./busybox date
Thu Jan 1 00:01:26 UTC 1970
简单介绍一下这类程序执行的原理:
实际上 ls
ps
这些命令都是执行 busybox
这个程序时的参数,所以应该指定运行当前目录下的可执行文件 busybox ,并且再附参数。还有一些你可能想问的:
/usr/bin
下真的有这些命令对应的可执行文件,而 busybox 是一个工具集,所以所有命令其实都是运行它本身。ls
等几个简单命令可以直接运行?因为我们在 ulib/axstarry/syscall_entry/src/test.rs
里手动创建了符号链接 create_link(
&(FilePath::new("/sbin/busybox").unwrap()),
&(FilePath::new("busybox").unwrap()),
);
create_link(
&(FilePath::new("/sbin/ls").unwrap()),
&(FilePath::new("busybox").unwrap()),
);
create_link(
&(FilePath::new("/ls").unwrap()),
&(FilePath::new("/busybox").unwrap()),
);
create_link(
&(FilePath::new("/sh").unwrap()),
&(FilePath::new("/busybox").unwrap()),
);
......
.sh
脚本时由 busybox sh
子命令解析的,它自己会去尝试用 busybox 解析上面的运行方式没放到 README 里,需要加几行说明一下。至于真正支持 busybox 的所有命令,短时间内还做不到
如果能区分 busybox 没有命令和内核没有实现的情况更好。例如:
sh: ps: not found
是用户程序 busybox 没找到命令(当然,如上所述这个命令是有的,只是运行方式不对
)PID USER TIME COMMAND
是内核没有完整实现 procfs
的功能导致的。因为 busybox 确实尝试拉了一个表格去找所有进程,只是没找到。
宏内核的busybox终端ls命令无法显示出全部文件