I'll preface this with a bit so y'all know that while I'm a bit of a n00b in the OS department, I've been programming for a while - mainly on emulators. Been coding in C for almost 25 years now - and been learning x86 ASM recently. I've made a few attempts at rewriting DOS that went down in smoke, but I've got a few pieces of those projects. And then IBM and Microsoft dropped PC DOS/MS-DOS 4.0 on us recently
I was looking at some of the pieces we've got that aren't likely to need too much updating, and decided FDISK could use a nicer interface, but couldn't really get too deep into the weeds because the code's partially algolized (anyone who's seen the original code to the Bourne Shell will know what I mean). I almost think it'll be easier to just gut the thing and start fresh.
And this is where I'm deep in the weeds. I know a bit of the basics, and keep RBIL open most times (remember, 8088 target here in C/ASM) so at the high level I'm fine. It's when I get down to stuff like enumerating hard drives and handling MBR that I'm lost, and not really finding the info I need (if I just need to RTFW - read the f'n wiki - it's possible I just haven't found the right page yet!)
(For what it's worth, I'll be using the same license that the existing code has, and I _can_ avail myself of the existing code, inasfar as it's part of 4.0 and therefore legitimate.)
(First timer here) FDISK: Getting into the nitty-gritty
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: (First timer here) FDISK: Getting into the nitty-gritty
I don't know how (or if!) DOS enumerates hard drives, so I can't help you very much there, but Wikipedia has a surprisingly thorough description of MBR partition tables.
Re: (First timer here) FDISK: Getting into the nitty-gritty
According to the source code of FreeDOS I've just read, KERNEL.SYS will enumerate all hard disks the BIOS knows using function 8 of interrupt 0x13 to get the number of hard disks, then read the partition table off of each of them, then assign drive letters by the Windows 2000 algorithm (which essentially means all partitions found in this way get the next available letter starting from C. Floppy drives are assigned after, starting from A, and then CD-ROM drives are assigned starting from D). All of this happens in ReadAllPartitionTables() in initdisk.c, which is executed during boot.
So that seems to be the answer to OP's question: Function 8 of interrupt 0x13.
So that seems to be the answer to OP's question: Function 8 of interrupt 0x13.
Carpe diem!
Re: (First timer here) FDISK: Getting into the nitty-gritty
Most likely, PC DOS uses the same algorithm...nullplan wrote:According to the source code of FreeDOS I've just read, KERNEL.SYS will enumerate all hard disks the BIOS knows using function 8 of interrupt 0x13 to get the number of hard disks, then read the partition table off of each of them, then assign drive letters by the Windows 2000 algorithm (which essentially means all partitions found in this way get the next available letter starting from C. Floppy drives are assigned after, starting from A, and then CD-ROM drives are assigned starting from D). All of this happens in ReadAllPartitionTables() in initdisk.c, which is executed during boot.
So that seems to be the answer to OP's question: Function 8 of interrupt 0x13.