| CD(4) | Device Drivers Manual | CD(4) | 
cd —
cd* at scsibus? target ? lun ?
cd1 at scsibus0 target 4 lun 0
cd* at atapibus? drive ? flags 0x0000
cd driver provides support for a Small Computer
  Systems Interface (SCSI) bus and Advanced Technology Attachment Packet
  Interface (ATAPI) Compact Disc-Read Only Memory (CD-ROM) drive. In an attempt
  to look like a regular disk, the cd driver synthesizes
  a partition table, with one partition covering the entire CD-ROM. It is
  possible to modify this partition table using
  disklabel(8), but it will
  only last until the CD-ROM is unmounted. In general the interfaces are similar
  to those described by wd(4) and
  sd(4).
As the SCSI adapter is probed during boot, the SCSI bus is scanned
    for devices. Any devices found which answer as `Read-only' type devices will
    be `attached' to the cd driver.
For the use of flags with ATAPI devices, see wd(4).
The system utility disklabel(8) may be used to read the synthesized disk label structure, which will contain correct figures for the size of the CD-ROM should that information be required.
<sys/cdio.h> and
  <sys/disklabel.h>.
DIOCGDINFODIOCSDINFOstruct disklabel) Read or write the in-core copy
      of the disklabel for the drive. The disklabel is initialized with
      information read from the SCSI inquiry commands, and should be the same as
      the information printed at boot. This structure is defined in
      disklabel(5).CDIOCPLAYTRACKSstruct ioc_play_track) Start audio playback given
      a track address and length. The structure is defined as follows:
    
struct ioc_play_track
{
	u_char	start_track;
	u_char	start_index;
	u_char	end_track;
	u_char	end_index;
};
    
    CDIOCPLAYBLOCKSstruct ioc_play_blocks) Start audio playback
      given a block address and length. The structure is defined as follows:
    
struct ioc_play_blocks
{
	int	blk;
	int	len;
};
    
    CDIOCPLAYMSFstruct ioc_play_msf) Start audio playback given a
      `minutes-seconds-frames' address and length. The structure is defined as
      follows:
    
struct ioc_play_msf
{
	u_char	start_m;
	u_char	start_s;
	u_char	start_f;
	u_char	end_m;
	u_char	end_s;
	u_char	end_f;
};
    
    CDIOCREADSUBCHANNELstruct ioc_read_subchannel) Read information from
      the subchannel at the location specified by this structure:
    
struct ioc_read_subchannel {
	u_char address_format;
#define CD_LBA_FORMAT	1
#define CD_MSF_FORMAT	2
	u_char data_format;
#define CD_SUBQ_DATA		0
#define CD_CURRENT_POSITION	1
#define CD_MEDIA_CATALOG	2
#define CD_TRACK_INFO		3
	u_char track;
	int	data_len;
	struct  cd_sub_channel_info *data;
};
    
    CDIOREADTOCHEADERstruct ioc_toc_header) Return summary information
      about the table of contents for the mounted CD-ROM. The information is
      returned into the following structure:
    
struct ioc_toc_header {
	u_short len;
	u_char  starting_track;
	u_char  ending_track;
};
    
    CDIOREADTOCENTRYSstruct ioc_read_toc_entry) Return information
      from the table of contents entries mentioned. (Yes, this command name is
      misspelled). The argument structure is defined as follows:
    
struct ioc_read_toc_entry {
	u_char	address_format;
	u_char	starting_track;
	u_short	data_len;
	struct  cd_toc_entry *data;
};
    
    data_len and pointed to by
      data.CDIOCSETPATCHstruct ioc_patch) Attach various audio channels
      to various output channels. The argument structure is defined thusly:
    
struct ioc_patch {
	u_char	patch[4];
	/* one for each channel */
};
    
    CDIOCGETVOLCDIOCSETVOLstruct ioc_vol) Get (set) information about the
      volume settings of the output channels. The argument structure is as
      follows:
    
struct	ioc_vol
{
	u_char	vol[4];
	/* one for each channel */
};
    
    CDIOCSETMONOCDIOCSETSTEREOCDIOCSETMUTECDIOCSETLEFTCDIOCSETRIGHTCDIOCSETDEBUGCDIOCCLRDEBUGCDIOCPAUSECDIOCRESUMECDIOCRESETCDIOCSTARTCDIOCSTOPCDIOCALLOWCDIOCPREVENTCDIOCEJECTCDIOCLOADUNLOADCDIOCCLOSEDIOCTURIn addition the general
    scsi(4) ioctls may be used with
    the cd driver, if used against the `whole disk'
    partition (i.e. /dev/rcd0d for the bebox and i386
    port, /dev/rcd0c for all other ports).
cd
  driver, then the act of changing the media will invalidate the disklabel and
  information held within the kernel. To stop corruption, all accesses to the
  device will be discarded until there are no more open file descriptors
  referencing the device. During this period, all new open attempts will be
  rejected. When no more open file descriptors reference the device, the first
  next open will load a new set of parameters (including disklabel) for the
  drive.
The audio code in the cd driver only
    support SCSI-2 standard audio commands. Because many CD-ROM manufacturers
    have not followed the standard, there are many CD-ROM drives for which audio
    will not work. Some work is planned to support some of the more common
    `broken' CD-ROM drives; however, this is not yet under way.
cd driver appeared in 386BSD 0.1.
ioctl() were poorly chosen, and a number of spelling
  errors have survived in the names of the ioctl()
  commands.
| June 23, 2012 | NetBSD 10.0 |