# Summary of CDROM ioctl calls

_Peios Kernel / Userspace interfaces / System and device interfaces / ioctl conventions_

> Edward A. Falk <efalk@google.com>

> **Peios:** Linux capability names in this interface retain their API meaning, but KACS evaluates them through native token privileges or compatibility rules. UID 0, `setcap` and Unix mode bits do not independently grant native authority. Object access and PIP checks remain additional constraints where applicable. See [Peios kernel behaviour](</kernel/introduction/peios-behaviour.md>) for the mapping and exceptions.


<a id="rst-summary-of-cdrom-ioctl-calls"></a>

- Edward A. Falk &lt;[efalk@google.com](<mailto:efalk@google.com>)&gt;

November, 2004

This document attempts to describe the ioctl(2) calls supported by the CDROM layer.  These are by-and-large implemented (as of Linux 2.6) in drivers/cdrom/cdrom.c and drivers/block/scsi_ioctl.c

ioctl values are listed in &lt;linux/cdrom.h&gt;.  As of this writing, they are as follows:

>
> <table>
> <tbody>
> <tr>
> <td>
>
>
> CDROMPAUSE
>
> </td>
> <td>
>
>
> Pause Audio Operation
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMRESUME
>
> </td>
> <td>
>
>
> Resume paused Audio Operation
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMPLAYMSF
>
> </td>
> <td>
>
>
> Play Audio MSF (struct cdrom_msf)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMPLAYTRKIND
>
> </td>
> <td>
>
>
> Play Audio Track/index (struct cdrom_ti)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADTOCHDR
>
> </td>
> <td>
>
>
> Read TOC header (struct cdrom_tochdr)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADTOCENTRY
>
> </td>
> <td>
>
>
> Read TOC entry (struct cdrom_tocentry)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMSTOP
>
> </td>
> <td>
>
>
> Stop the cdrom drive
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMSTART
>
> </td>
> <td>
>
>
> Start the cdrom drive
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMEJECT
>
> </td>
> <td>
>
>
> Ejects the cdrom media
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMVOLCTRL
>
> </td>
> <td>
>
>
> Control output volume (struct cdrom_volctrl)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMSUBCHNL
>
> </td>
> <td>
>
>
> Read subchannel data (struct cdrom_subchnl)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADMODE2
>
> </td>
> <td>
>
>
> Read CDROM mode 2 data (2336 Bytes) (struct cdrom_read)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADMODE1
>
> </td>
> <td>
>
>
> Read CDROM mode 1 data (2048 Bytes) (struct cdrom_read)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADAUDIO
>
> </td>
> <td>
>
>
> (struct cdrom_read_audio)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMEJECT_SW
>
> </td>
> <td>
>
>
> enable(1)/disable(0) auto-ejecting
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMMULTISESSION
>
> </td>
> <td>
>
>
> Obtain the start-of-last-session address of multi session disks (struct cdrom_multisession)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_GET_MCN
>
> </td>
> <td>
>
>
> Obtain the "Universal Product Code" if available (struct cdrom_mcn)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_GET_UPC
>
> </td>
> <td>
>
>
> Deprecated, use CDROM_GET_MCN instead.
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMRESET
>
> </td>
> <td>
>
>
> hard-reset the drive
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMVOLREAD
>
> </td>
> <td>
>
>
> Get the drive's volume setting (struct cdrom_volctrl)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADRAW
>
> </td>
> <td>
>
>
> read data in raw mode (2352 Bytes) (struct cdrom_read)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADCOOKED
>
> </td>
> <td>
>
>
> read data in cooked mode
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMSEEK
>
> </td>
> <td>
>
>
> seek msf address
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMPLAYBLK
>
> </td>
> <td>
>
>
> scsi-cd only, (struct cdrom_blk)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMREADALL
>
> </td>
> <td>
>
>
> read all 2646 bytes
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMGETSPINDOWN
>
> </td>
> <td>
>
>
> return 4-bit spindown value
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMSETSPINDOWN
>
> </td>
> <td>
>
>
> set 4-bit spindown value
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMCLOSETRAY
>
> </td>
> <td>
>
>
> pendant of CDROMEJECT
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_SET_OPTIONS
>
> </td>
> <td>
>
>
> Set behavior options
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_CLEAR_OPTIONS
>
> </td>
> <td>
>
>
> Clear behavior options
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_SELECT_SPEED
>
> </td>
> <td>
>
>
> Set the CD-ROM speed
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_SELECT_DISC
>
> </td>
> <td>
>
>
> Select disc (for juke-boxes)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_MEDIA_CHANGED
>
> </td>
> <td>
>
>
> Check is media changed
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_TIMED_MEDIA_CHANGE
>
> </td>
> <td>
>
>
> Check if media changed since given time (struct cdrom_timed_media_change_info)
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_DRIVE_STATUS
>
> </td>
> <td>
>
>
> Get tray position, etc.
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_DISC_STATUS
>
> </td>
> <td>
>
>
> Get disc type, etc.
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_CHANGER_NSLOTS
>
> </td>
> <td>
>
>
> Get number of slots
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_LOCKDOOR
>
> </td>
> <td>
>
>
> lock or unlock door
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_DEBUG
>
> </td>
> <td>
>
>
> Turn debug messages on/off
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_GET_CAPABILITY
>
> </td>
> <td>
>
>
> get capabilities
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROMAUDIOBUFSIZ
>
> </td>
> <td>
>
>
> set the audio buffer size
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> DVD_READ_STRUCT
>
> </td>
> <td>
>
>
> Read structure
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> DVD_WRITE_STRUCT
>
> </td>
> <td>
>
>
> Write structure
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> DVD_AUTH
>
> </td>
> <td>
>
>
> Authentication
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_SEND_PACKET
>
> </td>
> <td>
>
>
> send a packet to the drive
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_NEXT_WRITABLE
>
> </td>
> <td>
>
>
> get next writable block
>
> </td>
> </tr>
> <tr>
> <td>
>
>
> CDROM_LAST_WRITTEN
>
> </td>
> <td>
>
>
> get last block written on disc
>
> </td>
> </tr>
> </tbody>
> </table>

