diff options
author | njl <njl@FreeBSD.org> | 2003-01-13 05:34:42 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2003-01-13 05:34:42 +0000 |
commit | 1101decae7d3bf96b864ab9377ade8ad8c0475a0 (patch) | |
tree | afbcc812ef0edf3572b1e823ef385b15a6af36de /share | |
parent | 46da382d664dc0c7ceecc9990a5721453b3ee679 (diff) | |
download | FreeBSD-src-1101decae7d3bf96b864ab9377ade8ad8c0475a0.zip FreeBSD-src-1101decae7d3bf96b864ab9377ade8ad8c0475a0.tar.gz |
Add check for AIO support before starting up.
Diffstat (limited to 'share')
-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 e1e0a84..0f0d6b8 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 { |