Move embedding to appropriate partmap files
PATCH 1/1 Move embedding to appropriate partmap files
Hello. A bug was filed that embedding code in grub-setup.c was ignoring partmap metadata which could cause its overwriting. To avoid usage of metadata and because of upcoming sunpc embedding support I propose to move embedding to partmap/*.c. For this I devised an interface which enables future reusage of embedding for other too if necessary.
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
include/grub/partition.h +13 -0
@@ -25,6 +25,13 @@ struct grub_disk;typedef struct grub_partition *grub_partition_t ; +#ifdef GRUB_UTIL +typedef enum +{ +GRUB_EMBED_PCBIOS +}grub_embed_type_t ; +#endif +/* Partition map type. */ struct grub_partition_map {
@@ -43,6 +50,12 @@ struct grub_partition_map/* Return the name of the partition PARTITION. */ char *(*get_name) (const grub_partition_t partition); +#ifdef GRUB_UTIL +/* Determine sectors available for embedding. */ +grub_err_t (*embed) (struct grub_disk *disk,unsigned int nsectors, +grub_embed_type_t embed_type,grub_disk_addr_t *sectors); +#endif +/* The next partition map type. */ struct grub_partition_map *next; };
partmap/gpt.c +70 -2
102 lines not on this page · raw message
partmap/pc.c +106 -2
126 lines not on this page · raw message
util/i386/pc/grub-setup.c +62 -114
251 lines not on this page · raw message
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Hello. A bug was filed that embedding code in
grub-setup.cwas ignoring partmap metadata which could cause its overwriting. To avoid usage of metadata and because of upcoming sunpc embedding support I propose to move embedding to partmap/*.c. For this I devised an interface which enables future reusage of embedding for other too if necessary.
Can this go in util/i386/pc/ instead? This is basicaly ad-hoc code and doesn't seem very meaningful in generic partmap/*.c.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
2009/8/12 Robert Millan <[email protected]>:
Quoted 11 lines · Vladimir 'phcoder' Serbinenko
Quoted 6 lines
Hello. A bug was filed that embedding code in
grub-setup.cwas ignoring partmap metadata which could cause its overwriting. To avoid usage of metadata and because of upcoming sunpc embedding support I propose to move embedding to partmap/*.c. For this I devised an interface which enables future reusage of embedding for other too if necessary.Can this go in util/i386/pc/ instead? This is basicaly ad-hoc code and doesn't seem very meaningful in generic partmap/*.c.
I wonder, it here any firmware that supports multiple partition formats?
On i386 the only requirement would be that the first sector contains a loader signature but some BIOSes may be overly smart and perform some checks on the partition table. Firmware on other platforms (like OpenFrimware or EFI) might be more picky and require a valid partition table it understands.
Thanks Michal
Quoted 2 lines · Michal Suchanek
I wonder, it here any firmware that supports multiple partition formats?
GRUB does (GRUB+coreboot is a firmware). Anyhow, we were talking about BIOS, which is partmap-agnostic.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 10 lines · Robert Millan
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Hello. A bug was filed that embedding code in
grub-setup.cwas ignoring partmap metadata which could cause its overwriting. To avoid usage of metadata and because of upcoming sunpc embedding support I propose to move embedding to partmap/*.c. For this I devised an interface which enables future reusage of embedding for other too if necessary.Can this go in util/i386/pc/ instead? This is basicaly ad-hoc code and doesn't seem very meaningful in generic partmap/*.c.
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding. This way no code outside partmap/ and parttool/ has to know partition format. It's beneficial for future maintainance as if someone updates partition map definitions he may forget that util/i386/pc/.. has another ad-hoc implementation especially if he doesn't use BIOS himself
Quoted 14 lines
--
Robert MillanThe DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 9 lines · Vladimir 'phcoder' Serbinenko
Quoted 8 lines · Robert Millan
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Hello. A bug was filed that embedding code in
grub-setup.cwas ignoring partmap metadata which could cause its overwriting. To avoid usage of metadata and because of upcoming sunpc embedding support I propose to move embedding to partmap/*.c. For this I devised an interface which enables future reusage of embedding for other too if necessary.
Quoted 5 lines
Quoted 2 lines
Can this go in util/i386/pc/ instead? This is basicaly ad-hoc code and doesn't seem very meaningful in generic partmap/*.c.
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding.
Is embedding useful elsewhere?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Hi,
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Can this go in util/i386/pc/ instead? This is basicaly ad-hoc code and doesn't seem very meaningful in generic partmap/*.c.
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding.
Is embedding useful elsewhere?
Yes! Solaris currently embeds the legacy GRUB stage2 loader in a
non-filesystem slice within the Solaris partition (and we put stage1 in the PBR, which allows us to play nicely with Linux distributions who like to jam their boot loaders in the MBR).
--S
Quoted 5 lines
Quoted 3 lines
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding.
Is embedding useful elsewhere?
Yes. Consider a world of checksummed filesystems. In such world you can't change the contents of the file by just writing to its blocklist since it will break the checksum. Similar problems exist with RAIDs and LVMs. On some systems we can't put grub-env in a file. For these cases we can embed grub-env somewhere where we can write it with ease
Quoted 14 lines
--
Robert MillanThe DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines
Quoted 3 lines
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding.
Is embedding useful elsewhere?
Yes. Consider a world of checksummed filesystems. In such world you can't change the contents of the file by just writing to its blocklist since it will break the checksum. Similar problems exist with RAIDs and LVMs. On some systems we can't put grub-env in a file. For these cases we can embed grub-env somewhere where we can write it with ease
Ok. Feel free to use partmap/ then. But please make sure #ifdefs only enable those functions where they are going to be used. That'd be GRUB_MACHINE_PCBIOS for now, if later code in other ports relies on them, this can be changed.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 15 lines · Robert Millan
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
Quoted 4 lines
Quoted 4 lines
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding.
Quoted 8 lines
Quoted 2 lines
Is embedding useful elsewhere?
Yes. Consider a world of checksummed filesystems. In such world you can't change the contents of the file by just writing to its blocklist since it will break the checksum. Similar problems exist with RAIDs and LVMs. On some systems we can't put grub-env in a file. For these cases we can embed grub-env somewhere where we can write it with ease
Quoted 6 lines
Ok. Feel free to use partmap/ then. But please make sure #ifdefs only enable those functions where they are going to be used. That'd be
GRUB_MACHINE_PCBIOSfor now, if later code in other ports relies on them, this can be changed.
This patch fixes an important bug - namely overwriting extended partition tables
Signature · 3 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 16 lines · Vladimir 'phcoder' Serbinenko
Quoted 15 lines · Robert Millan
Quoted 12 lines · Vladimir 'phcoder' Serbinenko
Quoted 6 lines
Quoted 4 lines
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding.
Is embedding useful elsewhere?
Yes. Consider a world of checksummed filesystems. In such world you can't change the contents of the file by just writing to its blocklist since it will break the checksum. Similar problems exist with RAIDs and LVMs. On some systems we can't put grub-env in a file. For these cases we can embed grub-env somewhere where we can write it with ease
Quoted 8 lines
Quoted 6 lines
Ok. Feel free to use partmap/ then. But please make sure #ifdefs only enable those functions where they are going to be used. That'd be
GRUB_MACHINE_PCBIOSfor now, if later code in other ports relies on them, this can be changed.This patch fixes an important bug - namely overwriting extended partition tables
Is there a simpler way to resolve this? I don't object to the restructuring you propose, but it seems too intrusive to do this just a few hours before we release 1.97.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 29 lines · Robert Millan
Quoted 27 lines · Vladimir 'phcoder' Serbinenko
Quoted 25 lines · Robert Millan
Quoted 5 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines
Quoted 5 lines
We may want to embed more in the future. Actually I think it's not ad-hoc. Basically partition map defines a function which gives back the sectors available for embedding.
Quoted 10 lines
Quoted 3 lines
Is embedding useful elsewhere?
Yes. Consider a world of checksummed filesystems. In such world you can't change the contents of the file by just writing to its blocklist since it will break the checksum. Similar problems exist with RAIDs and LVMs. On some systems we can't put grub-env in a file. For these cases we can embed grub-env somewhere where we can write it with ease
Ok. Feel free to use partmap/ then. But please make sure #ifdefs only enable those functions where they are going to be used. That'd be
GRUB_MACHINE_PCBIOSfor now, if later code in other ports relies on them, this can be changed.
Quoted 9 lines
Quoted 3 lines
This patch fixes an important bug - namely overwriting extended partition tables
Is there a simpler way to resolve this? I don't object to the restructuring you propose, but it seems too intrusive to do this just a few hours before we release 1.97.
Yes. It's my concern too. Solving this requires metadata info form partition map which is normally hidden and new code may have undiscovered bugs. On the other hand already present code has a bug but which is unlikely to be triggered.
As a simple alternative one could keep current check + enumerte entries in MBR - this should be enough.
Signature · 3 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git