On 02/24/11 16:07, John Baldwin wrote:
On Thursday, February 24, 2011 3:35:51 pm Nathan Whitehorn wrote:
On 02/24/11 14:14, John Baldwin wrote:
On Thursday, February 24, 2011 10:00:44 am Nathan Whitehorn wrote:
Thanks! I've received basically this patch from a couple people now. I'm
going to investigate whether this is a more generic way to get this
information (so the list doesn't grow infinitely long), and will commit
this if I can't. Having CAM devices be part of newbus would simplify
this a very great deal...
Note that all these disk devices are not CAM devices, so CAM changing to
use new-bus wouldn't really matter one whit. They do all show up as 'DISK'
GEOM's however (I also hacked on a GEOM-based libdisk replacement at one
point, though probably less developed than Marcel's. I used libgeom to
discover DISK devices.) Given that disk_create() already hooks into GEOM,
that is probably the right way to discover disks in a generic fashion.
Right, stepping through that is how I build the list. Adding a device
description to the XML actually seems like a good idea (and maybe the
drive serial number?). Would anyone have any objections to me starting
to go through and do that?
I think that would be fine, but I don't think GEOM knows about those
properties yet?
It doesn't, but the attached patch changes that. I've added a new field
to struct disk (d_descr) meant to hold a human-readable description of
the disk, and changed several drivers (cd, ada, ad) to fill it with
their model strings. I've also modified geom_disk's config XML to report
the disk ident and description. If there aren't any objections, I'll
commit this at the end of the day.
-Nathan
Index: cam/scsi/scsi_cd.c
===================================================================
--- cam/scsi/scsi_cd.c (revision 219031)
+++ cam/scsi/scsi_cd.c (working copy)
@@ -724,6 +724,12 @@
softc->disk->d_strategy = cdstrategy;
softc->disk->d_ioctl = cdioctl;
softc->disk->d_name = "cd";
+ cam_strvis(softc->disk->d_descr, cgd->inq_data.vendor,
+ sizeof(cgd->inq_data.vendor), sizeof(softc->disk->d_descr));
+ strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr));
+ cam_strvis(&softc->disk->d_descr[strlen(softc->disk->d_descr)],
+ cgd->inq_data.product, sizeof(cgd->inq_data.product),
+ sizeof(softc->disk->d_descr) - strlen(softc->disk->d_descr));
softc->disk->d_unit = periph->unit_number;
softc->disk->d_drv1 = periph;
if (cpi.maxio == 0)
Index: cam/ata/ata_da.c
===================================================================
--- cam/ata/ata_da.c (revision 219031)
+++ cam/ata/ata_da.c (working copy)
@@ -746,6 +746,8 @@
softc->disk->d_flags |= DISKFLAG_CANDELETE;
strlcpy(softc->disk->d_ident, cgd->serial_num,
MIN(sizeof(softc->disk->d_ident), cgd->serial_num_len + 1));
+ strlcpy(softc->disk->d_descr, cgd->ident_data.model,
+ MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model)));
softc->disk->d_hba_vendor = cpi.hba_vendor;
softc->disk->d_hba_device = cpi.hba_device;
softc->disk->d_hba_subvendor = cpi.hba_subvendor;
Index: dev/ata/ata-disk.c
===================================================================
--- dev/ata/ata-disk.c (revision 219031)
+++ dev/ata/ata-disk.c (working copy)
@@ -145,6 +145,8 @@
adp->disk->d_flags |= DISKFLAG_CANDELETE;
strlcpy(adp->disk->d_ident, atadev->param.serial,
sizeof(adp->disk->d_ident));
+ strlcpy(adp->disk->d_descr, atadev->param.model,
+ sizeof(adp->disk->d_descr));
parent = device_get_parent(ch->dev);
if (parent != NULL && device_get_parent(parent) != NULL &&
(device_get_devclass(parent) ==
Index: geom/geom_disk.c
===================================================================
--- geom/geom_disk.c (revision 219031)
+++ geom/geom_disk.c (working copy)
@@ -371,6 +371,8 @@
indent, dp->d_fwheads);
sbuf_printf(sb, "%s<fwsectors>%u</fwsectors>\n",
indent, dp->d_fwsectors);
+ sbuf_printf(sb, "%s<ident>%s</ident>\n", indent, dp->d_ident);
+ sbuf_printf(sb, "%s<descr>%s</descr>\n", indent, dp->d_descr);
}
}
Index: geom/geom_disk.h
===================================================================
--- geom/geom_disk.h (revision 219031)
+++ geom/geom_disk.h (working copy)
@@ -85,6 +85,7 @@
u_int d_stripeoffset;
u_int d_stripesize;
char d_ident[DISK_IDENT_SIZE];
+ char d_descr[DISK_IDENT_SIZE];
uint16_t d_hba_vendor;
uint16_t d_hba_device;
uint16_t d_hba_subvendor;
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"