original version by Matt Domsch <Matt_Domsch@dell.com>
Disclaimed into the Public Domain
- Portions Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
+ Portions Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc.
EFI GUID Partition Table handling
Per Intel EFI Specification v1.02
return ok;
}
-#ifndef DISCOVER_ONLY
-/* writes zeros to the PMBR and the primary GPTH, and to the final sector */
-static int
-gpt_clobber (PedDevice *dev)
-{
- PED_ASSERT (dev != NULL, return 0);
-
- return (ptt_clear_sectors (dev, GPT_PMBR_LBA, GPT_PMBR_SECTORS)
- && ptt_clear_sectors (dev, GPT_PRIMARY_HEADER_LBA, GPT_HEADER_SECTORS)
- && ptt_clear_sectors (dev, dev->length - GPT_HEADER_SECTORS,
- GPT_HEADER_SECTORS));
-}
-#endif /* !DISCOVER_ONLY */
-
static PedDisk *
gpt_alloc (const PedDevice *dev)
{
GPTDiskData *gpt_disk_data = disk->disk_specific;
int i;
#ifndef DISCOVER_ONLY
- int write_back = 1;
+ int write_back = 0;
#endif
ped_disk_delete_all (disk);
if (primary_gpt && backup_gpt)
{
/* Both are valid. */
+#ifndef DISCOVER_ONLY
if (PED_LE64_TO_CPU (primary_gpt->AlternateLBA) < disk->dev->length - 1)
{
-#ifndef DISCOVER_ONLY
switch (ped_exception_throw
(PED_EXCEPTION_ERROR,
(PED_EXCEPTION_FIX | PED_EXCEPTION_CANCEL
case PED_EXCEPTION_FIX:
ptt_clear_sectors (disk->dev,
PED_LE64_TO_CPU (primary_gpt->AlternateLBA), 1);
+ write_back = 1;
break;
default:
- write_back = 0;
break;
}
-#endif /* !DISCOVER_ONLY */
}
+#endif /* !DISCOVER_ONLY */
gpt = primary_gpt;
pth_free (backup_gpt);
}
GuidPartitionEntry_t *pte
= (GuidPartitionEntry_t *) ((char *) ptes + i * p_ent_size);
PedPartition *part;
- PedConstraint *constraint_exact;
if (!guid_cmp (pte->PartitionTypeGuid, UNUSED_ENTRY_GUID))
continue;
part->fs_type = ped_file_system_probe (&part->geom);
part->num = i + 1;
- constraint_exact = ped_constraint_exact (&part->geom);
+ PedConstraint *constraint_exact = ped_constraint_exact (&part->geom);
if (!ped_disk_add_partition (disk, part, constraint_exact))
{
+ ped_constraint_destroy (constraint_exact);
ped_partition_destroy (part);
goto error_delete_all;
}
static PedDiskOps gpt_disk_ops =
{
- clobber: NULL_IF_DISCOVER_ONLY (gpt_clobber),
+ clobber: NULL,
write: NULL_IF_DISCOVER_ONLY (gpt_write),
partition_set_name: gpt_partition_set_name,