grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

partition map reorganization


From: Hollis Blanchard
Subject: partition map reorganization
Date: Mon, 1 Nov 2004 21:49:03 -0600

I'm working on supporting more than one partition map per architecture. Currently, x86 builds use disk/i386/pc/partition.c, and PPC builds use disk/powerpc/ieee1275/partition.c. Both provide identically-named functions for architecture-neutral code (e.g. grub_partition_iterate). Additionally, Apple partition code deals with things it shouldn't (e.g. dos_type), so we can see that some abstraction is needed here.

In order to support both partition types (and potentially more, should the need arise) in the same binary, I'm introducing a "partition_ops" structure to struct grub_disk, which contains a couple function pointers that are set as appropriate at grub_disk_open time. There is one ops structure per partition map type (i.e. DOS and Apple right now).

struct grub_partition_ops {
        grub_err_t (*iterate) (struct grub_disk *disk,
                                        int (*hook) (const grub_partition_t 
partition));
        grub_partition_t (*probe) (struct grub_disk *disk, const char *str);
        char * (*get_name) (const grub_partition_t p);
};

Impact to existing code can be minimized with wrappers like this:

static inline char *
grub_partition_get_name (const grub_partition_t p)
{
        return p->disk->ops->get_name (p);
}

Everything is going ok, but as the first step I'd like to make sure this idea is acceptable. Neutral code only uses a couple fields of struct grub_partition, so I would like to break the current struct grub_partition in two: a generic partition (i.e. what describes a disk partition in general) and a DOS-specific partition:

struct grub_partition {
        unsigned long start;
        unsigned long len;
        unsigned int index;
        struct grub_disk_t disk;
};

struct grub_dos_part {
        struct grub_partition generic;
        unsigned long offset;
        unsigned long ext_offset;
        int dos_part;
        int bsd_part;
        int dos_type;
        int bsd_type;
}

The generic grub_partition needs to be embedded in grub_dos_part so that neutral code can use a grub_partition pointer and then the map-specific code (e.g. grub_partition_get_name) can convert back to the grub_dos_part pointer.

It's not all ready for submission yet, but the struct division could go in first, to try to commit smaller incremental patches rather than one massive one. Is this ok?

-Hollis





reply via email to

[Prev in Thread] Current Thread [Next in Thread]