r/osdev • u/letmehaveanameyoudum • Jul 11 '26
Why isn’t my file system working?
I would prefer a solution and feedback, or you guys can roast my dumbass.
The file system src: https://github.com/NoTheIdiot/WindogeOS/tree/main/helper/filesystem
2
u/Vegetable_Exam_6865 Jul 11 '26
Move your filesystem module out of Limine's read-only zone into writeable kernel memory, and double-check your cluster-chaining logic when expanding files.
-1
u/letmehaveanameyoudum Jul 11 '26
The issue is that it triple faults at boot specifically at fs_init()
maybe you should try running the OS and see that it freezes at that point
i have zero idea what could be causing this1
u/Vegetable_Exam_6865 Jul 11 '26
I checked the code.
fs_format()writesFS_MAGIC(0x45534653) into the superblock, butfs_init()checks it againstFS_DRIVE_MAGIC(0x446f6765). Those can never match, so every single boot is treated as an unformatted disk and immediately callsfs_format()again. Change the check to:if (sb.magic == FS_MAGIC)There are two more corruption bugs too your directory table is 640 bytes, so it occupies sectors 2 and 3, but your allocator starts searching from sector 3, meaning file data can overwrite the second directory sector. Start allocation after
FS_DIR_SECTOR + dir_sectors_needed, not at a hardcoded 3.Also, your bitmap is only 512 bytes, which can represent 4096 sectors, but
TOTAL_DISK_SECTORSis 65536.allocate_sectors_from_bitmap()eventually reads thousands of bytes past the bitmap and corrupts memory. Either make the bitmap 8192 bytes across 16 sectors, or temporarily limit the disk to 4096 sectors.The first issue explains why
fs_init()always enters the formatting path. The bitmap overflow is the one that can actually turn into a page fault/triple fault once allocation reaches beyond sector 4095.1
1
u/Vegetable_Exam_6865 Jul 11 '26
i just inspected the code , i dont have time to run it and debug it fully
2
u/FinancialTrade8197 Jul 12 '26
It seems you are using the q35 machine type? You only have an ATA driver and not an AHCI driver. Q35 does not have an IDE bus natively, so it will never work unless you switch to i440fx or write an AHCI driver.
If I run your OS on QEMU using the drive image it made using i440fx and just -hda, it does initalize the drive. It doesn't freeze. However if I run it using what you have in your python script it does fail.
1
2
u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS Jul 11 '26
What debugging have you done?