diff options
author | simokawa <simokawa@FreeBSD.org> | 2003-09-25 05:43:26 +0000 |
---|---|---|
committer | simokawa <simokawa@FreeBSD.org> | 2003-09-25 05:43:26 +0000 |
commit | b8306c28e9a7940e023e1132173fb79c10747785 (patch) | |
tree | 791693805cbb36f6d7a49ce703a2383d77b16bae /share | |
parent | e30e166f804581d473b15dc3488e11bae2dc2611 (diff) | |
download | FreeBSD-src-b8306c28e9a7940e023e1132173fb79c10747785.zip FreeBSD-src-b8306c28e9a7940e023e1132173fb79c10747785.tar.gz |
* 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.
Diffstat (limited to 'share')
-rw-r--r-- | share/examples/scsi_target/scsi_cmds.c | 8 | ||||
-rw-r--r-- | share/examples/scsi_target/scsi_target.c | 24 |
2 files changed, 28 insertions, 4 deletions
diff --git a/share/examples/scsi_target/scsi_cmds.c b/share/examples/scsi_target/scsi_cmds.c index 1cbe6d8..331578f 100644 --- a/share/examples/scsi_target/scsi_cmds.c +++ b/share/examples/scsi_target/scsi_cmds.c @@ -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 diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c index 09f6610..d1bcb27 100644 --- a/share/examples/scsi_target/scsi_target.c +++ b/share/examples/scsi_target/scsi_target.c @@ -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) |