summaryrefslogtreecommitdiffstats
path: root/share/examples
diff options
context:
space:
mode:
authorsbruno <sbruno@FreeBSD.org>2009-09-07 23:16:27 +0000
committersbruno <sbruno@FreeBSD.org>2009-09-07 23:16:27 +0000
commit44778f4664a282655b0f666f93d9b4fdacaa7bd3 (patch)
tree39ed09ac9ede7db9f3a9c5573ebad5ed1d296aa0 /share/examples
parent7b5026505bb92146dcb5052720cc787581640eca (diff)
downloadFreeBSD-src-44778f4664a282655b0f666f93d9b4fdacaa7bd3.zip
FreeBSD-src-44778f4664a282655b0f666f93d9b4fdacaa7bd3.tar.gz
A few enhancements I made while working on the Firewire target (sbp_targ).
Update the error handling in a couple of cases to exit gracefully if certain mandatory conditions aren't met. Reduce the maximum number of initiators to 8 for this example code. While 1024 is more correct, this example code would act like it was stalled out even though it was merely allocating the needed structures in init_ccbs() Reviewed by: scottl@freebsd.org
Diffstat (limited to 'share/examples')
-rw-r--r--share/examples/scsi_target/scsi_target.c8
-rw-r--r--share/examples/scsi_target/scsi_target.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c
index c9686f9..1cf0bf5 100644
--- a/share/examples/scsi_target/scsi_target.c
+++ b/share/examples/scsi_target/scsi_target.c
@@ -226,7 +226,7 @@ main(int argc, char *argv[])
/* Open backing store for IO */
file_fd = open(file_name, O_RDWR);
if (file_fd < 0)
- err(1, "open backing store file");
+ errx(EX_NOINPUT, "open backing store file");
/* Check backing store size or use the size user gave us */
if (user_size == 0) {
@@ -291,7 +291,9 @@ main(int argc, char *argv[])
} while (targ_fd < 0 && errno == EBUSY);
if (targ_fd < 0)
- err(1, "Tried to open %d devices, none available", unit);
+ errx(1, "Tried to open %d devices, none available", unit);
+ else
+ warnx("opened /dev/targ%d", unit);
/* The first three are handled by kevent() later */
signal(SIGHUP, SIG_IGN);
@@ -318,6 +320,7 @@ main(int argc, char *argv[])
/* Set up inquiry data according to what SIM supports */
if (get_sim_flags(&sim_flags) != CAM_REQ_CMP)
errx(1, "get_sim_flags");
+
if (tcmd_init(req_flags, sim_flags) != 0)
errx(1, "Initializing tcmd subsystem failed");
@@ -327,6 +330,7 @@ main(int argc, char *argv[])
if (debug)
warnx("main loop beginning");
+
request_loop();
exit(0);
diff --git a/share/examples/scsi_target/scsi_target.h b/share/examples/scsi_target/scsi_target.h
index 3d94810..51af492 100644
--- a/share/examples/scsi_target/scsi_target.h
+++ b/share/examples/scsi_target/scsi_target.h
@@ -35,7 +35,7 @@
* Maximum number of parallel commands to accept,
* 1024 for Fibre Channel (SPI is 16).
*/
-#define MAX_INITIATORS 1024
+#define MAX_INITIATORS 8
#define SECTOR_SIZE 512
#define MAX_EVENTS (MAX_INITIATORS + 5)
/* kqueue for AIO, signals */
OpenPOWER on IntegriCloud