From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OPOBW-0000rc-O3 for mharc-grub-devel@gnu.org; Thu, 17 Jun 2010 19:07:46 -0400 Received: from [140.186.70.92] (port=34965 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OPOBT-0000pW-Bl for grub-devel@gnu.org; Thu, 17 Jun 2010 19:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OPOBS-0007NK-21 for grub-devel@gnu.org; Thu, 17 Jun 2010 19:07:43 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:54251) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OPOBR-0007NG-Rp for grub-devel@gnu.org; Thu, 17 Jun 2010 19:07:42 -0400 Received: by wyf28 with SMTP id 28so440242wyf.0 for ; Thu, 17 Jun 2010 16:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=daFp/oVtUROI3VMY60gv7jDJ4vHnuS+CfHhf4l64wwg=; b=i86ovbDOVgsa3TaWAf3ic0EQ6QevR9Q+CpVT7JMhnHVdhOCf2smi9j8erLOzS3j+0+ 3AXaKMB/Mzf1tDSonxLY4o3tc+1CkSRKD2KFsFH+HfHT+jiSRmrTTDrTlguR+y3cTIZw Or1XVzgJ5cYOp0B1nkqLrwnHWu0MNKhvuDbuU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=bKiObe7ysJbnKIhqBiukkaQxRO2nxf2byK3nO0+xZKJNdoC6YRS79Io/ur17vww5D8 wC3pMNbFzD+4MINNqj9pT00kULNHtqmivCgTjOhWIL3zT/R/DNrjw/z9VyGRCTls8ywx ezzrn7dsMvVvbrJqyZJAPmInuuE0aiEBa/TAc= Received: by 10.227.155.213 with SMTP id t21mr216724wbw.66.1276816060792; Thu, 17 Jun 2010 16:07:40 -0700 (PDT) Received: from [192.168.1.50] (c2433-1-88-160-112-182.fbx.proxad.net [88.160.112.182]) by mx.google.com with ESMTPS id b17sm9787528wbd.19.2010.06.17.16.07.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 17 Jun 2010 16:07:40 -0700 (PDT) Message-ID: <4C1AAAC9.4060907@gmail.com> Date: Fri, 18 Jun 2010 01:07:53 +0200 From: =?ISO-8859-1?Q?Gr=E9goire_Sutre?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4 MIME-Version: 1.0 To: The development of GNU GRUB Content-Type: multipart/mixed; boundary="------------000408010108010204000300" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Patch] Do not embed with multiple partmaps X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2010 23:07:44 -0000 This is a multi-part message in MIME format. --------------000408010108010204000300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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 --------------000408010108010204000300 Content-Type: text/x-patch; name="detect-multiple-partmaps.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="detect-multiple-partmaps.diff" === 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 + + * util/i386/pc/grub-setup.c (setup): Do not embed when there are + multiple (top-level) partmaps. + 2010-06-17 Colin Watson * 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); --------------000408010108010204000300--