Arceos-monolithic / Starry

An experimental modular OS written in Rust.
http://rcore-os.cn/arceos/
Apache License 2.0
12 stars 15 forks source link

busybox的ls(存在显示bug,不能显示出全部文件) #11

Open apengaaa opened 7 months ago

apengaaa commented 7 months ago
       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 # ls(存在显示bug,不能显示全部文件)
arithoh                 fstime                  multi.sh
bin                     hackbench               netperf
busybox                 hanoi                   netperf_testcode.sh
busybox_cmd.txt         hello                   netserver
busybox_testcode.sh     int                     pipe
context1                interrupts-test-1       random.lua
copy-file-range-test-1  interrupts-test-2       register
copy-file-range-test-2  iozone                  remove.lua
copy-file-range-test-3  iozone_testcode.sh      round_num.lua
copy-file-range-test-4  iperf3                  run-dynamic.sh
cyclictest              iperf_testcode.sh       run-static.sh
cyclictest_testcode.sh  libc-bench              runtest.exe
date.lua                libc.so                 short
dhry2                   libctest_testcode.sh    sin30.lua
dhry2reg                lmbench_all             sort.lua
dlopen_dso.so           lmbench_testcode.sh     spawn
double                  long                    strings.lua
entry-dynamic.exe       looper                  syscall
entry-static.exe        lua                     test.sh
execl                   lua_testcode.sh         test.txt
file_io.lua             main
float                   max_min.lua
/E #

宏内核的busybox终端ls命令无法显示出全部文件

apengaaa commented 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"
scPointer commented 7 months ago

关于 ls 的问题

这个问题被修复过,只是之前训练营被用来出题了( https://scpointer.github.io/rcore2oscomp/docs/lab3/ls.html ),所以暂时没实装到内核代码中。本周我会加进来。

scPointer commented 7 months ago

关于命令列表

单纯输入 help 只是一小部分内建命令,并不是全部。直接输入 busybox 并回车,可以看到实际支持的命令多得多。

目前测试的命令不是所有命令,只是个别常用命令,并且这些命令的输出不一定都正确。

Starry 没有完成全部所需功能。换句话说,测试的有些命令输出不正确是符合预期的,但我们仍然需要这一测试来方便后续的工作。

执行 busybox 命令的方式

应该加 busybox 前缀再执行。可以看到虽然内容还不对(内核没完整支持相关 syscall),但框架是对的

/ # ./busybox ps
PID   USER     TIME  COMMAND
/ # ./busybox date
Thu Jan  1 00:01:26 UTC 1970

简单介绍一下这类程序执行的原理: 实际上 ls ps 这些命令都是执行 busybox 这个程序时的参数,所以应该指定运行当前目录下的可执行文件 busybox ,并且再附参数。还有一些你可能想问的:

    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()),
    );
......

目前仍然存在的问题

上面的运行方式没放到 README 里,需要加几行说明一下。至于真正支持 busybox 的所有命令,短时间内还做不到

对测试的需求

如果能区分 busybox 没有命令和内核没有实现的情况更好。例如: