From: "Grégoire Sutre" <gregoire.sutre@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: [Patch] Do not embed with multiple partmaps
Date: Fri, 18 Jun 2010 01:07:53 +0200 [thread overview]
Message-ID: <4C1AAAC9.4060907@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
Hi,
As a (temporary) solution to the problem of embedding with multiple
top-level partmaps, the attached patch simply disables embedding when
there are multiple partmaps (i.e. apply the same behavior as when there
is no partmap).
This prevents grub-setup from overwriting e.g. a BSD label if it finds
an msdos label first.
The only drawback I see is that grub-setup may complain about an old
obsolete disklabel, but in that case the user simply has to destroy the
obsolete label, and IMHO this is more acceptable than potentially
destroying valuable data.
Grégoire
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: detect-multiple-partmaps.diff --]
[-- Type: text/x-patch; name="detect-multiple-partmaps.diff", Size: 1732 bytes --]
=== modified file 'ChangeLog'
--- ChangeLog 2010-06-17 20:54:04 +0000
+++ ChangeLog 2010-06-17 22:06:58 +0000
@@ -1,3 +1,8 @@
+2010-06-17 Grégoire Sutre <gregoire.sutre@gmail.com>
+
+ * util/i386/pc/grub-setup.c (setup): Do not embed when there are
+ multiple (top-level) partmaps.
+
2010-06-17 Colin Watson <cjwatson@ubuntu.com>
* util/i386/pc/grub-setup.c (usage): Pass an extra `program_name'
=== modified file 'util/i386/pc/grub-setup.c'
--- util/i386/pc/grub-setup.c 2010-06-17 20:54:04 +0000
+++ util/i386/pc/grub-setup.c 2010-06-17 22:04:48 +0000
@@ -93,6 +93,7 @@
grub_uint16_t core_sectors;
grub_device_t root_dev, dest_dev;
const char *dest_partmap;
+ int multiple_partmaps;
grub_uint8_t *boot_drive;
grub_disk_addr_t *kernel_sector;
grub_uint16_t *boot_drive_check;
@@ -354,10 +355,17 @@
{
if (p->parent)
return 0;
- dest_partmap = p->partmap->name;
- return 1;
+ if (dest_partmap == NULL)
+ dest_partmap = p->partmap->name;
+ else if (strcmp (dest_partmap, p->partmap->name) != 0)
+ {
+ multiple_partmaps = 1;
+ return 1;
+ }
+ return 0;
}
dest_partmap = 0;
+ multiple_partmaps = 0;
grub_partition_iterate (dest_dev->disk, identify_partmap);
if (! dest_partmap)
@@ -365,6 +373,11 @@
grub_util_warn (_("Attempting to install GRUB to a partitionless disk. This is a BAD idea."));
goto unable_to_embed;
}
+ if (multiple_partmaps)
+ {
+ grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels. This is a BAD idea."));
+ goto unable_to_embed;
+ }
if (strcmp (dest_partmap, "msdos") == 0)
grub_partition_iterate (dest_dev->disk, find_usable_region_msdos);
next reply other threads:[~2010-06-17 23:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-17 23:07 Grégoire Sutre [this message]
2010-07-01 20:52 ` [Patch] Do not embed with multiple partmaps Vladimir 'φ-coder/phcoder' Serbinenko
2010-07-04 12:19 ` Grégoire Sutre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C1AAAC9.4060907@gmail.com \
--to=gregoire.sutre@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.