scsi_target.c (107178) | scsi_target.c (109161) |
---|---|
1/* 2 * SCSI Disk Emulator 3 * 4 * Copyright (c) 2002 Nate Lawson. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/* 2 * SCSI Disk Emulator 3 * 4 * Copyright (c) 2002 Nate Lawson. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/share/examples/scsi_target/scsi_target.c 107178 2002-11-22 22:55:51Z njl $ | 28 * $FreeBSD: head/share/examples/scsi_target/scsi_target.c 109161 2003-01-13 05:34:42Z njl $ |
29 */ 30 31#include <sys/types.h> 32#include <errno.h> 33#include <err.h> 34#include <fcntl.h> 35#include <signal.h> 36#include <stddef.h> 37#include <stdio.h> 38#include <stdlib.h> 39#include <string.h> 40#include <sysexits.h> 41#include <unistd.h> 42#include <aio.h> | 29 */ 30 31#include <sys/types.h> 32#include <errno.h> 33#include <err.h> 34#include <fcntl.h> 35#include <signal.h> 36#include <stddef.h> 37#include <stdio.h> 38#include <stdlib.h> 39#include <string.h> 40#include <sysexits.h> 41#include <unistd.h> 42#include <aio.h> |
43#include <assert.h> |
|
43#include <sys/stat.h> 44#include <sys/queue.h> 45#include <sys/event.h> 46#include <sys/param.h> 47#include <cam/cam_queue.h> 48#include <cam/scsi/scsi_all.h> 49#include <cam/scsi/scsi_targetio.h> 50#include <cam/scsi/scsi_message.h> --- 149 unchanged lines hidden (view full) --- 200 err(1, "fstat file"); 201 volume_size = st.st_size / sector_size; 202 } else { 203 volume_size = user_size / sector_size; 204 } 205 if (volume_size <= 0) 206 errx(1, "volume must be larger than %d", sector_size); 207 | 44#include <sys/stat.h> 45#include <sys/queue.h> 46#include <sys/event.h> 47#include <sys/param.h> 48#include <cam/cam_queue.h> 49#include <cam/scsi/scsi_all.h> 50#include <cam/scsi/scsi_targetio.h> 51#include <cam/scsi/scsi_message.h> --- 149 unchanged lines hidden (view full) --- 201 err(1, "fstat file"); 202 volume_size = st.st_size / sector_size; 203 } else { 204 volume_size = user_size / sector_size; 205 } 206 if (volume_size <= 0) 207 errx(1, "volume must be larger than %d", sector_size); 208 |
209 { 210 struct aiocb aio, *aiop; 211 212 /* Make sure we have working AIO support */ 213 memset(&aio, 0, sizeof(aio)); 214 aio.aio_buf = malloc(sector_size); 215 if (aio.aio_buf == NULL) 216 err(1, "malloc"); 217 aio.aio_fildes = file_fd; 218 aio.aio_offset = 0; 219 aio.aio_nbytes = sector_size; 220 signal(SIGSYS, SIG_IGN); 221 if (aio_read(&aio) != 0) { 222 printf("You must enable VFS_AIO in your kernel " 223 "or load the aio(4) module.\n"); 224 err(1, "aio_read"); 225 } 226 if (aio_waitcomplete(&aiop, NULL) != sector_size) 227 err(1, "aio_waitcomplete"); 228 assert(aiop == &aio); 229 signal(SIGSYS, SIG_DFL); 230 free((void *)aio.aio_buf); 231 if (debug) 232 warnx("aio support tested ok"); 233 } 234 |
|
208 /* Go through all the control devices and find one that isn't busy. */ 209 unit = 0; 210 do { 211 snprintf(targname, sizeof(targname), "/dev/targ%d", unit++); 212 targ_fd = open(targname, O_RDWR); 213 } while (targ_fd < 0 && errno == EBUSY); 214 215 if (targ_fd < 0) --- 689 unchanged lines hidden --- | 235 /* Go through all the control devices and find one that isn't busy. */ 236 unit = 0; 237 do { 238 snprintf(targname, sizeof(targname), "/dev/targ%d", unit++); 239 targ_fd = open(targname, O_RDWR); 240 } while (targ_fd < 0 && errno == EBUSY); 241 242 if (targ_fd < 0) --- 689 unchanged lines hidden --- |