Add empty vfs program and fix tar parsing

This commit is contained in:
pjht 2019-05-24 11:52:13 -05:00
parent ebdc36fade
commit 30e043955b
10 changed files with 32 additions and 5 deletions

View File

@ -20,17 +20,21 @@ debug: os.iso kernel.elf
@$(EMU) -s $(QFLAGS) &
@$(GDB) -ex "target remote localhost:1234" -ex "symbol-file kernel/kernel.elf"
os.iso: kernel.elf initrd/* initrd/init
os.iso: kernel.elf initrd/* initrd/init initrd/vfs
@cp kernel/kernel.elf iso/boot
@cd initrd; tar -f ../iso/boot/initrd.tar -c *
@grub-mkrescue -o $@ iso > /dev/null 2>/dev/null
.PHONY: kernel.elf initrd/init
.PHONY: kernel.elf initrd/init initrd/vfs
initrd/init:
$(MAKE) -C init
cp init/init initrd/init
initrd/vfs:
$(MAKE) -C vfs
cp vfs/vfs initrd/vfs
kernel.elf:
@$(MAKE) -C kernel
@$(MAKE) -C libc

BIN
init/init

Binary file not shown.

View File

@ -1,4 +1,4 @@
#include "../libc/string.h"
#include <string.h>
#include "vga.h"
#include <grub/text_fb_info.h>
@ -40,10 +40,13 @@ int main(char* initrd, uint32_t initrd_sz) {
if (hdr.filename[0]=='\0') break;
uint32_t size=getsize(hdr.size);
pos+=512;
if (strcmp(hdr.filename,"init")==0) {
vga_write_string("Init found");
if (strcmp(hdr.filename,"vfs")==0) {
vga_write_string("VFS found");
}
pos+=size;
if (pos%512!=0) {
pos+=512-(pos%512);
}
}
for (;;);
}

Binary file not shown.

BIN
initrd/vfs Executable file

Binary file not shown.

Binary file not shown.

View File

@ -71,6 +71,9 @@ void kmain(struct multiboot_boot_header_tag* hdr) {
break;
}
pos+=size;
if (pos%512!=0) {
pos+=512-(pos%512);
}
}
elf_header header;
pos=datapos;

14
vfs/Makefile Normal file
View File

@ -0,0 +1,14 @@
C_SOURCES = $(wildcard *.c)
OBJ = $(C_SOURCES:.c=.o ../kernel/start.o)
CFLAGS = -I../sysroot/usr/include -Wall -g -ffreestanding
CC = i386-elf-gcc
vfs: $(OBJ)
@i386-elf-ld -o $@ $^ ../libc/libc.a
@rm -rf *.o
%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@
clean:
@rm -rf *.o prog.elf

3
vfs/main.c Normal file
View File

@ -0,0 +1,3 @@
int main() {
for (;;);
}

BIN
vfs/vfs Executable file

Binary file not shown.