sg_scsi_ioctl(9)
π sg_scsi_ioctl(9) β like, the kernel API manual, bestie
okay so this is a page from the Kernel API Manual (sg_scsi_ioctl(9), yes that's the whole title, we're being so official today β¨) and honestly? it's giving "legacy code that still lives in the group chat." let's get into it π«Ά
β¨ NAME β¨
sg_scsi_ioctl β handle deprecated SCSI_IOCTL_SEND_COMMAND ioctl
πΈ SYNOPSIS πΈ
int sg_scsi_ioctl (struct request_queue *q , bool open_for_write ,
struct scsi_ioctl_command __user *sic );
π ARGUMENTS π
qβ the request queue you're sending your scsi commands down. that's the road, bestie, and your command is the car πopen_for_writeβ literally just: is the file / block device opened for writing? yes or no, iconic question, we love a bool πsicβ the userspace structure that describes the command you wanna perform. it's the what of the whole operation π¦
π₯ DESCRIPTION π₯
so you send down the scsi command described by sic to the device below the request queue q. that's it. that's the whole vibe. no cap π¨
π NOTES π (please read these, i'm serious)
- π¨ this interface is deprecated β users should use the
SG_IOinterface instead, because that's a more flexible approach to performing SCSI commands on a device. don't be that person still using the old one, i'm begging π - the SCSI command length is determined by examining the 1st byte of the given command. there is no way to override this. like, none. don't ask, don't try, it's not happening π
- data transfers are limited to
PAGE_SIZE. small plate energy, honestly π - the length (
x + y) must be at leastOMAX_SB_LENbytes long so it can accommodate the sense buffer when an error occurs. the sense buffer is truncated toOMAX_SB_LEN(16) bytes so that old code will not be surprised π like we're protecting the elders, we respect it - if a Unix error occurs (e.g.
ENOMEM) then the user will receive a negative return and the Unix error code in'errno'. if the SCSI command succeeds then0is returned. positive numbers returned are the compacted SCSI error codes (4 bytes in one int) where the lowest byte is the SCSI status. three different return flavours, she contains multitudes π
fr fr, read the return value carefully β negative vs 0 vs positive is not a vibe, it's a whole meaning π«Ά
π SEE ALSO π
Kernel file ./drivers/scsi/scsi_ioctl.c ioctl_probe(9), scsi_set_medium_removal(9), scsi_cmd_allowed(9), scsi_ioctl(9), scsi_ioctl_block_when_processing_errors(9)
go read those, they're the rest of the friend group, iykyk π
and that's the page, bestie π§ this lil slice of the Kernel API Manual lives in ./drivers/scsi and it's dated October 2026 β so yeah, that's the source, the version, and the date, all signed off with love π slay, stay deprecated-free, and remember: use SG_IO π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms