diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2011-02-26 14:58:54 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2011-02-26 14:58:54 +0000 |
commit | 3fa7ecd6134abe348569c648a52df0da771219ae (patch) | |
tree | 44bde4d5f256ba7cfb26815701cdc05607d77274 | |
parent | 34864eccf3e5ec4e2a15c089a5f21e4496eaeb4d (diff) | |
download | FreeBSD-src-3fa7ecd6134abe348569c648a52df0da771219ae.zip FreeBSD-src-3fa7ecd6134abe348569c648a52df0da771219ae.tar.gz |
Add the disk ident and a human-meaningful description (here, the disk model
string) to the geom_disk config XML so that they are easily accessible from
userland.
MFC after: 1 week
-rw-r--r-- | sys/cam/ata/ata_da.c | 2 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_cd.c | 6 | ||||
-rw-r--r-- | sys/dev/ata/ata-disk.c | 2 | ||||
-rw-r--r-- | sys/geom/geom_disk.c | 2 | ||||
-rw-r--r-- | sys/geom/geom_disk.h | 1 |
5 files changed, 13 insertions, 0 deletions
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 44d2fa6..7d39f11 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -746,6 +746,8 @@ adaregister(struct cam_periph *periph, void *arg) 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; diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 6a73efb..4c49e2d3 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -724,6 +724,12 @@ cdregister(struct cam_periph *periph, void *arg) 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) diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index 85b6a54..bcaf6c4 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -145,6 +145,8 @@ ad_attach(device_t dev) 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) == diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 1d17e81..818b656 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -371,6 +371,8 @@ g_disk_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g 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); } } diff --git a/sys/geom/geom_disk.h b/sys/geom/geom_disk.h index 01dd732..2d5f15d 100644 --- a/sys/geom/geom_disk.h +++ b/sys/geom/geom_disk.h @@ -85,6 +85,7 @@ struct disk { 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; |