sd_ioctl(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 the ioctl(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:


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