sd_ioctl(9)
π sd_ioctl(9) β like, the kernel API manual, but make it make sense π
okay so bestie, welcome to sd_ioctl from the Kernel API Manual β this is the little function that handles ioctls for the SCSI disk driver, and honestly? it's giving traffic cop. it takes whatever weird request userspace shoved at it and points it in the right direction. slay. β¨
πΈ SYNOPSIS πΈ
int sd_ioctl (struct block_device *bdev , blk_mode_t mode , unsigned int
cmd , unsigned long arg );
like look at that signature. iconic. no cap, that's the whole shape of it π
π¦ ARGUMENTS π¦
bdevβ the target block device. the actual disk we're talking to, main character energy fr fr πmodeβ the open mode. how we got in here, basically πͺcmdβ the ioctl command number. the actual request, iykyk π₯argβ this is the third argument that got passed to theioctl(2)system call. often it's holding a pointer. so yeah, handle with care, it's usually pointing at something π
π DESCRIPTION π
it returns 0 if everything went fine β¨ (though heads up β some ioctls return positive numbers on success as well, so don't @ me if you get a happy little nonzero back).
if something went wrong? it returns a negated errno value. so like, if you see a negative number, that's your error, periodt π
β NOTE β
most ioctls get forwarded onto the block subsystem, or even further down into the scsi subsystem. so this function is lowkey just the messenger β the real work is happening elsewhere π§
π SEE ALSO π
Kernel file ./drivers/scsi/sd.c plus the whole friend group:
sd_group_number(9)sd_open(9)sd_release(9)sd_check_events(9)sd_eh_reset(9)sd_eh_action(9)sd_done(9)sd_read_block_provisioning(9)sd_read_cpr(9)sd_revalidate_disk(9)sd_unlock_native_capacity(9)sd_format_disk_name(9)sd_probe(9)sd_remove(9)init_sd(9)exit_sd(9)
and that's the page, bestie π
this gem lives over in ./drivers/scsi, dated October 2026, and it's sd_ioctl(9) forever and always π«Ά go read the source, ily, bye β¨
π¦ 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