* scsi_cmds.c

- Fill in autosense data.
- Add compatibility for RELENG_4.

* scsi_target.c
- Raw device support
- Set correct value in c_descr->offset for CAM_DIR_NONE case.
- Support for CTIO abort.
This commit is contained in:
Hidetoshi Shimokawa 2003-09-25 05:43:26 +00:00
parent d91440cd46
commit c4b3637b44
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=120428
2 changed files with 28 additions and 4 deletions

View File

@ -246,10 +246,8 @@ tcmd_sense(u_int init_id, struct ccb_scsiio *ctio, u_int8_t flags,
/* Fill out the supplied CTIO */
if (ctio != NULL) {
/* No autosense yet
bcopy(sense, &ctio->sense_data, sizeof(*sense));
ctio->sense_len = sizeof(*sense); XXX
*/
ctio->sense_len = sizeof(*sense); /* XXX */
ctio->ccb_h.flags &= ~CAM_DIR_MASK;
ctio->ccb_h.flags |= CAM_DIR_NONE | /* CAM_SEND_SENSE | */
CAM_SEND_STATUS;
@ -331,7 +329,11 @@ init_inquiry(u_int16_t req_flags, u_int16_t sim_flags)
inq = &inq_data;
bzero(inq, sizeof(*inq));
inq->device = T_DIRECT | (SID_QUAL_LU_CONNECTED << 5);
#ifdef SCSI_REV_SPC
inq->version = SCSI_REV_SPC; /* was 2 */
#else
inq->version = SCSI_REV_3; /* was 2 */
#endif
/*
* XXX cpi.hba_inquiry doesn't support Addr16 so we give the

View File

@ -45,6 +45,7 @@
#include <sys/queue.h>
#include <sys/event.h>
#include <sys/param.h>
#include <sys/disk.h>
#include <cam/cam_queue.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_targetio.h>
@ -199,7 +200,18 @@ main(int argc, char *argv[])
if (fstat(file_fd, &st) < 0)
err(1, "fstat file");
volume_size = st.st_size / sector_size;
#if __FreeBSD_version >= 500000
if ((st.st_mode & S_IFCHR) != 0) {
/* raw device */
off_t mediasize;
if (ioctl(file_fd, DIOCGMEDIASIZE, &mediasize) < 0)
err(1, "DIOCGMEDIASIZE");
/* XXX get sector size by ioctl()?? */
volume_size = mediasize / sector_size;
} else
#endif
volume_size = st.st_size / sector_size;
} else {
volume_size = user_size / sector_size;
}
@ -582,6 +594,8 @@ work_atio(struct ccb_accept_tio *atio)
c_descr->offset = a_descr->base_off + a_descr->targ_req;
else if ((a_descr->flags & CAM_DIR_MASK) == CAM_DIR_OUT)
c_descr->offset = a_descr->base_off + a_descr->init_req;
else
c_descr->offset = a_descr->base_off;
/*
* Return a check condition if there was an error while
@ -684,6 +698,14 @@ run_queue(struct ccb_accept_tio *atio)
ctio = (struct ccb_scsiio *)ccb_h;
c_descr = (struct ctio_descr *)ctio->ccb_h.targ_descr;
if (ctio->ccb_h.status == CAM_REQ_ABORTED) {
TAILQ_REMOVE(&a_descr->cmplt_io, ccb_h,
periph_links.tqe);
free_ccb((union ccb *)ctio);
send_ccb((union ccb *)atio, /*priority*/1);
continue;
}
/* If completed item is in range, call handler */
if ((c_descr->event == AIO_DONE &&
c_descr->offset == a_descr->base_off + a_descr->targ_ack)