Skip to content

[kernel] Automatic re-read partition table after MBR modified#2367

Merged
ghaerr merged 4 commits intomasterfrom
initpartition
Jul 22, 2025
Merged

[kernel] Automatic re-read partition table after MBR modified#2367
ghaerr merged 4 commits intomasterfrom
initpartition

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Jul 22, 2025

Fixes the fdisk reboot and sys problems described in #2364 (comment).

Now, after running fdisk the system automatically rereads the partition table when using either the BIOSHD or ATA CF drivers. No reboot necessary.

The partition table will be re-read the next time any process opens the device with the modified MBR. The revised partition table will at that point be (re)displayed on the console in the same format as the partition table boot screen display. For example, running fdisk again after writing the MBR will provoke this behavior, or accessing the newly created partition using mkfs or mkfat.

Also fixes a major problem writing garbage data when using the ATA CF driver (to either hard disk or CF). This was bad code added approximately a week ago when I added XMS support. This is now fixed, and is likely the cause of @toncho11's second problem described in the link above where sys after fdisk/reboot didn't work: the MBR was being written incorrectly, as well as any other data written to a CF card or hard disk by the ATA CF driver.

The partition reading code was moved out of INITPROC into far text to allow for re-reading the partition table; this added 2K to the kernel resident memory usage. The ATA CF driver was also added to the far text segment to make room in the normal text segment.

Also added was an automatic sync after fdisk writes the MBR; it was previously possible that the MBR would not actually have been synced to disk if the system were rebooted immediately after fdisk without syncing. Neither sync nor reboot are necessary anymore.

@ghaerr ghaerr merged commit 88e4c13 into master Jul 22, 2025
2 checks passed
@ghaerr ghaerr deleted the initpartition branch July 22, 2025 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant