From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OKh9O-0003DC-Ia for mharc-grub-devel@gnu.org; Fri, 04 Jun 2010 20:22:10 -0400 Received: from [140.186.70.92] (port=60582 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKh9M-0003Bl-4x for grub-devel@gnu.org; Fri, 04 Jun 2010 20:22:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKh9K-0002ga-R1 for grub-devel@gnu.org; Fri, 04 Jun 2010 20:22:08 -0400 Received: from mail-ww0-f41.google.com ([74.125.82.41]:45462) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKh9K-0002gR-KM for grub-devel@gnu.org; Fri, 04 Jun 2010 20:22:06 -0400 Received: by wwb24 with SMTP id 24so1480285wwb.0 for ; Fri, 04 Jun 2010 17:22:05 -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=AffzTRp+f9n1z7QSYLFXCw64leJsG3H7ELsPSQ0sWx0=; b=NEBHkZRfK6MOvi0GuFh7l1XmEZN3ENrl47qjUk9tGAIWf54HHmBmmxxXPf+RelFcUv hP6svvsIsB9zx1fjouhVf+R9CmHNCKmK1TYDH3kh8XDkLsdfjiUcZ53FWdZgYtL4jTHV 7LvBXCSEtVap0YoGQhYpbdXLjHc0wNRyEDaX4= 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=p4idIu1ZmXB7qsvBU1RL639PBHCLnUcpXC6Rx+izXBre7iLkYf853PRZsA4Ccsx9oq gjpiRqoetu8vzfQCIKJSFu7wXP4ZIDN+ny2IFutxJKna6bluHz8DO5WBxG1FLLtk+DMJ JL/JvEW769pjI6uHMKrMPvsjTQma9RX15BCE0= Received: by 10.227.143.149 with SMTP id v21mr11434087wbu.125.1275697324976; Fri, 04 Jun 2010 17:22:04 -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 y31sm14244760wby.16.2010.06.04.17.22.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 04 Jun 2010 17:22:04 -0700 (PDT) Message-ID: <4C0998AC.5010405@gmail.com> Date: Sat, 05 Jun 2010 02:22:04 +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/20100411 Icedove/3.0.4 MIME-Version: 1.0 To: The development of GNU GRUB Content-Type: multipart/mixed; boundary="------------030504080500090502080303" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Patch] Use absolute offset for embedding area in grub-setup (i386-pc) 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: Sat, 05 Jun 2010 00:22:09 -0000 This is a multi-part message in MIME format. --------------030504080500090502080303 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Hi, The attached patch uses grub_partition_get_start (p) instead of p->start in grub-setup's iteration over partitions. While we are at it, also use grub_partition_get_len (p) instead of p->len. An alternative would be to assume that partitions are properly nested, and therefore iterate only over the top-level ones (i.e. those with p->parent == NULL). In that case, we could equivalently use p->start. In the check for non-empty embedding area, the patch uses <= instead of == (as we may have embed_region.start == 1 && embed_region.end == 0). Comments? Grégoire --------------030504080500090502080303 Content-Type: text/x-patch; name="grub-setup.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="grub-setup.diff" === modified file 'ChangeLog' --- ChangeLog 2010-06-03 08:48:23 +0000 +++ ChangeLog 2010-06-05 00:14:38 +0000 @@ -1,3 +1,8 @@ +2010-06-05 Grégoire Sutre + + * util/i386/pc/grub-setup.c (setup): Use absolute offsets for start of + embedding area. Use <= instead of == when checking for non-emptyness. + 2010-06-03 Colin Watson * INSTALL: Document several build requirements for optional features === modified file 'util/i386/pc/grub-setup.c' --- util/i386/pc/grub-setup.c 2010-05-17 19:26:16 +0000 +++ util/i386/pc/grub-setup.c 2010-06-04 23:53:08 +0000 @@ -126,8 +126,8 @@ setup (const char *dir, /* There's always an embed region, and it starts right after the MBR. */ embed_region.start = 1; - if (embed_region.end > p->start) - embed_region.end = p->start; + if (embed_region.end > grub_partition_get_start (p)) + embed_region.end = grub_partition_get_start (p); return 0; } @@ -147,8 +147,8 @@ setup (const char *dir, /* If there's an embed region, it is in a dedicated partition. */ if (! memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16)) { - embed_region.start = p->start; - embed_region.end = p->start + p->len; + embed_region.start = grub_partition_get_start (p); + embed_region.end = grub_partition_get_start (p) + grub_partition_get_len (p); return 1; } @@ -361,7 +361,7 @@ setup (const char *dir, else grub_util_error (_("No DOS-style partitions found")); - if (embed_region.end == embed_region.start) + if (embed_region.end <= embed_region.start) { if (! strcmp (dest_partmap, "msdos")) grub_util_warn (_("This msdos-style partition label has no post-MBR gap; embedding won't be possible!")); --------------030504080500090502080303--