From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] fix disk->id abuse
Date: Sat, 30 Aug 2008 14:26:26 +0200 [thread overview]
Message-ID: <20080830122626.GA5899@thorin> (raw)
[-- Attachment #1: Type: text/plain, Size: 915 bytes --]
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."
[-- Attachment #2: disk_id_abuse.diff --]
[-- Type: text/x-diff, Size: 2116 bytes --]
2008-08-30 Robert Millan <rmh@aybabtu.com>
* 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;
next reply other threads:[~2008-08-30 12:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-30 12:26 Robert Millan [this message]
2008-08-30 15:41 ` [PATCH] fix disk->id abuse Pavel Roskin
2008-08-31 13:33 ` Robert Millan
2008-09-01 23:39 ` Pavel Roskin
2008-09-02 13:40 ` Robert Millan
2008-09-02 13:55 ` Marco Gerards
2008-09-02 19:12 ` Christian Franke
2008-09-02 19:24 ` Robert Millan
2008-09-02 19:43 ` Christian Franke
2008-09-02 19:21 ` Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080830122626.GA5899@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.