p Where the .Xr wd 4 device has a fairly low level interface to the system, .Tn SCSI devices have a much higher level interface and talk to the system via a .Tn SCSI host adapter (e.g., .Xr ahc 4 ) . A .Tn SCSI adapter must also be separately configured into the system before a .Tn SCSI disk can be configured.
p
When the
.Tn SCSI
adapter is probed during boot, the
.Tn SCSI
bus is scanned for devices. Any devices found which answer as
.Sq Em Direct
type devices will be attached to the
.Nm
driver.
In
.Tn FreeBSD
releases prior to 2.1, the first found was attached as
.Li sd0 ,
the second
.Li sd1 ,
and so on.
Beginning in 2.1 it became possible to lock down the assignment of
devices on the
.Tn SCSI
bus to particular units of the
.Nm
device; refer to
.Xr scsi 4
for details on kernel configuration.
.Sh PARTITIONING
The
.Nm
driver allows the disk to have two levels of partitioning.
One layer, called the
.Dq slice layer ,
is used to separate the
.Tn FreeBSD
areas of the disk from areas used by other operating systems.
The second layer is the native
.Bx 4.4
partitioning scheme,
.Xr disklabel 5 ,
which is used to subdivide the
.Tn FreeBSD
slices into areas for individual filesystems and swap spaces.
For more information, see
.Xr fdisk 8
and
.Xr disklabel 8 ,
respectively.)
On many systems
.Xr disklabel 8
is used to partition the drive into filesystems. On some systems the
NetBSD portion of the disk resides within a native partition, and another
program is used to create the NetBSD portion.
p For example, the i386 port uses .Xr fdisk 8 to partition the disk into a BIOS level partition. This allows sharing the disk with other operating systems.
p
If an uninitialized disk is opened, the slice table will be
initialized with a fictitious
.Tn FreeBSD
slice spanning the entire disk. Similarly, if an uninitialized
(or
.No non- Ns Tn FreeBSD )
slice is opened, its disklabel will be initialized with parameters returned
by the drive and a single
.Sq Li c
partition encompassing the entire slice.
.Sh KERNEL CONFIGURATION
It is only necessary to explicitly configure one
.Nm
device; data structures are dynamically allocated as disks are found
on the
.Tn SCSI
bus.
.Sh IOCTLS
The following
.Xr ioctl 2
calls apply to
.Tn SCSI
disks as well as to other disks. They are defined in the header file
.Aq Pa disklabel.h .
p
l -tag -width DIOCSDINFO .It Dv DIOCSBAD
Usually used to set up a bad-block mapping system on the disk.
.Tn SCSI
drive incorporate their own bad-block mapping so this command is not
implemented.
t Dv DIOCGDINFO Read, from the kernel, the in-core copy of the disklabel for the
drive. This may be a fictitious disklabel if the drive has never
been initialized, in which case it will contain information read
from the
.Tn SCSI
inquiry commands.
t Dv DIOCSDINFO Give the driver a new disklabel to use. The driver
.Em will not
write the new
disklabel to the disk.
t Dv DIOCWLABEL Enable or disable the driver's software
write protect of the disklabel on the disk.
t Dv DIOCWDINFO Give the driver a new disklabel to use. The driver
.Em will
write the new disklabel to the disk.
t Dv DIOCLOCK Lock the media cartridge into the device, or unlock a cartridge previously
locked. Used to prevent user and software eject while the media is in
use.
t Dv DIOCEJECT Eject the media cartridge from a removable device.
.El
p In addition, the .Xr scsi 4 general .Fn ioctl commands may be used with the .Nm driver, but only against the .Sq Li c (whole disk) partition. .Sh NOTES If a removable device is attached to the .Nm driver, then the act of changing the media will invalidate the disklabel and information held within the kernel. To avoid corruption, all accesses to the device will be discarded until there are no more open file descriptors referencing the device. During this period, all new open attempts will be rejected. When no more open file descriptors reference the device, the first next open will load a new set of parameters (including disklabel) for the drive. .Sh FILES l -tag -width /dev/rsdXXXXX -compact t Pa /dev/sd Ns Ar u Ns Ar p block mode .Tn SCSI disk unit .Ar u , partition .Ar p t Pa /dev/rsd Ns Ar u Ns Ar p raw mode .Tn SCSI disk unit .Ar u , partition .Ar p .Sm off .El .Sh DIAGNOSTICS None. .Sh SEE ALSO .Xr wd 4 , .Xr disklabel 5 , .Xr disklabel 8 , .Xr fdisk 8 .Sh HISTORY The .Nm driver was originally written for .Tn Mach 2.5, and was ported to .Tn FreeBSD by Julian Elischer. It was later ported to .Tn NetBSD .