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
This commit is contained in:
Nathan Whitehorn 2011-02-26 14:58:54 +00:00
parent f008df5edd
commit 65cb6238bd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=219056
5 changed files with 13 additions and 0 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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) ==

View File

@ -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);
}
}

View File

@ -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;