diff options
author | Nate Lawson <njl@FreeBSD.org> | 2003-01-13 05:34:42 +0000 |
---|---|---|
committer | Nate Lawson <njl@FreeBSD.org> | 2003-01-13 05:34:42 +0000 |
commit | 2d696c643ea69246d4a27c7f64db4a0ea16f52b4 (patch) | |
tree | afbcc812ef0edf3572b1e823ef385b15a6af36de /share/examples/scsi_target | |
parent | ec693c0e79dfb3021b0fc49173fe49f8cd52fbf5 (diff) |
Add check for AIO support before starting up.
Notes
Notes:
svn path=/head/; revision=109161
Diffstat (limited to 'share/examples/scsi_target')
-rw-r--r-- | share/examples/scsi_target/scsi_target.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c index e1e0a846503a..0f0d6b8ae28b 100644 --- a/share/examples/scsi_target/scsi_target.c +++ b/share/examples/scsi_target/scsi_target.c @@ -40,6 +40,7 @@ #include <sysexits.h> #include <unistd.h> #include <aio.h> +#include <assert.h> #include <sys/stat.h> #include <sys/queue.h> #include <sys/event.h> @@ -205,6 +206,32 @@ main(int argc, char *argv[]) if (volume_size <= 0) errx(1, "volume must be larger than %d", sector_size); + { + struct aiocb aio, *aiop; + + /* Make sure we have working AIO support */ + memset(&aio, 0, sizeof(aio)); + aio.aio_buf = malloc(sector_size); + if (aio.aio_buf == NULL) + err(1, "malloc"); + aio.aio_fildes = file_fd; + aio.aio_offset = 0; + aio.aio_nbytes = sector_size; + signal(SIGSYS, SIG_IGN); + if (aio_read(&aio) != 0) { + printf("You must enable VFS_AIO in your kernel " + "or load the aio(4) module.\n"); + err(1, "aio_read"); + } + if (aio_waitcomplete(&aiop, NULL) != sector_size) + err(1, "aio_waitcomplete"); + assert(aiop == &aio); + signal(SIGSYS, SIG_DFL); + free((void *)aio.aio_buf); + if (debug) + warnx("aio support tested ok"); + } + /* Go through all the control devices and find one that isn't busy. */ unit = 0; do { |