scsi_eh_prep_cmnd(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… scsi_eh_prep_cmnd(9) β€” like, the kernel API manual bestie ✨

okay so real talk, this one's from the Kernel API Manual and it's the save-a-SCSI-command-for-error-recovery girlie. her whole job is snapshotting a command so the SCSI error handler can go feral and then put everything back. πŸŽ€


✨ NAME ✨

scsi_eh_prep_cmnd β€” bestie, it saves a scsi command info as part of error recovery 🫢


🌸 SYNOPSIS 🌸

void scsi_eh_prep_cmnd (struct scsi_cmnd *scmd , struct scsi_eh_save
*ses , unsigned char *cmnd , int cmnd_size , unsigned sense_bytes );

no cap, that's the whole signature. five args. she's not complicated, she's just specific. πŸ‘‘


πŸ¦‹ ARGUMENTS πŸ¦‹

  • scmd β€” the SCSI command structure you're hijacking 😭 like sorry babe, we're taking the wheel for a sec. this is the struct getting its info saved.
  • ses β€” the structure that holds the save/restore information. sticky notes for later energy πŸ’œ
  • cmnd β€” the CDB to send. it can be NULL if no new cmnd is needed β€” sometimes the assignment is "do nothing", iconic.
  • cmnd_size β€” size in bytes of cmnd. and listen, it must be <= MAX_COMMAND_SIZE. not a vibe suggestion, a hard limit. ⚠️
  • sense_bytes β€” size of sense data to copy. or 0. and here's the tea: if != 0, cmnd is ignored πŸ™ˆ

πŸ’– DESCRIPTION πŸ’–

okay so picture it. this function saves a scsi command's information before re-execution, as part of the error recovery process. the way that error recovery just needs a little backup plan, you know? main character energy honestly.

here's the rule that will lowkey catch you if you're not paying attention:

if sense_bytes is 0, the command you send must be one that does not transfer any data. fr fr, zero data movement, don't even think about it.

and then the flip side β€” if sense_bytes != 0, then cmnd is ignored, and this function wires up a REQUEST_SENSE command and cmnd buffers to read sense_bytes into scmd->sense_buffer. like she just takes over. slay. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

it's giving repertoire, bestie. here's the whole friend group, plus the kernel file that lives at ./drivers/scsi/scsi_error.c:


πŸŽ€ one last thing πŸŽ€

this page lives in ./drivers/scsi, and it's dated October 2026 β€” so yeah, she's from the future, and she's still saving your commands. πŸ’…βœ¨ bye bestie, go read scsi_eh_restore_cmnd(9) next, it's literally the other half of this story 🫢🌈

πŸ“¦ where this page comes from