scsi_add_device(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… scsi_add_device β€” a Kernel API Manual moment

okay so bestie, this one's scsi_add_device(9) from the Kernel API Manual and honestly? it's giving "small function, big consequences." let's get into it 🫢


✨ NAME ✨

scsi_add_device β€” creates a new SCSI (LU) instance. that's it, that's the whole vibe. it makes a device appear ✨


🌸 SYNOPSIS 🌸

int scsi_add_device (struct Scsi_Host *host , uint channel , uint target
, u64 lun );

literally four args, no cap. hand it a host, a channel, a target and a lun and it'll go off and do its thing πŸ’«


πŸŽ€ ARGUMENTS πŸŽ€

  • host β€” the Scsi_Host instance where the device is located. like, where does this thing even live, that's the host 🏠
  • channel β€” the target channel number. and ngl, it's rarely other than 0 πŸ™ˆ
  • target β€” the target id number, iconic little identifier, we love her πŸ‘‘
  • lun β€” the LUN of the target device. yes, u64. yes, she's big πŸ’œ

πŸ¦‹ DESCRIPTION πŸ¦‹

Probe for a specific LUN and add it if found. that's the entire job description and she ate πŸ”₯


⭐ NOTES ⭐

okay this part MATTERS so listen up bestie, no skimming πŸ‘€

This call is usually performed internally during a SCSI bus scan when an HBA is added (i.e. scsi_scan_host). so it's mostly a behind-the-scenes girly doing her work without being asked πŸ’…

so it should only be called if the HBA becomes aware of a new SCSI device (LU) after scsi_scan_host has completed. like, don't jump the queue, the scan has to finish first, periodt βœ‹

and if it's successful, this call can lead to sdev_init and sdev_configure callbacks into the LLD. so your callbacks are gonna get pinged, be ready for it πŸ’–

lowkey important: this is not a "call it whenever" function. timing is everything, fr fr 🌸

🌈 RETURN 🌈

  • 0 on success (slay πŸ’…)
  • negative error code on failure (the 😭 path)

🧚 SEE ALSO 🧚

Kernel file ./drivers/scsi/scsi_scan.c is the home base for all of these besties, so go say hi:

that's a whole group chat of scan-related functions and they're all linked, iykyk πŸ’«


okay that's the page πŸŽ€ it lives over in ./drivers/scsi, dated October 2026, and it's part of the Kernel API Manual (so yes, scsi_add_device(9) is the name-and-section combo, going in the header where it belongs). mwah, go add some devices responsibly πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from