Move some common code into a "push_ddt" function.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@857 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-04-10 09:37:45 +00:00
parent cfed8c6f29
commit 78995ad7cc
1 changed files with 15 additions and 12 deletions

View File

@ -556,11 +556,21 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
pddt->ddt_fstype[8] = '\0'; pddt->ddt_fstype[8] = '\0';
} }
STATIC void push_ddt(ddt *pddt)
{
ddt FAR *fddt = DynAlloc("ddt", 1, sizeof(ddt));
fmemcpy(fddt, pddt, sizeof(ddt));
if (pddt->ddt_logdriveno != 0) {
(fddt - 1)->ddt_next = fddt;
if (pddt->ddt_driveno == 0 && pddt->ddt_logdriveno == 1)
(fddt - 1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG;
}
}
void DosDefinePartition(struct DriveParamS *driveParam, void DosDefinePartition(struct DriveParamS *driveParam,
ULONG StartSector, struct PartTableEntry *pEntry, ULONG StartSector, struct PartTableEntry *pEntry,
int extendedPartNo, int PrimaryNum) int extendedPartNo, int PrimaryNum)
{ {
ddt FAR *fddt;
ddt nddt; ddt nddt;
ddt *pddt = &nddt; ddt *pddt = &nddt;
struct CHS chs; struct CHS chs;
@ -610,9 +620,7 @@ void DosDefinePartition(struct DriveParamS *driveParam,
pddt->ddt_type = 5; pddt->ddt_type = 5;
memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb));
fddt = DynAlloc("ddt", 1, sizeof(ddt)); push_ddt(pddt);
fmemcpy(fddt, pddt, sizeof(ddt));
(fddt-1)->ddt_next = fddt;
/* Alain whishes to keep this in later versions, too /* Alain whishes to keep this in later versions, too
Tom likes this too, so he made it configurable by SYS CONFIG ... Tom likes this too, so he made it configurable by SYS CONFIG ...
@ -1253,7 +1261,6 @@ void ReadAllPartitionTables(void)
int HardDrive; int HardDrive;
int nHardDisk = BIOS_nrdrives(); int nHardDisk = BIOS_nrdrives();
int Unit; int Unit;
ddt FAR *fddt;
ddt nddt; ddt nddt;
ddt *pddt = &nddt; ddt *pddt = &nddt;
static iregs regs; static iregs regs;
@ -1281,10 +1288,8 @@ void ReadAllPartitionTables(void)
pddt->ddt_serialno = 0x12345678l; pddt->ddt_serialno = 0x12345678l;
memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb));
fddt = DynAlloc("ddt", 1, sizeof(ddt)); if (Unit == 0)
if (Unit == 0) { push_ddt(pddt);
fmemcpy(fddt, pddt, sizeof(ddt));
}
} }
/* Initial number of disk units */ /* Initial number of disk units */
@ -1306,12 +1311,10 @@ void ReadAllPartitionTables(void)
} }
else else
{ /* set up the DJ method : multiple logical drives */ { /* set up the DJ method : multiple logical drives */
(fddt - 1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG;
pddt->ddt_descflags |= DF_MULTLOG; pddt->ddt_descflags |= DF_MULTLOG;
} }
(fddt-1)->ddt_next = fddt;
fmemcpy(fddt, pddt, sizeof(ddt));
push_ddt(pddt);
nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1); nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1);
memset(foundPartitions, 0, sizeof(foundPartitions)); memset(foundPartitions, 0, sizeof(foundPartitions));