From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KZPYj-00050V-Ll for mharc-grub-devel@gnu.org; Sat, 30 Aug 2008 08:28:05 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KZPYi-0004zQ-O5 for grub-devel@gnu.org; Sat, 30 Aug 2008 08:28:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KZPYh-0004yi-KK for grub-devel@gnu.org; Sat, 30 Aug 2008 08:28:04 -0400 Received: from [199.232.76.173] (port=42260 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KZPYh-0004yV-5u for grub-devel@gnu.org; Sat, 30 Aug 2008 08:28:03 -0400 Received: from aybabtu.com ([69.60.117.155]:52196) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KZPYg-0000CS-TD for grub-devel@gnu.org; Sat, 30 Aug 2008 08:28:03 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1KZPOk-000708-Vq for grub-devel@gnu.org; Sat, 30 Aug 2008 14:17:47 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1KZPX8-0001ZR-Ht for grub-devel@gnu.org; Sat, 30 Aug 2008 14:26:26 +0200 Date: Sat, 30 Aug 2008 14:26:26 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080830122626.GA5899@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [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: Sat, 30 Aug 2008 12:28:05 -0000 --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline disk->id is supposed to be filled with a per-disk value so that the disk cache manager can identify individual disks. For single-disk drivers, a constant is enough. But it seems someone started using pointers to strings for them, and then we all (including me) copied. Then I see disk/scsi.c doing the same thing, but this time it's a real problem since it's not a single-disk driver. So this patch means to solve both issues; makes single-disk drivers use a constant directly (since a pointer to string is meaningless and confusing), and disk/scsi.c use LUNs which (I believe) will work as unique identifiers. Marco, could you confirm this is ok (specially the latter)? -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --Qxx1br4bt0+wmkIi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="disk_id_abuse.diff" 2008-08-30 Robert Millan * disk/host.c (grub_host_open): Initialize `disk->id' using a constant rather than a pointer to string. * disk/memdisk.c (grub_memdisk_open): Likewise. * fs/i386/pc/pxe.c (grub_pxe_open): Likewise. * disk/scsi.c (grub_scsi_open): Initialize `disk->id' using the `lun' variable rather than a pointer to string. Index: disk/scsi.c =================================================================== --- disk/scsi.c (revision 1831) +++ disk/scsi.c (working copy) @@ -248,7 +248,7 @@ grub_scsi_open (const char *name, grub_d { if (! p->open (name, scsi)) { - disk->id = (unsigned long) "scsi"; /* XXX */ + disk->id = lun; /* FIXME: are LUNs unique identifiers? */ disk->data = scsi; scsi->dev = p; scsi->lun = lun; Index: disk/host.c =================================================================== --- disk/host.c (revision 1831) +++ disk/host.c (working copy) @@ -41,7 +41,7 @@ grub_host_open (const char *name, grub_d return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a host disk"); disk->total_sectors = 0; - disk->id = (unsigned long) "host"; + disk->id = 'host'; disk->has_partitions = 0; disk->data = 0; Index: disk/memdisk.c =================================================================== --- disk/memdisk.c (revision 1831) +++ disk/memdisk.c (working copy) @@ -41,7 +41,7 @@ grub_memdisk_open (const char *name, gru 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 = 'mdsk'; disk->has_partitions = 0; return GRUB_ERR_NONE; Index: fs/i386/pc/pxe.c =================================================================== --- fs/i386/pc/pxe.c (revision 1831) +++ fs/i386/pc/pxe.c (working copy) @@ -63,7 +63,7 @@ grub_pxe_open (const char *name, grub_di return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a pxe disk"); disk->total_sectors = 0; - disk->id = (unsigned long) "pxe"; + disk->id = 'pxe'; disk->has_partitions = 0; disk->data = 0; --Qxx1br4bt0+wmkIi--