should be called after volumes' initiaization */
| 3276 | |
| 3277 | /* should be called after volumes' initiaization */ |
| 3278 | BOOL |
| 3279 | Ext2LoadDiskPartitions(PEXT2_DISK Disk) |
| 3280 | { |
| 3281 | UCHAR i = 0, cnt = 0; |
| 3282 | ULONG j = 0; |
| 3283 | |
| 3284 | BOOL bDynamic = FALSE; |
| 3285 | |
| 3286 | if (Disk->NumParts == 0) { |
| 3287 | Disk->NumParts = 1; |
| 3288 | } |
| 3289 | |
| 3290 | Disk->DataParts = (PEXT2_PARTITION) malloc( |
| 3291 | sizeof(EXT2_PARTITION) * Disk->NumParts); |
| 3292 | if (!Disk->DataParts) { |
| 3293 | return FALSE; |
| 3294 | } |
| 3295 | |
| 3296 | memset(Disk->DataParts, 0, sizeof(EXT2_PARTITION) * Disk->NumParts); |
| 3297 | |
| 3298 | if (Disk->Layout) { |
| 3299 | if (Disk->Layout->PartitionStyle == PARTITION_STYLE_MBR && |
| 3300 | Disk->Layout->PartitionEntry->Mbr.PartitionType == PARTITION_LDM) { |
| 3301 | bDynamic = TRUE; |
| 3302 | } |
| 3303 | |
| 3304 | |
| 3305 | /* Now walk through driveLayout and pack partitions */ |
| 3306 | for (i = 0; (Disk->Layout != NULL) && |
| 3307 | (i < (UCHAR)Disk->Layout->PartitionCount); i++) { |
| 3308 | |
| 3309 | PPARTITION_INFORMATION_EXT Part; |
| 3310 | Part = &Disk->Layout->PartitionEntry[i]; |
| 3311 | |
| 3312 | if (Disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { |
| 3313 | if (Part->Mbr.PartitionType == PARTITION_ENTRY_UNUSED || |
| 3314 | Part->Mbr.PartitionType == PARTITION_EXTENDED || |
| 3315 | Part->Mbr.PartitionType == PARTITION_XINT13_EXTENDED) { |
| 3316 | continue; |
| 3317 | } |
| 3318 | } |
| 3319 | |
| 3320 | sprintf(&Disk->DataParts[cnt].Name[0], |
| 3321 | "\\Device\\Harddisk%u\\Partition%u", |
| 3322 | Disk->OrderNo, cnt + 1); |
| 3323 | Disk->DataParts[cnt].Magic = EXT2_PART_MAGIC; |
| 3324 | Disk->DataParts[cnt].PartType = Disk->Layout->PartitionStyle; |
| 3325 | |
| 3326 | Disk->DataParts[cnt].Disk = Disk; |
| 3327 | Disk->DataParts[cnt].Number = cnt + 1; |
| 3328 | Disk->DataParts[cnt++].Entry = Part; |
| 3329 | } |
| 3330 | |
| 3331 | /* Search the volumes of the partition */ |
| 3332 | for (i=0; i < cnt; i++) { |
| 3333 | |
| 3334 | PEXT2_VOLUME volume = gVols; |
| 3335 | for (j=0; (ULONG)j < g_nVols; j++) { |
no test coverage detected