Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1FzJaM-0000DH-KS for mharc-grub-devel@gnu.org; Sat, 08 Jul 2006 16:39:30 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FzJaL-0000Cv-DK for grub-devel@gnu.org; Sat, 08 Jul 2006 16:39:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FzJaH-0000C2-Lk for grub-devel@gnu.org; Sat, 08 Jul 2006 16:39:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FzJaH-0000By-Gz for grub-devel@gnu.org; Sat, 08 Jul 2006 16:39:25 -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 1FzJaz-0007Mk-Cf for grub-devel@gnu.org; Sat, 08 Jul 2006 16:40:09 -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 1FzJaD-0005Nu-6y for grub-devel@gnu.org; Sat, 08 Jul 2006 22:39:21 +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 1FzJaC-0001ud-88 for grub-devel@gnu.org; Sat, 08 Jul 2006 22:39:20 +0200 Date: Sat, 08 Jul 2006 22:39:20 +0200 Message-ID: <87ac7jg7bb.wl%jeroen@vrijschrift.org> From: Jeroen Dekkers To: The development of GRUB 2 In-Reply-To: <200607081807.44495.okuji@enbug.org> References: <87wtarepr8.wl%jeroen@vrijschrift.org> <200607081807.44495.okuji@enbug.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: Re: [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: Sat, 08 Jul 2006 20:39:29 -0000 At Sat, 8 Jul 2006 18:07:44 +0200, Yoshinori K. Okuji wrote: > > Hi Jeroen, > > On Wednesday 05 July 2006 22:54, Jeroen Dekkers wrote: > > + > > + disk->total_sectors = grub_partition_get_len (disk->partition); > > + } > > But I don't agree with this part. The member "total_sectors" must describe the > size of the whole disk but not of the partition. This is because GRUB > accesses partitions through the disk interface. When accessing a partition, > GRUB tweaks offsets by the start sector of the partition. If not, it is > another bug. grub_disk_check_range() increases the sector read so sector 0 is the first sector of the partition. So if you open a partition, you will have to read from 0 until the length of the partition, and that will give you the partition. Now I'm reading the code again I see that the "out of disk" check needs to be adapted to this change too. But it's a little bit illogical that the size you get from the same disk structure isn't the size of the partition, but the size of something else. It's also not really useful: if you're opening a partition, your are interested in the size of the partition most of the time, not the size of the disk the partition is on. The AFFS code already assumes that the total_sectors is the size of the partition and the blocklist code does that too, if you want to allow to read a blocklist from a partition. Not having total_sectors the size of the partition also makes it impossible to write generic code for both disks and partitions. Everytime you want to get the size of a device, you've to check whether the device is a disk or a partition. This will enlarge the code unnecessary. So I don't really see why total_sectors should be the size of the disk the partition is on instead of the size of the partition. Jeroen Dekkers