Author: nwhitehorn Date: Sat Feb 26 14:58:54 2011 New Revision: 219056 URL: http://svn.freebsd.org/changeset/base/219056
Log: 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 Modified: head/sys/cam/ata/ata_da.c head/sys/cam/scsi/scsi_cd.c head/sys/dev/ata/ata-disk.c head/sys/geom/geom_disk.c head/sys/geom/geom_disk.h Modified: head/sys/cam/ata/ata_da.c ============================================================================== --- head/sys/cam/ata/ata_da.c Sat Feb 26 12:50:28 2011 (r219055) +++ head/sys/cam/ata/ata_da.c Sat Feb 26 14:58:54 2011 (r219056) @@ -746,6 +746,8 @@ adaregister(struct cam_periph *periph, v 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; Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Sat Feb 26 12:50:28 2011 (r219055) +++ head/sys/cam/scsi/scsi_cd.c Sat Feb 26 14:58:54 2011 (r219056) @@ -724,6 +724,12 @@ cdregister(struct cam_periph *periph, vo 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) Modified: head/sys/dev/ata/ata-disk.c ============================================================================== --- head/sys/dev/ata/ata-disk.c Sat Feb 26 12:50:28 2011 (r219055) +++ head/sys/dev/ata/ata-disk.c Sat Feb 26 14:58:54 2011 (r219056) @@ -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) == Modified: head/sys/geom/geom_disk.c ============================================================================== --- head/sys/geom/geom_disk.c Sat Feb 26 12:50:28 2011 (r219055) +++ head/sys/geom/geom_disk.c Sat Feb 26 14:58:54 2011 (r219056) @@ -371,6 +371,8 @@ g_disk_dumpconf(struct sbuf *sb, const c 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); } } Modified: head/sys/geom/geom_disk.h ============================================================================== --- head/sys/geom/geom_disk.h Sat Feb 26 12:50:28 2011 (r219055) +++ head/sys/geom/geom_disk.h Sat Feb 26 14:58:54 2011 (r219056) @@ -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; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"