orange's chapter6/a make buildimg报:display mount: /dev/loop0: can't read superblock

root@ubuntu:/home/hgfs/OS_Self/chapter6/a# make buildimg
dd if=boot/boot.bin of=a.img bs=512 count=1 conv=notrunc
1+0 records in
1+0 records out
512 bytes copied, 0.000227916 s, 2.2 MB/s
sudo mount -o loop a.img /mnt/floppy/
mount: /dev/loop0: can't read superblock
Makefile:55: recipe for target 'buildimg' failed

make: *** [buildimg] Error 32

这个问题找到一个解决办法,注释掉Makefile这行,在前面加个#:

#dd if=boot/boot.bin of=a.img bs=512 count=1 conv=notrunc

然后我在kernel/main.c中把

void TestA()
{
        int i = 0;
        while(1){
                disp_str("A");
                disp_int(i++);
                disp_str(" ");  <---- disp_str(".");(原来是.被我修改为空格)用于测试是否生效
                delay(1);
        }

}

然后重新编译.o,生成a.img,起动bochs:

root@ubuntu:/home/hgfs/OS_Self/chapter6/a# vim kernel/main.c    "." --->" "
root@ubuntu:/home/hgfs/OS_Self/chapter6/a# make    生成.o

nasm -I boot/include/ -o boot/boot.bin boot/boot.asm
nasm -I boot/include/ -o boot/loader.bin boot/loader.asm
nasm -I include/ -f elf -o kernel/kernel.o kernel/kernel.asm
gcc -m32 -I include/ -c -fno-builtin -fno-stack-protector -o kernel/start.o kernel/start.c
gcc -m32 -I include/ -c -fno-builtin -fno-stack-protector -o kernel/main.o kernel/main.c
kernel/main.c: In function ‘TestA’:
kernel/main.c:56:3: warning: implicit declaration of function ‘disp_int’ [-Wimplicit-function-declaration]
   disp_int(i++);
   ^
gcc -m32 -I include/ -c -fno-builtin -fno-stack-protector -o kernel/i8259.o kernel/i8259.c
kernel/i8259.c: In function ‘spurious_irq’:
kernel/i8259.c:39:2: warning: implicit declaration of function ‘disp_int’ [-Wimplicit-function-declaration]
  disp_int(irq);
  ^
gcc -m32 -I include/ -c -fno-builtin -fno-stack-protector -o kernel/global.o kernel/global.c
gcc -m32 -I include/ -c -fno-builtin -fno-stack-protector -o kernel/protect.o kernel/protect.c
kernel/protect.c: In function ‘init_prot’:
kernel/protect.c:63:2: warning: implicit declaration of function ‘init_8259A’ [-Wimplicit-function-declaration]
  init_8259A();
  ^
kernel/protect.c:100:2: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration]
  memset(&tss, 0, sizeof(tss));
  ^
kernel/protect.c: In function ‘exception_handler’:
kernel/protect.c:201:2: warning: implicit declaration of function ‘disp_int’ [-Wimplicit-function-declaration]
  disp_int(eflags);
  ^
nasm -I include/ -f elf -o lib/kliba.o lib/kliba.asm
gcc -m32 -I include/ -c -fno-builtin -fno-stack-protector -o lib/klib.o lib/klib.c
nasm -I include/ -f elf -o lib/string.o lib/string.asm
ld -s -m elf_i386 -Ttext 0x30400 -o kernel.bin kernel/kernel.o kernel/start.o kernel/main.o kernel/i8259.o kernel/global.o kernel/protect.o lib/kliba.o lib/klib.o lib/string.o
root@ubuntu:/home/hgfs/OS_Self/chapter6/a# make buildimg 生成a.img
sudo mount -o loop a.img /mnt/floppy/
sudo cp -fv boot/loader.bin /mnt/floppy/
'boot/loader.bin' -> '/mnt/floppy/loader.bin'
sudo cp -fv kernel.bin /mnt/floppy
'kernel.bin' -> '/mnt/floppy/kernel.bin'
sudo umount /mnt/floppy
root@ubuntu:/home/hgfs/OS_Self/chapter6/a# bochs -f a.txt 起动bochs
========================================================================
                        Bochs x86 Emulator 2.6
            Built from SVN snapshot on September 2nd, 2012
========================================================================
00000000000i[     ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/lib/bochs/plugins'
00000000000i[     ] BXSHARE not set. using compile time default '/usr/share/bochs'
00000000000i[     ] lt_dlhandle is 0x3a503f0
00000000000i[PLGIN] loaded plugin libbx_unmapped.so
00000000000i[     ] lt_dlhandle is 0x3a51050
00000000000i[PLGIN] loaded plugin libbx_biosdev.so
00000000000i[     ] lt_dlhandle is 0x3a519d0
00000000000i[PLGIN] loaded plugin libbx_speaker.so
00000000000i[     ] lt_dlhandle is 0x3a51d80
00000000000i[PLGIN] loaded plugin libbx_extfpuirq.so
00000000000i[     ] lt_dlhandle is 0x3a538e0
00000000000i[PLGIN] loaded plugin libbx_parallel.so
00000000000i[     ] lt_dlhandle is 0x3a55590
00000000000i[PLGIN] loaded plugin libbx_serial.so
00000000000i[     ] lt_dlhandle is 0x3a59170
00000000000i[PLGIN] loaded plugin libbx_gameport.so
00000000000i[     ] lt_dlhandle is 0x3a59c10
00000000000i[PLGIN] loaded plugin libbx_iodebug.so
00000000000i[     ] reading configuration from a.txt
00000000000e[     ] a.txt:27: 'keyboard_mapping' will be replaced by new 'keyboard' option.
00000000000i[     ] lt_dlhandle is 0x3a5a4b0
00000000000i[PLGIN] loaded plugin libbx_sdl.so
00000000000i[     ] installing sdl module as the Bochs GUI
00000000000i[     ] using log file bochsout.txt
Next at t=0
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
<bochs:1> c  +回车
^CNext at t=173977124
(0) [0x0000000000030f96] 0005:0000000000030f96 (unk. ctxt): add dword ptr ss:[ebp-8], 0x00000001 ; 8345f801

<bochs:2>

显示结果由原来的.变成空格了:


注:我的测试环境是ubuntu16.04


由于白天在上班昨天发现的这个问题,今天才解决


猜你喜欢

转载自blog.csdn.net/r77683962/article/details/79634154
今日推荐