CD(9)

πŸ’Ώ CD(9) β€” the cd driver, bestie edition ✨

okay so this is cd, section 9 of the Kernel Developer's Manual β€” yes, the kernel developer one, not the shell command, don't @ me πŸ™ˆ it's the CDROM driver for the CAM SCSI subsystem and she's iconic.


🌸 NAME 🌸

cd β€” the CDROM driver for the CAM SCSI subsystem. that's it. that's the girl. πŸ’…


✨ DESCRIPTION ✨

so the cd device driver hands you a read-only interface for CDROM drives (that's SCSI type 5 πŸŽ€) and WORM drives (SCSI type 4) that support CDROM type commands. slay.

but lowkey? some drives do NOT behave the way the driver expects. like, at all. 😭 so if your drive is being extra, go read the β€œQUIRKS” section below for info on possible flags. iykyk.


πŸ¦‹ QUIRKS πŸ¦‹

every single CD-ROM device can have its own little interpretation of the SCSI spec, which is so on brand for hardware honestly. and that can lead to drives needing special handling in the driver. here's the full list of quirks the driver recognizes β€” no skips, no cuts, we list them all:

  • CD_Q_NO_TOUCH β€” tells the driver not to probe the drive at attach time to see if there's a disk in there and figure out what size it is. > heads up bestie: this flag is currently unimplemented in the CAM cd driver. so yeah. it's giving placeholder. πŸ’€
  • CD_Q_BCD_TRACKS β€” this one's for broken drives that return track numbers in packed BCD instead of straight decimal. if your drive seems to be skipping tracks (like tracks 10-15 just vanish ✨), congrats, you have a drive that is in need of this flag. not me diagnosing your hardware through a manpage.
  • CD_Q_NO_CHANGER β€” tells the driver that the device in question is not a changer. you only need this for a CDROM device with multiple luns that are not part of a changer. niche but valid.
  • CD_Q_CHANGER β€” tells the driver that the given device is a multi-lun changer. in general the driver will figure this out all by itself when it sees a LUN greater than 0 (main character energy, honestly). setting this flag only does one thing: it tells the driver to run the initial read capacity command for LUN 0 of the changer through the changer scheduling code.
  • CD_Q_10_BYTE_ONLY β€” tells the driver that the given device only accepts 10 byte MODE SENSE/MODE SELECT commands. now listen β€” in general these types of quirks should not be added to the cd(4) driver. why? because the driver already does several things to try to figure out whether the drive in question needs 10 byte commands:
    1. first, it issues a CAM Path Inquiry command to determine whether the protocol the drive speaks typically only allows 10 byte commands. (ATAPI and USB are two prominent examples of protocols where you generally only want to send 10 byte commands. πŸ‘€)
    2. then, if it gets an ILLEGAL REQUEST error back from a 6 byte MODE SENSE or MODE SELECT command, it attempts to send the 10 byte version of the command instead.

so the only reason you'd ever need this quirk is if your drive uses a protocol (e.g., SCSI) that typically does not have a problem with 6 byte commands. periodt.


πŸŽ€ FILES πŸŽ€

  • /sys/cam/scsi/scsi_cd.c β€” is the driver source file. that's where the magic lives, go read her 🫢

πŸ”₯ SEE ALSO πŸ”₯


πŸ’œ HISTORY πŸ’œ

the cd manual page first appeared in FreeBSD 2.2. a true legend. a pioneer. we stan an OG. πŸ‘‘


🌈 AUTHORS 🌈

this manual page was written by John-Mark Gurney <jmg@FreeBSD.org>. it was then updated for CAM and FreeBSD 3.0 by Kenneth Merry <ken@FreeBSD.org>. thank you for your service, kings 🫑


and that's the whole vibe check bestie πŸ’– this page is from Debian, dated March 25, 2014, living in section 9 of the Kernel Developer's Manual. go forth and mount something. πŸ“βœ¨

πŸ“¦ where this page comes from