TARG(4)
π¦ TARG(4) β SCSI target emulator driver π¦
okay so bestie, this is the TARG(4) page from the Kernel Interfaces Manual β the SCSI target emulator driver. itβs giving kernel-level main character energy, and yes, weβre getting into all of it. π
β¨ NAME β¨
targ β SCSI target emulator driver
πΈ SYNOPSIS πΈ
To compile this driver into the kernel, place the following line in your kernel configuration file:
device targ
π DESCRIPTION π
The targ driver provides an interface for usermode programs to emulate SCSI target devices. A sample program that emulates a disk drive (similar to da(4)) can be found in /usr/share/examples/scsi_target.
The targ driver supplies the control device /dev/targ. After opening the device, the file descriptor must be bound to a specific bus/target/LUN and enabled to process CCBs using the TARGIOCENABLE ioctl. The process then uses write(2) to send CCBs to the SIM and poll(2) or kqueue(2) to see if responses are ready. Pointers to completed CCBs are returned via read(2). Any data transfers requested by the user CCBs are done via zero-copy IO.
π IOCTLS π
The following ioctl(2) calls are defined in the header file <cam/scsi/scsi_targetio.h>.
TARGIOCENABLEβ(struct ioc_enable_lun)Enable target mode on the LUN specified by the following structure:
struct ioc_enable_lun {
path_id_t path_id;
target_id_t target_id;
lun_id_t lun_id;
int grp6_len;
int grp7_len;
};
The selected path (bus), target, and LUN must not already be in use or EADDRINUSE is returned. If grp6_len or grp7_len are non-zero, reception of vendor-specific commands is enabled.
TARGIOCDISABLEβ Disable target mode and abort all pending CCBs. The CCBs may optionally be read as they complete.TARGIOCENABLEcan then be called to activate a different LUN. Multiple disable calls have no effect. Theclose(2)system call automatically disables target mode if enabled.TARGIOCDEBUGβ(int)EnablesCAM_PERIPHdebugging if the argument is non-zero, otherwise disables it.
π§ FILES π§
<cam/scsi/scsi_targetio.h>β describes the usermode interface./sys/cam/scsi/scsi_target.cβ is the driver source file./dev/targβ is the control device.
π₯ SEE ALSO π₯
/usr/share/examples/scsi_target,ahc(4),isp(4),scsi(4)- FreeBSD Target Information, http://www.root.org/~nate/freebsd/.
π AUTHORS π
The targ driver first appeared in FreeBSD 3.0 and was written by Justin T. Gibbs. It was rewritten for FreeBSD 5.0 by Nate Lawson <nate@root.org>.
π BUGS π
- Currently, only the
ahc(4)andisp(4)drivers fully support target mode. - The
ahc(4)driver does not support tagged queuing in target mode.
okay thatβs the whole page β footer vibes: Debian, December 13, 2011, TARG(4). mwah π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2002 Nate Lawson. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms