=== modified file 'include/grub/partition.h' --- include/grub/partition.h 2010-07-14 09:26:17 +0000 +++ include/grub/partition.h 2010-07-29 01:03:11 +0000 @@ -72,6 +72,7 @@ int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk, int (*hook) (struct grub_disk *disk, const grub_partition_t partition)); +int EXPORT_FUNC(grub_partition_detect) (struct grub_disk *disk); char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition); === modified file 'kern/disk.c' --- kern/disk.c 2010-02-07 00:48:38 +0000 +++ kern/disk.c 2010-07-29 01:13:07 +0000 @@ -298,6 +298,10 @@ goto fail; } } + else if (disk->has_partitions) + { + disk->has_partitions = grub_partition_detect(disk); + } /* The cache will be invalidated about 2 seconds after a device was closed. */ === modified file 'kern/partition.c' --- kern/partition.c 2010-07-16 23:55:01 +0000 +++ kern/partition.c 2010-07-29 01:07:42 +0000 @@ -219,6 +219,35 @@ return ret; } +int +grub_partition_detect (struct grub_disk *disk) +{ + const struct grub_partition_map *partmap; + int found = 0; + + auto int part_iterate (grub_disk_t dsk, const grub_partition_t p); + + int part_iterate (grub_disk_t dsk __attribute((unused)), + const grub_partition_t partition __attribute((unused))) + { + found = 1; + /* It's not really an error, just want to short-circut the interation */ + return grub_error(GRUB_ERR_TEST_FAILURE, "Partition found"); + } + + FOR_PARTITION_MAPS(partmap) + { + grub_err_t err; + err = partmap->iterate (disk, part_iterate); + if (err) + grub_errno = GRUB_ERR_NONE; + if (found) + break; + } + + return found; +} + char * grub_partition_get_name (const grub_partition_t partition) {