continue working on implementing lib9660 into the kernel

This commit is contained in:
2025-08-16 19:41:48 +03:00
parent 287ac77422
commit ce6e9642ee
10 changed files with 151 additions and 53 deletions
+17 -28
View File
@@ -15,6 +15,7 @@
#include "../include/exec_from_file.h"
#include "../include/atapi.h"
#include "../include/lib9660.h"
#include "../include/vfs.h"
#include <stdint.h>
@@ -25,34 +26,14 @@ void apply_pic_masks()
outb(0xa1,0xff);
}
static l9660_fs g_iso_fs;
static l9660_dir g_root_dir;
static l9660_file g_test_file;
bool read_sector_callback(l9660_fs *fs, void *buf, uint32_t sector) {
// The 'fs' parameter is not needed for our simple case, so we can ignore it.
(void)fs;
// Call your existing CD-ROM read function to read 1 sector.
// We assume the CD-ROM is the secondary master (0x170).
int result = read_cdrom(0x170, false, sector, 1, (uint16_t*)buf);
// lib9660 expects 'true' for success and 'false' for failure.
// Your read_cdrom returns 0 for success.
return (result == 0);
}
void test_iso9660()
{
l9660_status status = l9660_openfs(&g_iso_fs, read_sector_callback);
if (status != L9660_OK) {
printf("Error opening ISO9660 filesystem!\n");
return;
}
l9660_dir g_root_dir;
l9660_file g_test_file;
l9660_status status;
// 2. Open the root directory
status = l9660_fs_open_root(&g_root_dir, &g_iso_fs);
status = l9660_fs_open_root(&g_root_dir, &global_fs);
if (status != L9660_OK) {
printf("Error opening root directory!\n");
return;
@@ -77,10 +58,16 @@ void test_iso9660()
printf("\nReading content of /TEST.TXT:\n");
// Re-open the root directory to reset its position before searching
l9660_fs_open_root(&g_root_dir, &g_iso_fs);
l9660_fs_open_root(&g_root_dir, &global_fs);
// Note: ISO9660 filenames are often uppercase.
status = l9660_openat(&g_test_file, &g_root_dir, "test.txt;1");
l9660_dir boot_dir;
l9660_dir grub_dir;
status = l9660_opendirat(&boot_dir, &g_root_dir, "boot");
printf("STATUS %X\n", status);
status = l9660_opendirat(&grub_dir, &boot_dir, "grub");
printf("STATUS %X\n", status);
status = l9660_openat(&g_test_file, &grub_dir, "grub.cfg");
if (status != L9660_OK) {
printf("Error opening TEST.TXT;1. Error code: ");
@@ -197,9 +184,11 @@ void kmain(unsigned int magic, unsigned int info)
printf("huy1 points to: 0x%X huy2 points to:0x%X\n", huy, huy2);
printf("huy1: %s\nhuy2: %s", huy, huy2);
mount_fs();
test_iso9660();
//exec_from_file("/ebalo/main", "/ebalo/");
exec_from_file("main.", ".");
while(1)
{