diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-03 04:58:22 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-03 04:58:22 +0000 |
commit | 197dd4fd469f573243f0fa2108f0f7c8fd01e0bf (patch) | |
tree | 68a1fa458ea692e5bcd3dc0ed054a29e05c4567e /sys/scsi/sd.c | |
parent | cd94cddeff421164bec9661a132c615be9dd95bb (diff) |
implement the DK INFO ioctl so userland can query the disks product,
vendor, etc details.
Diffstat (limited to 'sys/scsi/sd.c')
-rw-r--r-- | sys/scsi/sd.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index c4921761fb0..f8d8d68cbfa 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.119 2007/02/21 01:32:21 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.120 2007/04/03 04:58:21 dlg Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -108,6 +108,8 @@ void sd_flush(struct sd_softc *, int); void viscpy(u_char *, u_char *, int); +int sd_ioctl_inquiry(struct sd_softc *, struct dk_inquiry *); + struct cfattach sd_ca = { sizeof(struct sd_softc), sdmatch, sdattach, sddetach, sdactivate @@ -953,6 +955,13 @@ sdioctl(dev, cmd, addr, flag, p) sd->sc_link->flags |= SDEV_EJECTING; goto exit; + case DIOCINQ: + error = scsi_do_ioctl(sd->sc_link, dev, cmd, addr, flag, p); + if (error == ENOTTY) + error = sd_ioctl_inquiry(sd, + (struct dk_inquiry *)addr); + goto exit; + default: if (part != RAW_PART) { error = ENOTTY; @@ -966,6 +975,27 @@ sdioctl(dev, cmd, addr, flag, p) return (error); } +int +sd_ioctl_inquiry(struct sd_softc *sd, struct dk_inquiry *di) +{ + struct scsi_inquiry_vpd vpd; + + bzero(di, sizeof(struct dk_inquiry)); + scsi_strvis(di->vendor, sd->sc_link->inqdata.vendor, + sizeof(sd->sc_link->inqdata.vendor)); + scsi_strvis(di->product, sd->sc_link->inqdata.product, + sizeof(sd->sc_link->inqdata.product)); + scsi_strvis(di->revision, sd->sc_link->inqdata.revision, + sizeof(sd->sc_link->inqdata.revision)); + + /* the serial vpd page is optional */ + if (scsi_inquire_vpd(sd->sc_link, &vpd, sizeof(vpd), + SI_PG_SERIAL, 0) == 0) + scsi_strvis(di->serial, vpd.serial, sizeof(vpd.serial)); + + return (0); +} + /* * Load the label information on the named device */ |