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