Add a new ioctl, SCSIOCGETDEVINFO, which takes a device ID and uses it

to look up information about that device.  Right now, all it does
is give back the dev_t for the device, if known, since that's all
I needed, but hopefully the SCSI mavens will come up with a more generally
useful structure.
This commit is contained in:
Garrett Wollman 1998-02-01 04:13:13 +00:00
parent 1f13bdaa97
commit 158f45f157
2 changed files with 25 additions and 3 deletions

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*End copyright
*
* $Id: scsi_ioctl.c,v 1.26 1997/09/02 20:06:34 bde Exp $
* $Id: scsi_ioctl.c,v 1.27 1997/12/02 21:07:01 phk Exp $
*
*
*/
@ -256,7 +256,7 @@ struct proc *p, struct scsi_link *sc_link)
/* If we can't write the device we can't permit much:
*/
if (cmd != SCIOCIDENTIFY && !(flags & FWRITE))
if (cmd != SCIOCIDENTIFY && cmd != SCSIOCGETDEVINFO&& !(flags & FWRITE))
return EACCES;
SC_DEBUG(sc_link,SDEV_DB2,("scsi_do_ioctl(0x%x)\n",cmd));
@ -363,6 +363,20 @@ struct proc *p, struct scsi_link *sc_link)
sca->lun = sc_link->lun;
break;
}
case SCIOCGETDEVINFO:
{
struct scsi_devinfo *scd = (struct scsi_devinfo *)addr;
struct scsi_link *scl;
scl = scsi_link_get(scd->addr.bus, scd->addr.target,
scd->addr.lun);
if (scl != 0) {
scd->dev = scl->dev;
ret = 0;
} else {
ret = ENXIO;
}
break;
}
default:
ret = ENOTTY;

View File

@ -1,5 +1,5 @@
/*
* $Id$
* $Id: scsiio.h,v 1.8 1997/02/22 09:45:49 peter Exp $
*/
#ifndef _SYS_SCSIIO_H_
#define _SYS_SCSIIO_H_
@ -67,4 +67,12 @@ struct scsi_addr {
#define SCIOCFREEZETHAW _IOW('Q', 11, int) /* Freeze SCSI for some seconds */
#define SCIOCWAITTHAW _IO('Q', 12) /* Wait for SCSI to thaw */
struct scsi_getdevinfo {
struct scsi_addr addr;
dev_t dev;
};
#define SCIOCGETDEVINFO _IOWR('Q', 13, struct scsi_getdevinfo)
#endif /* !_SYS_SCSIIO_H_ */