From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KabIZ-0001hL-Gj for mharc-grub-devel@gnu.org; Tue, 02 Sep 2008 15:12:19 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KabIX-0001gq-GK for grub-devel@gnu.org; Tue, 02 Sep 2008 15:12:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KabIV-0001gL-Qn for grub-devel@gnu.org; Tue, 02 Sep 2008 15:12:17 -0400 Received: from [199.232.76.173] (port=55974 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KabIV-0001gH-Nj for grub-devel@gnu.org; Tue, 02 Sep 2008 15:12:15 -0400 Received: from mailout04.t-online.de ([194.25.134.18]:35655) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KabIV-0007jc-EY for grub-devel@gnu.org; Tue, 02 Sep 2008 15:12:15 -0400 Received: from fwd33.aul.t-online.de by mailout04.sul.t-online.de with smtp id 1KabIS-0008Gv-00; Tue, 02 Sep 2008 21:12:12 +0200 Received: from [10.3.2.2] (bjXMaBZvZhWZyqaeh6eZn61EorQObSN5BoA4IQmKmtaekWHjILu0Ml+Dt6EhM7eQ-t@[217.235.224.72]) by fwd33.aul.t-online.de with esmtp id 1KabII-0Pitf60; Tue, 2 Sep 2008 21:12:02 +0200 Message-ID: <48BD9004.1030901@t-online.de> Date: Tue, 02 Sep 2008 21:12:04 +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> In-Reply-To: <87abeqlkjd.fsf@xs4all.nl> Content-Type: multipart/mixed; boundary="------------080504000105090202090904" X-ID: bjXMaBZvZhWZyqaeh6eZn61EorQObSN5BoA4IQmKmtaekWHjILu0Ml+Dt6EhM7eQ-t X-TOI-MSGID: 24836726-7b30-437c-b736-84bb889039c7 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:12:17 -0000 This is a multi-part message in MIME format. --------------080504000105090202090904 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Marco Gerards wrote: > [...] > > >>> We could write a macro for ID comparison that would compare both the >>> "driver ID" (disk->dev->id) and "device ID" (disk->id). In this case, >>> we can omit disk->id initialization in the drivers supporting only one >>> device (e.g. memdisk) and only leave it where it's indeed needed for >>> identifying separate devices, thus removing potentially confusing code. >>> >> Sounds fine, although what worries me most if the current usage of 'id' in >> scsi.c, which can lead to collision already. >> >> I assume using LUNs is a proper solution for that one? >> > > No, it is not. I think I already said so on IRC? > > 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. See attached patch for an example. Christian --------------080504000105090202090904 Content-Type: text/x-diff; name="grub2-disk-id.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="grub2-disk-id.patch" diff --git a/disk/memdisk.c b/disk/memdisk.c index 978eae5..e814890 100644 --- a/disk/memdisk.c +++ b/disk/memdisk.c @@ -41,7 +41,7 @@ grub_memdisk_open (const char *name, grub_disk_t disk) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a memdisk"); disk->total_sectors = memdisk_size / GRUB_DISK_SECTOR_SIZE; - disk->id = (unsigned long) "mdsk"; + disk->id = (unsigned long) grub_memdisk_open; disk->has_partitions = 0; return GRUB_ERR_NONE; diff --git a/disk/scsi.c b/disk/scsi.c index 01ef04e..8a5bd4e 100644 --- a/disk/scsi.c +++ b/disk/scsi.c @@ -248,7 +248,7 @@ grub_scsi_open (const char *name, grub_disk_t disk) { if (! p->open (name, scsi)) { - disk->id = (unsigned long) "scsi"; /* XXX */ + disk->id = (unsigned long) scsi; disk->data = scsi; scsi->dev = p; scsi->lun = lun; --------------080504000105090202090904--