From 58548abbc3c738c27bba25e45aeaaa2fdba1a992 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 01:48:38 +0100 Subject: [PATCH] Remove data member in partition structure --- include/grub/partition.h | 3 --- kern/disk.c | 1 - partmap/acorn.c | 1 - partmap/amiga.c | 2 -- partmap/apple.c | 11 +++++------ partmap/gpt.c | 9 +-------- partmap/msdos.c | 1 - util/i386/pc/grub-setup.c | 10 +++++++--- 8 files changed, 13 insertions(+), 25 deletions(-) diff --git a/include/grub/partition.h b/include/grub/partition.h index bd97144c9..9feb9459d 100644 --- a/include/grub/partition.h +++ b/include/grub/partition.h @@ -60,9 +60,6 @@ struct grub_partition /* The index of this partition in the partition table. */ int index; - /* Partition map type specific data. */ - void *data; - /* Parent partition map. */ struct grub_partition *parent; diff --git a/kern/disk.c b/kern/disk.c index 514f28c15..ccd5f200f 100644 --- a/kern/disk.c +++ b/kern/disk.c @@ -342,7 +342,6 @@ grub_disk_close (grub_disk_t disk) while (disk->partition) { part = disk->partition->parent; - grub_free (disk->partition->data); grub_free (disk->partition); disk->partition = part; } diff --git a/partmap/acorn.c b/partmap/acorn.c index 0c3abf11d..f3b36106e 100644 --- a/partmap/acorn.c +++ b/partmap/acorn.c @@ -106,7 +106,6 @@ acorn_partition_map_iterate (grub_disk_t disk, return err; part.partmap = &grub_acorn_partition_map; - part.data = 0; for (i = 0; i != LINUX_MAP_ENTRIES; ++i) { diff --git a/partmap/amiga.c b/partmap/amiga.c index 5b6a4598f..b5fba0dbc 100644 --- a/partmap/amiga.c +++ b/partmap/amiga.c @@ -99,8 +99,6 @@ amiga_partition_map_iterate (grub_disk_t disk, return grub_error (GRUB_ERR_BAD_PART_TABLE, "Amiga partition map not found"); - part.data = 0; - /* The end of the partition list is marked using "-1". */ while (next != -1) { diff --git a/partmap/apple.c b/partmap/apple.c index 35bdcc8d7..b9d3e9174 100644 --- a/partmap/apple.c +++ b/partmap/apple.c @@ -122,17 +122,16 @@ apple_partition_map_iterate (grub_disk_t disk, goto fail; } - part.data = 0; pos = grub_be_to_cpu16 (aheader.blocksize); do { - part.offset = pos / GRUB_DISK_SECTOR_SIZE; - part.index = pos % GRUB_DISK_SECTOR_SIZE; + part.offset = pos / GRUB_DISK_SECTOR_SIZE; + part.index = pos % GRUB_DISK_SECTOR_SIZE; - if (grub_disk_read (disk, part.offset, part.index, - sizeof (struct grub_apple_part), &apart)) - return grub_errno; + if (grub_disk_read (disk, part.offset, part.index, + sizeof (struct grub_apple_part), &apart)) + return grub_errno; if (grub_be_to_cpu16 (apart.magic) != GRUB_APPLE_PART_MAGIC) { diff --git a/partmap/gpt.c b/partmap/gpt.c index 2c942e164..8b799d4d5 100644 --- a/partmap/gpt.c +++ b/partmap/gpt.c @@ -71,15 +71,11 @@ gpt_partition_map_iterate (grub_disk_t disk, grub_dprintf ("gpt", "Read a valid GPT header\n"); entries = grub_le_to_cpu64 (gpt.partitions); - part.data = grub_malloc (sizeof (entry)); for (i = 0; i < grub_le_to_cpu32 (gpt.maxpart); i++) { if (grub_disk_read (disk, entries, last_offset, sizeof (entry), &entry)) - { - grub_free (part.data); - return grub_errno; - } + return grub_errno; if (grub_memcmp (&grub_gpt_partition_type_empty, &entry.type, sizeof (grub_gpt_partition_type_empty))) @@ -92,7 +88,6 @@ gpt_partition_map_iterate (grub_disk_t disk, part.number = i; part.index = last_offset; part.partmap = &grub_gpt_partition_map; - grub_memcpy (part.data, &entry, sizeof (entry)); grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", i, (unsigned long long) part.start, @@ -110,8 +105,6 @@ gpt_partition_map_iterate (grub_disk_t disk, } } - grub_free (part.data); - return GRUB_ERR_NONE; } diff --git a/partmap/msdos.c b/partmap/msdos.c index accf3fdba..bafd86eb6 100644 --- a/partmap/msdos.c +++ b/partmap/msdos.c @@ -40,7 +40,6 @@ pc_partition_map_iterate (grub_disk_t disk, p.offset = 0; ext_offset = 0; - p.data = 0; p.number = -1; p.partmap = &grub_msdos_partition_map; diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index 27c9cd434..af0217d10 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -130,17 +130,21 @@ setup (const char *dir, int NESTED_FUNC_ATTR find_usable_region_gpt (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t p) { - struct grub_gpt_partentry *gptdata = p->data; + struct grub_gpt_partentry gptdata; + + disk->partition = p->parent; + if (grub_disk_read (disk, p->offset, p->index, + sizeof (gptdata), &gptdata)) + return 0; /* If there's an embed region, it is in a dedicated partition. */ - if (! memcmp (&gptdata->type, &grub_gpt_partition_type_bios_boot, 16)) + if (! memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16)) { embed_region.start = p->start; embed_region.end = p->start + p->len; return 1; } - return 0; }