diff options
author | Marvin Borner | 2020-04-25 19:45:47 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-25 19:45:47 +0200 |
commit | 4d46d6bb37c97050980ec5d0c29ee03e82cf9b63 (patch) | |
tree | 3c5105638c301b6f0d31abe4d8e73c79cff8054f | |
parent | 71a111f7e6b71e0894b90e8dc1221b1ec4f84ab3 (diff) |
Fixed ext2 reading by using genext2fs
As the debian versions use a horribly old version of genext2fs, this
program gets compiled in the build process now.
-rw-r--r-- | .github/workflows/build.yml | 2 | ||||
-rwxr-xr-x | run | 43 | ||||
-rw-r--r-- | src/kernel/fs/ext2.c | 4 | ||||
-rw-r--r-- | src/kernel/fs/ext2.h | 2 | ||||
-rw-r--r-- | src/kernel/fs/load.c | 2 | ||||
-rw-r--r-- | src/kernel/graphics/vesa.c | 2 | ||||
-rw-r--r-- | src/kernel/kernel.c | 4 |
7 files changed, 43 insertions, 16 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cfa6f20..602bce4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,6 @@ jobs: if: steps.cache-cross.outputs.cache-hit != 'true' run: sh run cross - name: Build - run: sh run build + run: sh run build -y - name: Test install run: sh run image @@ -5,6 +5,7 @@ set -e cd "$(dirname "$0")" mode="${1}" +no_ask="${2}" network="rtl8139" qemu_with_flags() { @@ -16,6 +17,33 @@ qemu_with_flags() { fi } +make_genext2fs() { + if [ "$(genext2fs -V | awk '{print $2}')" = "1.4.2" ]; then + echo "genext2fs is already the newest version" + else + if [ "$no_ask" != "-y" ]; then + printf "Melvix requires the newest genext2fs version, would you like to install it? [y/n] " + read -r answer + fi + if [ "$answer" != "${answer#[Yy]}" ] || [ "$no_ask" = "-y" ]; then + echo "Building genext2fs..." + git clone --quiet https://github.com/bestouff/genext2fs.git >/dev/null + cd genext2fs >/dev/null + git checkout --quiet 000e369 >/dev/null + mv README.md README >/dev/null + touch ChangeLog >/dev/null + sh autogen.sh >/dev/null + ./configure >/dev/null + sudo make install >/dev/null + cd .. >/dev/null + rm -rf genext2fs >/dev/null + echo "Success!" + else + echo "This probably won't compile..." + fi + fi +} + make_cross() { if [ ! -d "./cross/" ]; then # Create directory @@ -78,15 +106,14 @@ make_build() { grub-mkrescue -o ./build/melvix.iso ./iso/ # Create disk image - mke2fs -b 4096 -N 4096 ./build/disk.img 65536 + make_genext2fs mkdir ./mnt/ - sudo mount ./build/disk.img ./mnt/ - sudo mkdir -p ./mnt/etc/ - sudo mkdir -p ./mnt/usr/ - sudo mkdir -p ./mnt/bin/ - # echo "Hello world, ext2!" | sudo tee -a ./mnt/etc/test # ?! - sudo cp ./build/font.bin ./mnt/bin/font - sync && sudo umount mnt + mkdir -p ./mnt/etc/ + mkdir -p ./mnt/usr/ + mkdir -p ./mnt/bin/ + cp ./build/font.bin ./mnt/bin/font + echo "Hello world, ext2!" | tee -a ./mnt/etc/test + genext2fs -B 4096 -d mnt -U -N 4096 -b 65536 ./build/disk.img rm -r mnt/ printf "Build finshed successfully!\n\n" diff --git a/src/kernel/fs/ext2.c b/src/kernel/fs/ext2.c index 4e7a384..afab33d 100644 --- a/src/kernel/fs/ext2.c +++ b/src/kernel/fs/ext2.c @@ -241,7 +241,7 @@ uint8_t *read_file(char *path) ext2_open_inode(inode, &file); if (inode != 0) { size_t size = file.inode.size; - debug("%d", size); + debug("%dKiB", size >> 10); uint8_t *buf = kmalloc(size); ext2_read(&file, buf, size); kfree(file.buf); @@ -251,4 +251,4 @@ uint8_t *read_file(char *path) warn("File not found"); return NULL; } -} +}
\ No newline at end of file diff --git a/src/kernel/fs/ext2.h b/src/kernel/fs/ext2.h index 7fbe493..88515a3 100644 --- a/src/kernel/fs/ext2.h +++ b/src/kernel/fs/ext2.h @@ -139,4 +139,4 @@ uint32_t ext2_look_up_path(char *path); uint8_t *read_file(char *path); -#endif +#endif
\ No newline at end of file diff --git a/src/kernel/fs/load.c b/src/kernel/fs/load.c index 09e6dbc..59bb905 100644 --- a/src/kernel/fs/load.c +++ b/src/kernel/fs/load.c @@ -10,4 +10,4 @@ void load_binaries() font = (struct font *)read_file("/bin/font"); log("Successfully loaded binaries"); -} +}
\ No newline at end of file diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c index d7bc42a..e8ef0e0 100644 --- a/src/kernel/graphics/vesa.c +++ b/src/kernel/graphics/vesa.c @@ -368,4 +368,4 @@ void vesa_set_color(uint32_t color) { vesa_convert_color(terminal_color, color); vesa_convert_color(terminal_background, default_background_color); -} +}
\ No newline at end of file diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 881361f..c5137bd 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -58,7 +58,7 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address) ata_init(); ext2_init_fs(); - // log("%s", read_file("/etc/test")); // Multiple reads don't work?! + log("%s", read_file("/etc/test")); load_binaries(); set_optimal_resolution(); @@ -79,4 +79,4 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address) // panic("This should NOT happen!"); // asm ("div %0" :: "r"(0)); // Exception testing x/0 -} +}
\ No newline at end of file |