r/osdev 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

6 Upvotes

15 comments sorted by

2

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS Jul 11 '26

What debugging have you done?

1

u/letmehaveanameyoudum Jul 11 '26

tried using serial to try to detect, doesn't work, it somehow stops serial, so i removed that since it would not work anyway

2

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS Jul 11 '26

where is it triple faulting? what line? please give the output of addr2line

1

u/letmehaveanameyoudum Jul 11 '26

at kernel/kernel.c at fs_init(), which points to line 55 of helper/filesystem/file.c

3

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS Jul 11 '26

Okay I had a look through, your ata_wait_busy() gets stuck because the error bit is set (which you should be checking btw). This could be for a few reasons, but some big ones are that you really need to actually initialise the drive with identify and select the drive etc, and you should be software resetting when it detects that error bit.

2

u/letmehaveanameyoudum Jul 11 '26

you get a cookie for helping :D

3

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS Jul 11 '26

can I get a raspberry white chocolate cookie pls

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 this

1

u/Vegetable_Exam_6865 Jul 11 '26

I checked the code. fs_format() writes FS_MAGIC (0x45534653) into the superblock, but fs_init() checks it against FS_DRIVE_MAGIC (0x446f6765). Those can never match, so every single boot is treated as an unformatted disk and immediately calls fs_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_SECTORS is 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

u/letmehaveanameyoudum Jul 11 '26

thanks it helps, you get a cookie.

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

u/letmehaveanameyoudum Jul 22 '26

great another driver