Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1FyEOk-0004d8-Js for mharc-grub-devel@gnu.org; Wed, 05 Jul 2006 16:55:02 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FyEOj-0004cp-Ek for grub-devel@gnu.org; Wed, 05 Jul 2006 16:55:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FyEOh-0004cU-Vf for grub-devel@gnu.org; Wed, 05 Jul 2006 16:55:01 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FyEOh-0004cR-Sz for grub-devel@gnu.org; Wed, 05 Jul 2006 16:54:59 -0400 Received: from [82.94.249.43] (helo=neonescio.viaisn.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FyEOk-0002Fu-6B for grub-devel@gnu.org; Wed, 05 Jul 2006 16:55:02 -0400 Received: from dijkstra.dekkers.cx ([2001:838:3ce::1] ident=Debian-exim) by neonescio.viaisn.org with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA:32 CV=0) (Exim 4.50 #1) id 1FyEOa-000381-Iq for grub-devel@gnu.org; Wed, 05 Jul 2006 22:54:52 +0200 Received: from localhost ([127.0.0.1] helo=dijkstra.dekkers.cx ident=jeroen) by dijkstra.dekkers.cx with esmtp (Exim 4.62) (envelope-from ) id 1FyEOZ-00032t-Qt for grub-devel@gnu.org; Wed, 05 Jul 2006 22:54:51 +0200 Date: Wed, 05 Jul 2006 22:54:51 +0200 Message-ID: <87wtarepr8.wl%jeroen@vrijschrift.org> From: Jeroen Dekkers To: grub-devel@gnu.org User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.0.50 (x86_64-pc-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Subject: [PATCH] Set size of partition correctly in grub_disk_open() X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jul 2006 20:55:01 -0000 Hi, When we open a partition grub_disk_open() sets disk->total_sectors to the size of the disk, not the size of the partition. We also don't check whether we grub_partition_probe() actually finds a partition. See the patch below. Jeroen Dekkers 2006-07-05 Jeroen Dekkers * kern/disk.c (grub_disk_open): Check whether grub_partition_probe() finds a partition. Set disk->total_sectors to the size of the partition if we open a partition. Index: kern/disk.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/disk.c,v retrieving revision 1.13 diff -u -p -r1.13 disk.c --- kern/disk.c 4 Jun 2006 15:56:54 -0000 1.13 +++ kern/disk.c 5 Jul 2006 20:51:18 -0000 @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2006 Free Software Foundation, Inc. * * GRUB is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -265,7 +265,16 @@ grub_disk_open (const char *name) disk->dev = dev; if (p) - disk->partition = grub_partition_probe (disk, p + 1); + { + disk->partition = grub_partition_probe (disk, p + 1); + if (! disk->partition) + { + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such partition"); + goto fail; + } + + disk->total_sectors = grub_partition_get_len (disk->partition); + } /* The cache will be invalidated about 2 seconds after a device was closed. */