From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Kabmr-0003Bt-DE for mharc-grub-devel@gnu.org; Tue, 02 Sep 2008 15:43:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kabmq-0003BZ-IR for grub-devel@gnu.org; Tue, 02 Sep 2008 15:43:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kabmp-0003Ar-Ki for grub-devel@gnu.org; Tue, 02 Sep 2008 15:43:35 -0400 Received: from [199.232.76.173] (port=53109 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kabmp-0003Al-CI for grub-devel@gnu.org; Tue, 02 Sep 2008 15:43:35 -0400 Received: from mailout04.t-online.de ([194.25.134.18]:46598) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kabmo-0003QG-Up for grub-devel@gnu.org; Tue, 02 Sep 2008 15:43:35 -0400 Received: from fwd27.aul.t-online.de by mailout04.sul.t-online.de with smtp id 1Kabmm-0003bG-03; Tue, 02 Sep 2008 21:43:32 +0200 Received: from [10.3.2.2] (rSOdA-ZQohvFh4PwccNxYC-8QRcA+UxFxaoCjOKeqqrudY3WV4jKQExEv+zofbEQLS@[217.235.224.72]) by fwd27.aul.t-online.de with esmtp id 1Kabmb-0tkFiS0; Tue, 2 Sep 2008 21:43:21 +0200 Message-ID: <48BD975B.6060507@t-online.de> Date: Tue, 02 Sep 2008 21:43:23 +0200 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11 MIME-Version: 1.0 To: The development of GRUB 2 References: <20080830122626.GA5899@thorin> <20080830114118.3zltziz18g0ss8ws-cebfxv@webmail.spamcop.net> <20080831133355.GC2688@thorin> <1220312369.21219.18.camel@dv> <20080902134045.GB31165@thorin> <87abeqlkjd.fsf@xs4all.nl> <48BD9004.1030901@t-online.de> <20080902192425.GC9070@thorin> In-Reply-To: <20080902192425.GC9070@thorin> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ID: rSOdA-ZQohvFh4PwccNxYC-8QRcA+UxFxaoCjOKeqqrudY3WV4jKQExEv+zofbEQLS X-TOI-MSGID: 5797bdbb-2713-4ddb-a434-ad9c59bb05ea X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: Re: [PATCH] fix disk->id abuse 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: Tue, 02 Sep 2008 19:43:36 -0000 Robert Millan wrote: > On Tue, Sep 02, 2008 at 09:12:04PM +0200, Christian Franke wrote: > >> If disk->id is supposed to be a GUID ('Grub Unique Identifier' in this >> case :-), then a pointer to the private data structure for the disk >> should work. This id is unique until disk close. >> >> For drivers without disk->data, simply use the address of e.g. the open >> function itself. >> > > This is fine for single-disk drivers, but for multi-disk ones we need it to > be unique among different disks provided by the same driver. > > I apparently made the false assumption, that multi-disk drivers always have disk->data as a real pointer. > Although, of course, I don't see why can't we just make it use a pointer to > itself: > > disk->id = (unsigned long) &disk->id; > > but then what's the point of storing that in a variable anyway. We might as > well just remove this variable and whoever uses it can use a pointer to the > structure instead? > > This works on the assumption that disk structures are never reallocated, but > I suppose that's a sane thing to assume... > > Sounds good. Probably add an inline function to improve readability: typedef unsigned long grub_disk_id_t; inline grub_disk_id_t disk_id (const grub_disk_t * disk) { return (grub_id_t)(disk); } ... data = grub_disk_cache_fetch (disk->dev->id, disk_id(disk), start_sector); Christian