How johnpgarry/sg3_utils works
sg3_utils is a suite of command-line tools for issuing SCSI and related storage commands, plus the shared libsgutils runtime. The usual workflow is an operator invoking a utility, which interprets options and requests device operations through shared command and pass-through layers; results are decoded or displayed. Copy utilities provide a distinct data-transfer workflow. The README documents ATA/SAT and NVMe support, including NVMe-aware behavior in sg_inq and sg_ses. Some subsystem links below rely on README or SOURCE INDEX references rather than sampled implementation excerpts.
Main entry points: sg_pt.h Pass-through API · sg_cmds_basic.h Basic command API · sg_ses.c Enclosure services · sg_pt_linux.c Linux transport
Components 32
Command-line utilities
- SCSI utilities
src - Raw commands
src/sg_raw.c - Copy utilities
src/sg_dd.c - Inquiry
src/sg_inq.c - Log pages
src/sg_logs.c - Enclosure services
src/sg_ses.c - VPD data
src/sg_vpd.c - Zone query
src/sg_z_act_query.c
Command and decode library
- Basic commands
lib/sg_cmds_basic.c - Extended commands
lib/sg_cmds_extra.c - SCSI decoding
lib/sg_lib.c - Decode tables
lib/sg_lib_data.c
Pass-through transport
- Linux transport
lib/sg_pt_linux.c - Linux NVMe
lib/sg_pt_linux_nvme.c - FreeBSD transport
lib/sg_pt_freebsd.c - Windows transport
lib/sg_pt_win32.c
Runtime interfaces
- Basic command API
include/sg_cmds_basic.h - Extended command API
include/sg_cmds_extra.h - Library API
include/sg_lib.h - Data definitions
include/sg_lib_data.h - Pass-through API
include/sg_pt.h - Linux I/O definitions
include/sg_io_linux.h - Linux definitions
include/sg_linux_inc.h - NVMe interface
include/sg_pt_nvme.h - Windows interface
include/sg_pt_win32.h - Diagnostics output
include/sg_pr2serr.h - Byte conversions
include/sg_unaligned.h - SG kernel interface
testing/uapi_sg.h - Linux pass-through API
include/sg_pt_linux.h - Name tables API
include/sg_lib_names.h
Other components
- Operator
- Storage device
Connections 37
- Operator → SCSI utilities: invokes
README - Operator → Raw commands: invokes
README - Operator → Copy utilities: invokes
README - SCSI utilities → Basic commands: requests commands
- Raw commands → Pass-through API: submits commands
- Copy utilities → Basic commands: requests I/O
- Inquiry → Basic command API: uses command API
src/sg_inq.c - Inquiry → Pass-through API: uses pass-through
src/sg_inq.c - Log pages → Basic command API: uses command API
src/sg_logs.c - Log pages → Pass-through API: uses pass-through
src/sg_logs.c - Enclosure services → Basic command API: uses command API
src/sg_ses.c - Enclosure services → Extended command API: uses extended API
src/sg_ses.c - Enclosure services → Pass-through API: uses pass-through
src/sg_ses.c - VPD data → Basic command API: uses command API
src/sg_vpd.c - Zone query → Basic command API: uses command API
src/sg_z_act_query.c - Basic commands → Pass-through API: uses pass-through
- Extended commands → Pass-through API: uses pass-through
lib/sg_cmds_extra.c - SCSI decoding → Decode tables: uses tables
lib/sg_lib.c - SCSI decoding → Data definitions: uses definitions
lib/sg_lib.c - Inquiry → Storage device: queries SCSI or NVMe
README - Enclosure services → Storage device: queries SCSI or NVMe
README - SCSI utilities → Storage device: sends SCSI commands
README - Copy utilities → Storage device: copies device data
README - Pass-through API → Linux transport: implemented by
- Pass-through API → FreeBSD transport: implemented by
lib/sg_pt_freebsd.c - Pass-through API → Windows transport: implemented by
lib/sg_pt_win32.c - Linux transport → Linux NVMe: supports NVMe
lib/sg_pt_linux_nvme.c - Linux transport → Linux I/O definitions: uses definitions
- Linux transport → Linux pass-through API: uses interface
- Linux NVMe → NVMe interface: uses interface
lib/sg_pt_linux_nvme.c - FreeBSD transport → NVMe interface: uses interface
lib/sg_pt_freebsd.c - Windows transport → Windows interface: uses interface
lib/sg_pt_win32.c - Linux I/O definitions → Linux definitions: includes definitions
include/sg_io_linux.h - SG kernel interface → Linux I/O definitions: complements interface
- Basic command API → Diagnostics output: documents output
- Library API → Byte conversions: supports decoding
- Name tables API → Data definitions: uses definitions
include/sg_lib_names.h