1.\" Copyright (c) 2002 2.\" Nate Lawson. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the author nor the names of any co-contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY Nate Lawson AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20.\" FOR 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$ 29.\" 30.Dd November 15, 2002 31.Dt SCSI_TARGET 8 32.Os 33.Sh NAME 34.Nm scsi_target 35.Nd usermode SCSI disk emulator 36.Sh SYNOPSIS 37.Nm 38.Op Fl AdST 39.Op Fl b Ar size 40.Op Fl c Ar size 41.Op Fl s Ar size 42.Op Fl W Ar num 43.Ar bus:target:lun 44.Ar filename 45.Sh DESCRIPTION 46The 47.Nm 48program emulates a SCSI target device using the 49.Xr targ 4 50device driver. It supports the basic commands of a direct access device, like 51.Xr da 4 . 52In typical operation, it opens a control device and 53enables target mode for the specified LUN. It then communicates with 54the SIM using CCBs exchanged via 55.Xr read 2 56and 57.Xr write 2 . 58READ and WRITE CDBs are satisfied with the specified backing store file. 59.Pp 60For performance, all backing store accesses use 61.Xr aio 4 . 62Thus, 63.Nm 64requires a kernel compiled with "options VFS_AIO". 65.Pp 66Options: 67.Pp 68.Bl -tag -width XXXXXXXXXXXXXX 69.It Fl A 70Enable 16 addresses if supported by the SIM. Default is 8. 71.It Fl S 72Enable synchronous transfers if supported by the SIM. Default is disabled. 73.It Fl T 74Enable tagged queuing if supported by the SIM. Default is no tagged 75queuing. 76.It Fl W Ar "8,16,32" 77Enable 16 or 32 bit wide transfers if supported by the SIM. Default is 8. 78.It Fl b Ar bufsize 79Set buffer size for transfers. Transfers larger than this will be split 80into multiple transfers. 81.It Fl c Ar sectorsize 82Set sector size for emulated volume. Default is 512. 83.It Fl d 84Enable debugging output in 85.Nm 86and its associated control device. 87.It Fl s Ar volsize 88Use a different size for the emulated volume. Must be less than or equal 89to the size of 90.Ar filename . 91.El 92.Pp 93Required arguments: 94.Bl -tag -width XXXXXXXXXXXXXX 95.It Ar bus:target:lun 96Attach to specified bus id, target id, and lun. 97.It Ar filename 98file to use as a backing store 99.El 100.Pp 101All options default to the minimal functionality of SCSI-1. 102To be safe, 103.Nm 104checks the SIM for the requested capability before enabling target mode. 105.Sh EXAMPLE 106Create a 5 megabyte backing store file. 107.Bd -literal 108# dd if=/dev/zero of=vol size=1m count=5 109.Ed 110.Pp 111Enable target mode on bus 0, target id 1, lun 0, using 112.Ar vol 113as the backing store for READ6/10 and WRITE6/10 commands. 114Only the first 1000 bytes of 115.Ar vol 116will be used. Debugging information will be output. 11716-bit wide transfers will be used if the SIM supports them. 118.Pp 119.Bd -literal 120# scsi_target -d -v 1000 -W 16 0:1:0 vol 121.Ed 122.Sh FILES 123.Bl -tag -width /usr/share/examples/scsi_target -compact 124.It Pa /dev/targ* 125are the control devices. 126.It Pa /usr/share/examples/scsi_target 127is the source directory. 128.El 129.Sh SEE ALSO 130.Xr targ 4 , 131.Xr scsi 4 132.Sh AUTHORS 133The 134.Nm 135example first appeared in 136.Fx 3.0 137and was written by 138.An Justin T. Gibbs . 139It was rewritten for 140.Fx 5.0 141by 142.An Nate Lawson Aq nate@root.org . 143