diff options
author | Matt Jacob <mjacob@FreeBSD.org> | 2000-07-14 20:26:59 +0000 |
---|---|---|
committer | Matt Jacob <mjacob@FreeBSD.org> | 2000-07-14 20:26:59 +0000 |
commit | 97188b54ce326ce175148e156aea2cdee7c3fbe9 (patch) | |
tree | 4eed311050b2c8675083486fc4fea1cea0ac7ed3 /share/examples/scsi_target | |
parent | 4abef49222e5f92a31e6db8a9b1e416b32ba0a65 (diff) |
Make use of the new TARGIODEBUG ioctl (i.e., add an option for it's use).
Notes
Notes:
svn path=/head/; revision=63185
Diffstat (limited to 'share/examples/scsi_target')
-rw-r--r-- | share/examples/scsi_target/scsi_target.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c index 5c1efb186970..b2c0fc8ffca6 100644 --- a/share/examples/scsi_target/scsi_target.c +++ b/share/examples/scsi_target/scsi_target.c @@ -56,6 +56,7 @@ char targdevname[80]; int targctlfd; int targfd; int quit; +int debug = 0; struct ioc_alloc_unit alloc_unit = { CAM_BUS_WILDCARD, CAM_TARGET_WILDCARD, @@ -74,7 +75,7 @@ main(int argc, char *argv[]) int ch; appname = *argv; - while ((ch = getopt(argc, argv, "i:o:p:t:l:")) != -1) { + while ((ch = getopt(argc, argv, "i:o:p:t:l:d")) != -1) { switch(ch) { case 'i': if ((ifd = open(optarg, O_RDONLY)) == -1) { @@ -100,6 +101,9 @@ main(int argc, char *argv[]) case 'l': alloc_unit.lun_id = atoi(optarg); break; + case 'd': + debug++; + break; case '?': default: usage(); @@ -144,6 +148,11 @@ main(int argc, char *argv[]) exit(EX_NOINPUT); } + if (ioctl(targfd, TARGIODEBUG, &debug) == -1) { + perror("TARGIODEBUG"); + exit(EX_SOFTWARE); + } + buf = malloc(bufsize); if (buf == NULL) { @@ -301,6 +310,12 @@ handle_exception() exit(EX_SOFTWARE); } + /* Clear the exception so the kernel will take our response */ + if (ioctl(targfd, TARGIOCCLEAREXCEPTION, &exceptions) == -1) { + perror("TARGIOCCLEAREXCEPTION"); + exit(EX_SOFTWARE); + } + bzero(&ccb, sizeof(ccb)); cam_fill_ctio(&ccb.csio, /*retries*/2, /*cbfcnp*/NULL, @@ -314,17 +329,19 @@ handle_exception() /*data_ptr*/NULL, /*dxfer_len*/0, /*timeout*/5 * 1000); + if (ioctl(targfd, TARGIOCCOMMAND, &ccb) == -1) { perror("TARGIOCCOMMAND"); exit(EX_SOFTWARE); } + } else { + if (ioctl(targfd, TARGIOCCLEAREXCEPTION, &exceptions) == -1) { + perror("TARGIOCCLEAREXCEPTION"); + exit(EX_SOFTWARE); + } } - if (ioctl(targfd, TARGIOCCLEAREXCEPTION, &exceptions) == -1) { - perror("TARGIOCCLEAREXCEPTION"); - exit(EX_SOFTWARE); - } } static void @@ -338,7 +355,7 @@ usage() { (void)fprintf(stderr, -"usage: %-16s [-o output_file] [-i input_file] -p path -t target -l lun\n", +"usage: %-16s [ -d ] [-o output_file] [-i input_file] -p path -t target -l lun\n", appname); exit(EX_USAGE); |