The information that follows was determined from reading kernel source code.  It is likely that some corrections will be made over time.

---

General:

> Unless otherwise specified, all ioctl calls return 0 on success and -1 with errno set to an appropriate value on error.  (Some ioctls return non-negative data values.)
>
> Unless otherwise specified, all ioctl calls return -1 and set errno to EFAULT on a failed attempt to copy data to or from user address space.
>
> Individual drivers may return error codes not listed here.
>
> Unless otherwise specified, all data structures and constants are defined in &lt;linux/cdrom.h&gt;

---

- **CDROMPAUSE**

  Pause Audio Operation

  usage:



  ```text
  ioctl(fd, CDROMPAUSE, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

- **CDROMRESUME**

  Resume paused Audio Operation

  usage:



  ```text
  ioctl(fd, CDROMRESUME, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

- **CDROMPLAYMSF**

  Play Audio MSF

  (struct cdrom_msf)

  usage:



  ```text
  struct cdrom_msf msf;

  ioctl(fd, CDROMPLAYMSF, &msf);
  ```

  - **inputs:**

    cdrom_msf structure, describing a segment of music to play

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

  - **notes:**

    - MSF stands for minutes-seconds-frames

    - LBA stands for logical block address

    - Segment is described as start and end times, where each time is described as minutes:seconds:frames. A frame is 1/75 of a second.

- **CDROMPLAYTRKIND**

  Play Audio Track/index

  (struct cdrom_ti)

  usage:



  ```text
  struct cdrom_ti ti;

  ioctl(fd, CDROMPLAYTRKIND, &ti);
  ```

  - **inputs:**

    cdrom_ti structure, describing a segment of music to play

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

  - **notes:**

    - Segment is described as start and end times, where each time is described as a track and an index.

- **CDROMREADTOCHDR**

  Read TOC header

  (struct cdrom_tochdr)

  usage:



  ```text
  cdrom_tochdr header;

  ioctl(fd, CDROMREADTOCHDR, &header);
  ```

  - **inputs:**

    cdrom_tochdr structure

  - **outputs:**

    cdrom_tochdr structure

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

- **CDROMREADTOCENTRY**

  Read TOC entry

  (struct cdrom_tocentry)

  usage:



  ```text
  struct cdrom_tocentry entry;

  ioctl(fd, CDROMREADTOCENTRY, &entry);
  ```

  - **inputs:**

    cdrom_tocentry structure

  - **outputs:**

    cdrom_tocentry structure

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

    - EINVAL      entry.cdte_format not CDROM_MSF or CDROM_LBA

    - EINVAL      requested track out of bounds

    - EIO         I/O error reading TOC

  - **notes:**

    - TOC stands for Table Of Contents

    - MSF stands for minutes-seconds-frames

    - LBA stands for logical block address

- **CDROMSTOP**

  Stop the cdrom drive

  usage:



  ```text
  ioctl(fd, CDROMSTOP, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

  - **notes:**

    - Exact interpretation of this ioctl depends on the device, but most seem to spin the drive down.

- **CDROMSTART**

  Start the cdrom drive

  usage:



  ```text
  ioctl(fd, CDROMSTART, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

  - **notes:**

    - Exact interpretation of this ioctl depends on the device, but most seem to spin the drive up and/or close the tray. Other devices ignore the ioctl completely.

- **CDROMEJECT**

  - Ejects the cdrom media

  usage:



  ```text
  ioctl(fd, CDROMEJECT, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    none

  - **error returns:**

    - ENOSYS      cd drive not capable of ejecting

    - EBUSY       other processes are accessing drive, or door is locked

  - **notes:**

    - See CDROM_LOCKDOOR, below.

- **CDROMCLOSETRAY**

  pendant of CDROMEJECT

  usage:



  ```text
  ioctl(fd, CDROMCLOSETRAY, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    none

  - **error returns:**

    - ENOSYS      cd drive not capable of closing the tray

    - EBUSY       other processes are accessing drive, or door is locked

  - **notes:**

    - See CDROM_LOCKDOOR, below.

- **CDROMVOLCTRL**

  Control output volume (struct cdrom_volctrl)

  usage:



  ```text
  struct cdrom_volctrl volume;

  ioctl(fd, CDROMVOLCTRL, &volume);
  ```

  - **inputs:**

    cdrom_volctrl structure containing volumes for up to 4 channels.

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

- **CDROMVOLREAD**

  Get the drive's volume setting

  (struct cdrom_volctrl)

  usage:



  ```text
  struct cdrom_volctrl volume;

  ioctl(fd, CDROMVOLREAD, &volume);
  ```

  - **inputs:**

    none

  - **outputs:**

    The current volume settings.

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

- **CDROMSUBCHNL**

  Read subchannel data

  (struct cdrom_subchnl)

  usage:



  ```text
  struct cdrom_subchnl q;

  ioctl(fd, CDROMSUBCHNL, &q);
  ```

  - **inputs:**

    cdrom_subchnl structure

  - **outputs:**

    cdrom_subchnl structure

  - **error return:**

    - ENOSYS      cd drive not audio-capable.

    - EINVAL      format not CDROM_MSF or CDROM_LBA

  - **notes:**

    - Format is converted to CDROM_MSF or CDROM_LBA as per user request on return

- **CDROMREADRAW**

  read data in raw mode (2352 Bytes)

  (struct cdrom_read)

  usage:



  ```text
  union {

    struct cdrom_msf msf;               /* input */
    char buffer[CD_FRAMESIZE_RAW];      /* return */
  } arg;
  ioctl(fd, CDROMREADRAW, &arg);
  ```

  - **inputs:**

    cdrom_msf structure indicating an address to read.

    Only the start values are significant.

  - **outputs:**

    Data written to address provided by user.

  - **error return:**

    - EINVAL      address less than 0, or msf less than 0:2:0

    - ENOMEM      out of memory

  - **notes:**

    - As of 2.6.8.1, comments in &lt;linux/cdrom.h&gt; indicate that this ioctl accepts a cdrom_read structure, but actual source code reads a cdrom_msf structure and writes a buffer of data to the same address.

    - MSF values are converted to LBA values via this formula:



      ```text
      lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;
      ```

- **CDROMREADMODE1**

  Read CDROM mode 1 data (2048 Bytes)

  (struct cdrom_read)

  - **notes:**

    Identical to CDROMREADRAW except that block size is CD_FRAMESIZE (2048) bytes

- **CDROMREADMODE2**

  Read CDROM mode 2 data (2336 Bytes)

  (struct cdrom_read)

  - **notes:**

    Identical to CDROMREADRAW except that block size is CD_FRAMESIZE_RAW0 (2336) bytes

- **CDROMREADAUDIO**

  (struct cdrom_read_audio)

  usage:



  ```text
  struct cdrom_read_audio ra;

  ioctl(fd, CDROMREADAUDIO, &ra);
  ```

  - **inputs:**

    cdrom_read_audio structure containing read start point and length

  - **outputs:**

    audio data, returned to buffer indicated by ra

  - **error return:**

    - EINVAL      format not CDROM_MSF or CDROM_LBA

    - EINVAL      nframes not in range \[1 75\]

    - ENXIO       drive has no queue (probably means invalid fd)

    - ENOMEM      out of memory

- **CDROMEJECT_SW**

  enable(1)/disable(0) auto-ejecting

  usage:



  ```text
  int val;

  ioctl(fd, CDROMEJECT_SW, val);
  ```

  - **inputs:**

    Flag specifying auto-eject flag.

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      Drive is not capable of ejecting.

    - EBUSY       Door is locked

- **CDROMMULTISESSION**

  Obtain the start-of-last-session address of multi session disks

  (struct cdrom_multisession)

  usage:



  ```text
  struct cdrom_multisession ms_info;

  ioctl(fd, CDROMMULTISESSION, &ms_info);
  ```

  - **inputs:**

    > cdrom_multisession structure containing desired

    format.

  - **outputs:**

    cdrom_multisession structure is filled with last_session information.

  - **error return:**

    - EINVAL      format not CDROM_MSF or CDROM_LBA

- **CDROM_GET_MCN**

  Obtain the "Universal Product Code" if available

  (struct cdrom_mcn)

  usage:



  ```text
  struct cdrom_mcn mcn;

  ioctl(fd, CDROM_GET_MCN, &mcn);
  ```

  - **inputs:**

    none

  - **outputs:**

    Universal Product Code

  - **error return:**

    - ENOSYS      Drive is not capable of reading MCN data.

  - **notes:**

    - Source code comments state:



      ```text
      The following function is implemented, although very few
      audio discs give Universal Product Code information, which
      should just be the Medium Catalog Number on the box.  Note,
      that the way the code is written on the CD is /not/ uniform
      across all discs!
      ```

- **CDROM_GET_UPC**

  CDROM_GET_MCN  (deprecated)

  Not implemented, as of 2.6.8.1

- **CDROMRESET**

  hard-reset the drive

  usage:



  ```text
  ioctl(fd, CDROMRESET, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    none

  - **error return:**

    - EACCES      Access denied:  requires CAP_SYS_ADMIN

    - ENOSYS      Drive is not capable of resetting.

- **CDROMREADCOOKED**

  read data in cooked mode

  usage:



  ```text
  u8 buffer[CD_FRAMESIZE]

  ioctl(fd, CDROMREADCOOKED, buffer);
  ```

  - **inputs:**

    none

  - **outputs:**

    2048 bytes of data, "cooked" mode.

  - **notes:**

    Not implemented on all drives.

- **CDROMREADALL**

  read all 2646 bytes

  Same as CDROMREADCOOKED, but reads 2646 bytes.

- **CDROMSEEK**

  seek msf address

  usage:



  ```text
  struct cdrom_msf msf;

  ioctl(fd, CDROMSEEK, &msf);
  ```

  - **inputs:**

    MSF address to seek to.

  - **outputs:**

    none

- **CDROMPLAYBLK**

  scsi-cd only

  (struct cdrom_blk)

  usage:



  ```text
  struct cdrom_blk blk;

  ioctl(fd, CDROMPLAYBLK, &blk);
  ```

  - **inputs:**

    Region to play

  - **outputs:**

    none

- **CDROMGETSPINDOWN**

  Obsolete, was ide-cd only

  usage:



  ```text
  char spindown;

  ioctl(fd, CDROMGETSPINDOWN, &spindown);
  ```

  - **inputs:**

    none

  - **outputs:**

    The value of the current 4-bit spindown value.

- **CDROMSETSPINDOWN**

  Obsolete, was ide-cd only

  usage:



  ```text
  char spindown

  ioctl(fd, CDROMSETSPINDOWN, &spindown);
  ```

  - **inputs:**

    4-bit value used to control spindown (TODO: more detail here)

  - **outputs:**

    none

- **CDROM_SET_OPTIONS**

  Set behavior options

  usage:



  ```text
  int options;

  ioctl(fd, CDROM_SET_OPTIONS, options);
  ```

  - **inputs:**

    > New values for drive options.  The logical 'or' of:


    <table>
    <tbody>
    <tr>
    <td>


    CDO_AUTO_CLOSE

    </td>
    <td>


    close tray on first open(2)

    </td>
    </tr>
    <tr>
    <td>


    CDO_AUTO_EJECT

    </td>
    <td>


    open tray on last release

    </td>
    </tr>
    <tr>
    <td>


    CDO_USE_FFLAGS

    </td>
    <td>


    use O_NONBLOCK information on open

    </td>
    </tr>
    <tr>
    <td>


    CDO_LOCK

    </td>
    <td>


    lock tray on open files

    </td>
    </tr>
    <tr>
    <td>


    CDO_CHECK_TYPE

    </td>
    <td>


    check type on open for data

    </td>
    </tr>
    </tbody>
    </table>

  - **outputs:**

    Returns the resulting options settings in the ioctl return value.  Returns -1 on error.

  - **error return:**

    - ENOSYS      selected option(s) not supported by drive.

- **CDROM_CLEAR_OPTIONS**

  Clear behavior options

  Same as CDROM_SET_OPTIONS, except that selected options are turned off.

- **CDROM_SELECT_SPEED**

  Set the CD-ROM speed

  usage:



  ```text
  int speed;

  ioctl(fd, CDROM_SELECT_SPEED, speed);
  ```

  - **inputs:**

    New drive speed.

  - **outputs:**

    none

  - **error return:**

    - ENOSYS      speed selection not supported by drive.

- **CDROM_SELECT_DISC**

  Select disc (for juke-boxes)

  usage:



  ```text
  int disk;

  ioctl(fd, CDROM_SELECT_DISC, disk);
  ```

  - **inputs:**

    Disk to load into drive.

  - **outputs:**

    none

  - **error return:**

    - EINVAL      Disk number beyond capacity of drive

- **CDROM_MEDIA_CHANGED**

  Check is media changed

  usage:



  ```text
  int slot;

  ioctl(fd, CDROM_MEDIA_CHANGED, slot);
  ```

  - **inputs:**

    Slot number to be tested, always zero except for jukeboxes.

    May also be special values CDSL_NONE or CDSL_CURRENT

  - **outputs:**

    > Ioctl return value is 0 or 1 depending on whether the media

    has been changed, or -1 on error.

  - **error returns:**

    - ENOSYS      Drive can't detect media change

    - EINVAL      Slot number beyond capacity of drive

    - ENOMEM      Out of memory

- **CDROM_DRIVE_STATUS**

  Get tray position, etc.

  usage:



  ```text
  int slot;

  ioctl(fd, CDROM_DRIVE_STATUS, slot);
  ```

  - **inputs:**

    Slot number to be tested, always zero except for jukeboxes.

    May also be special values CDSL_NONE or CDSL_CURRENT

  - **outputs:**

    > Ioctl return value will be one of the following values

    from &lt;linux/cdrom.h&gt;:

    >
    > <table>
    > <tbody>
    > <tr>
    > <td>
    >
    >
    > CDS_NO_INFO
    >
    > </td>
    > <td>
    >
    >
    > Information not available.
    >
    > </td>
    > </tr>
    > <tr>
    > <td>
    >
    >
    > CDS_NO_DISC
    >
    > </td>
    > <td>
    >
    >
    >
    >
    > </td>
    > </tr>
    > <tr>
    > <td>
    >
    >
    > CDS_TRAY_OPEN
    >
    > </td>
    > <td>
    >
    >
    >
    >
    > </td>
    > </tr>
    > <tr>
    > <td>
    >
    >
    > CDS_DRIVE_NOT_READY
    >
    > </td>
    > <td>
    >
    >
    >
    >
    > </td>
    > </tr>
    > <tr>
    > <td>
    >
    >
    > CDS_DISC_OK
    >
    > </td>
    > <td>
    >
    >
    >
    >
    > </td>
    > </tr>
    > <tr>
    > <td>
    >
    >
    > -1
    >
    > </td>
    > <td>
    >
    >
    > error
    >
    > </td>
    > </tr>
    > </tbody>
    > </table>

  - **error returns:**

    - ENOSYS      Drive can't detect drive status

    - EINVAL      Slot number beyond capacity of drive

    - ENOMEM      Out of memory

- **CDROM_DISC_STATUS**

  Get disc type, etc.

  usage:



  ```text
  ioctl(fd, CDROM_DISC_STATUS, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    > Ioctl return value will be one of the following values

    from &lt;linux/cdrom.h&gt;:

    > - CDS_NO_INFO
    >
    > - CDS_AUDIO
    >
    > - CDS_MIXED
    >
    > - CDS_XA_2_2
    >
    > - CDS_XA_2_1
    >
    > - CDS_DATA_1

  - **error returns:**

    none at present

  - **notes:**

    - Source code comments state:



      ```text
      Ok, this is where problems start.  The current interface for
      the CDROM_DISC_STATUS ioctl is flawed.  It makes the false
      assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc.
      Unfortunately, while this is often the case, it is also
      very common for CDs to have some tracks with data, and some
      tracks with audio.      Just because I feel like it, I declare
      the following to be the best way to cope.  If the CD has
      ANY data tracks on it, it will be returned as a data CD.
      If it has any XA tracks, I will return it as that.      Now I
      could simplify this interface by combining these returns with
      the above, but this more clearly demonstrates the problem
      with the current interface.  Too bad this wasn't designed
      to use bitmasks...             -Erik

      Well, now we have the option CDS_MIXED: a mixed-type CD.
      User level programmers might feel the ioctl is not very
      useful.
                      ---david
      ```

- **CDROM_CHANGER_NSLOTS**

  Get number of slots

  usage:



  ```text
  ioctl(fd, CDROM_CHANGER_NSLOTS, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    The ioctl return value will be the number of slots in a CD changer.  Typically 1 for non-multi-disk devices.

  - **error returns:**

    none

- **CDROM_LOCKDOOR**

  lock or unlock door

  usage:



  ```text
  int lock;

  ioctl(fd, CDROM_LOCKDOOR, lock);
  ```

  - **inputs:**

    Door lock flag, 1=lock, 0=unlock

  - **outputs:**

    none

  - **error returns:**

    - EDRIVE_CANT_DO_THIS

      > Door lock function not supported.

    - EBUSY

      > Attempt to unlock when multiple users have the drive open and not CAP_SYS_ADMIN

  - **notes:**

    As of 2.6.8.1, the lock flag is a global lock, meaning that all CD drives will be locked or unlocked together.  This is probably a bug.

    The EDRIVE_CANT_DO_THIS value is defined in &lt;linux/cdrom.h&gt; and is currently (2.6.8.1) the same as EOPNOTSUPP

- **CDROM_DEBUG**

  Turn debug messages on/off

  usage:



  ```text
  int debug;

  ioctl(fd, CDROM_DEBUG, debug);
  ```

  - **inputs:**

    Cdrom debug flag, 0=disable, 1=enable

  - **outputs:**

    The ioctl return value will be the new debug flag.

  - **error return:**

    - EACCES      Access denied:  requires CAP_SYS_ADMIN

- **CDROM_GET_CAPABILITY**

  get capabilities

  usage:



  ```text
  ioctl(fd, CDROM_GET_CAPABILITY, 0);
  ```

  - **inputs:**

    none

  - **outputs:**

    The ioctl return value is the current device capability flags.  See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc.

- **CDROMAUDIOBUFSIZ**

  set the audio buffer size

  usage:



  ```text
  int arg;

  ioctl(fd, CDROMAUDIOBUFSIZ, val);
  ```

  - **inputs:**

    New audio buffer size

  - **outputs:**

    The ioctl return value is the new audio buffer size, or -1 on error.

  - **error return:**

    - ENOSYS      Not supported by this driver.

  - **notes:**

    Not supported by all drivers.

DVD_READ_STRUCT                 Read structure

> usage:
>
>
>
> ```text
> dvd_struct s;
>
> ioctl(fd, DVD_READ_STRUCT, &s);
> ```
>
> - **inputs:**
>
>   > dvd_struct structure, containing:
>
>
>   <table>
>   <tbody>
>   <tr>
>   <td>
>
>
>   type
>
>   </td>
>   <td>
>
>
>   specifies the information desired, one of DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT, DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA, DVD_STRUCT_MANUFACT
>
>   </td>
>   </tr>
>   <tr>
>   <td>
>
>
>   physical.layer_num
>
>   </td>
>   <td>
>
>
>   desired layer, indexed from 0
>
>   </td>
>   </tr>
>   <tr>
>   <td>
>
>
>   copyright.layer_num
>
>   </td>
>   <td>
>
>
>   desired layer, indexed from 0
>
>   </td>
>   </tr>
>   <tr>
>   <td>
>
>
>   disckey.agid
>
>   </td>
>   <td>
>
>
>
>
>   </td>
>   </tr>
>   </tbody>
>   </table>
>
> - **outputs:**
>
>   > dvd_struct structure, containing:
>
>
>   <table>
>   <tbody>
>   <tr>
>   <td>
>
>
>   physical
>
>   </td>
>   <td>
>
>
>   for type == DVD_STRUCT_PHYSICAL
>
>   </td>
>   </tr>
>   <tr>
>   <td>
>
>
>   copyright
>
>   </td>
>   <td>
>
>
>   for type == DVD_STRUCT_COPYRIGHT
>
>   </td>
>   </tr>
>   <tr>
>   <td>
>
>
>   disckey.value
>
>   </td>
>   <td>
>
>
>   for type == DVD_STRUCT_DISCKEY
>
>   </td>
>   </tr>
>   <tr>
>   <td>
>
>
>   bca.\{len,value\}
>
>   </td>
>   <td>
>
>
>   for type == DVD_STRUCT_BCA
>
>   </td>
>   </tr>
>   <tr>
>   <td>
>
>
>   manufact.\{len,valu\}
>
>   </td>
>   <td>
>
>
>   for type == DVD_STRUCT_MANUFACT
>
>   </td>
>   </tr>
>   </tbody>
>   </table>
>
> - **error returns:**
>
>   - EINVAL      physical.layer_num exceeds number of layers
>
>   - EIO         Received invalid response from drive

DVD_WRITE_STRUCT                Write structure

> Not implemented, as of 2.6.8.1

DVD_AUTH                        Authentication

> usage:
>
>
>
> ```text
> dvd_authinfo ai;
>
> ioctl(fd, DVD_AUTH, &ai);
> ```
>
> - **inputs:**
>
>   dvd_authinfo structure.  See &lt;linux/cdrom.h&gt;
>
> - **outputs:**
>
>   dvd_authinfo structure.
>
> - **error return:**
>
>   - ENOTTY      ai.type not recognized.

- **CDROM_SEND_PACKET**

  send a packet to the drive

  usage:



  ```text
  struct cdrom_generic_command cgc;

  ioctl(fd, CDROM_SEND_PACKET, &cgc);
  ```

  - **inputs:**

    cdrom_generic_command structure containing the packet to send.

  - **outputs:**

    > none

    cdrom_generic_command structure containing results.

  - **error return:**

    - EIO

      > command failed.

    - EPERM

      > Operation not permitted, either because a write command was attempted on a drive which is opened read-only, or because the command requires CAP_SYS_RAWIO

    - EINVAL

      > cgc.data_direction not set

- **CDROM_NEXT_WRITABLE**

  get next writable block

  usage:



  ```text
  long next;

  ioctl(fd, CDROM_NEXT_WRITABLE, &next);
  ```

  - **inputs:**

    none

  - **outputs:**

    The next writable block.

  - **notes:**

    > If the device does not support this ioctl directly, the

    ioctl will return CDROM_LAST_WRITTEN + 7.

- **CDROM_LAST_WRITTEN**

  get last block written on disc

  usage:



  ```text
  long last;

  ioctl(fd, CDROM_LAST_WRITTEN, &last);
  ```

  - **inputs:**

    none

  - **outputs:**

    The last block written on disc

  - **notes:**

    If the device does not support this ioctl directly, the result is derived from the disc's table of contents.  If the table of contents can't be read, this ioctl returns an error.
