Back to home page

OSCL-LXR

 
 

    


0001 ============================
0002 Summary of CDROM ioctl calls
0003 ============================
0004 
0005 - Edward A. Falk <efalk@google.com>
0006 
0007 November, 2004
0008 
0009 This document attempts to describe the ioctl(2) calls supported by
0010 the CDROM layer.  These are by-and-large implemented (as of Linux 2.6)
0011 in drivers/cdrom/cdrom.c and drivers/block/scsi_ioctl.c
0012 
0013 ioctl values are listed in <linux/cdrom.h>.  As of this writing, they
0014 are as follows:
0015 
0016         ========================  ===============================================
0017         CDROMPAUSE                Pause Audio Operation
0018         CDROMRESUME               Resume paused Audio Operation
0019         CDROMPLAYMSF              Play Audio MSF (struct cdrom_msf)
0020         CDROMPLAYTRKIND           Play Audio Track/index (struct cdrom_ti)
0021         CDROMREADTOCHDR           Read TOC header (struct cdrom_tochdr)
0022         CDROMREADTOCENTRY         Read TOC entry (struct cdrom_tocentry)
0023         CDROMSTOP                 Stop the cdrom drive
0024         CDROMSTART                Start the cdrom drive
0025         CDROMEJECT                Ejects the cdrom media
0026         CDROMVOLCTRL              Control output volume (struct cdrom_volctrl)
0027         CDROMSUBCHNL              Read subchannel data (struct cdrom_subchnl)
0028         CDROMREADMODE2            Read CDROM mode 2 data (2336 Bytes)
0029                                   (struct cdrom_read)
0030         CDROMREADMODE1            Read CDROM mode 1 data (2048 Bytes)
0031                                   (struct cdrom_read)
0032         CDROMREADAUDIO            (struct cdrom_read_audio)
0033         CDROMEJECT_SW             enable(1)/disable(0) auto-ejecting
0034         CDROMMULTISESSION         Obtain the start-of-last-session
0035                                   address of multi session disks
0036                                   (struct cdrom_multisession)
0037         CDROM_GET_MCN             Obtain the "Universal Product Code"
0038                                   if available (struct cdrom_mcn)
0039         CDROM_GET_UPC             Deprecated, use CDROM_GET_MCN instead.
0040         CDROMRESET                hard-reset the drive
0041         CDROMVOLREAD              Get the drive's volume setting
0042                                   (struct cdrom_volctrl)
0043         CDROMREADRAW              read data in raw mode (2352 Bytes)
0044                                   (struct cdrom_read)
0045         CDROMREADCOOKED           read data in cooked mode
0046         CDROMSEEK                 seek msf address
0047         CDROMPLAYBLK              scsi-cd only, (struct cdrom_blk)
0048         CDROMREADALL              read all 2646 bytes
0049         CDROMGETSPINDOWN          return 4-bit spindown value
0050         CDROMSETSPINDOWN          set 4-bit spindown value
0051         CDROMCLOSETRAY            pendant of CDROMEJECT
0052         CDROM_SET_OPTIONS         Set behavior options
0053         CDROM_CLEAR_OPTIONS       Clear behavior options
0054         CDROM_SELECT_SPEED        Set the CD-ROM speed
0055         CDROM_SELECT_DISC         Select disc (for juke-boxes)
0056         CDROM_MEDIA_CHANGED       Check is media changed
0057         CDROM_TIMED_MEDIA_CHANGE  Check if media changed
0058                                   since given time
0059                                   (struct cdrom_timed_media_change_info)
0060         CDROM_DRIVE_STATUS        Get tray position, etc.
0061         CDROM_DISC_STATUS         Get disc type, etc.
0062         CDROM_CHANGER_NSLOTS      Get number of slots
0063         CDROM_LOCKDOOR            lock or unlock door
0064         CDROM_DEBUG               Turn debug messages on/off
0065         CDROM_GET_CAPABILITY      get capabilities
0066         CDROMAUDIOBUFSIZ          set the audio buffer size
0067         DVD_READ_STRUCT           Read structure
0068         DVD_WRITE_STRUCT          Write structure
0069         DVD_AUTH                  Authentication
0070         CDROM_SEND_PACKET         send a packet to the drive
0071         CDROM_NEXT_WRITABLE       get next writable block
0072         CDROM_LAST_WRITTEN        get last block written on disc
0073         ========================  ===============================================
0074 
0075 
0076 The information that follows was determined from reading kernel source
0077 code.  It is likely that some corrections will be made over time.
0078 
0079 ------------------------------------------------------------------------------
0080 
0081 General:
0082 
0083         Unless otherwise specified, all ioctl calls return 0 on success
0084         and -1 with errno set to an appropriate value on error.  (Some
0085         ioctls return non-negative data values.)
0086 
0087         Unless otherwise specified, all ioctl calls return -1 and set
0088         errno to EFAULT on a failed attempt to copy data to or from user
0089         address space.
0090 
0091         Individual drivers may return error codes not listed here.
0092 
0093         Unless otherwise specified, all data structures and constants
0094         are defined in <linux/cdrom.h>
0095 
0096 ------------------------------------------------------------------------------
0097 
0098 
0099 CDROMPAUSE
0100         Pause Audio Operation
0101 
0102 
0103         usage::
0104 
0105           ioctl(fd, CDROMPAUSE, 0);
0106 
0107 
0108         inputs:
0109                 none
0110 
0111 
0112         outputs:
0113                 none
0114 
0115 
0116         error return:
0117           - ENOSYS      cd drive not audio-capable.
0118 
0119 
0120 CDROMRESUME
0121         Resume paused Audio Operation
0122 
0123 
0124         usage::
0125 
0126           ioctl(fd, CDROMRESUME, 0);
0127 
0128 
0129         inputs:
0130                 none
0131 
0132 
0133         outputs:
0134                 none
0135 
0136 
0137         error return:
0138           - ENOSYS      cd drive not audio-capable.
0139 
0140 
0141 CDROMPLAYMSF
0142         Play Audio MSF
0143 
0144         (struct cdrom_msf)
0145 
0146 
0147         usage::
0148 
0149           struct cdrom_msf msf;
0150 
0151           ioctl(fd, CDROMPLAYMSF, &msf);
0152 
0153         inputs:
0154                 cdrom_msf structure, describing a segment of music to play
0155 
0156 
0157         outputs:
0158                 none
0159 
0160 
0161         error return:
0162           - ENOSYS      cd drive not audio-capable.
0163 
0164         notes:
0165                 - MSF stands for minutes-seconds-frames
0166                 - LBA stands for logical block address
0167                 - Segment is described as start and end times, where each time
0168                   is described as minutes:seconds:frames.
0169                   A frame is 1/75 of a second.
0170 
0171 
0172 CDROMPLAYTRKIND
0173         Play Audio Track/index
0174 
0175         (struct cdrom_ti)
0176 
0177 
0178         usage::
0179 
0180           struct cdrom_ti ti;
0181 
0182           ioctl(fd, CDROMPLAYTRKIND, &ti);
0183 
0184         inputs:
0185                 cdrom_ti structure, describing a segment of music to play
0186 
0187 
0188         outputs:
0189                 none
0190 
0191 
0192         error return:
0193           - ENOSYS      cd drive not audio-capable.
0194 
0195         notes:
0196                 - Segment is described as start and end times, where each time
0197                   is described as a track and an index.
0198 
0199 
0200 
0201 CDROMREADTOCHDR
0202         Read TOC header
0203 
0204         (struct cdrom_tochdr)
0205 
0206 
0207         usage::
0208 
0209           cdrom_tochdr header;
0210 
0211           ioctl(fd, CDROMREADTOCHDR, &header);
0212 
0213         inputs:
0214                 cdrom_tochdr structure
0215 
0216 
0217         outputs:
0218                 cdrom_tochdr structure
0219 
0220 
0221         error return:
0222           - ENOSYS      cd drive not audio-capable.
0223 
0224 
0225 
0226 CDROMREADTOCENTRY
0227         Read TOC entry
0228 
0229         (struct cdrom_tocentry)
0230 
0231 
0232         usage::
0233 
0234           struct cdrom_tocentry entry;
0235 
0236           ioctl(fd, CDROMREADTOCENTRY, &entry);
0237 
0238         inputs:
0239                 cdrom_tocentry structure
0240 
0241 
0242         outputs:
0243                 cdrom_tocentry structure
0244 
0245 
0246         error return:
0247           - ENOSYS      cd drive not audio-capable.
0248           - EINVAL      entry.cdte_format not CDROM_MSF or CDROM_LBA
0249           - EINVAL      requested track out of bounds
0250           - EIO         I/O error reading TOC
0251 
0252         notes:
0253                 - TOC stands for Table Of Contents
0254                 - MSF stands for minutes-seconds-frames
0255                 - LBA stands for logical block address
0256 
0257 
0258 
0259 CDROMSTOP
0260         Stop the cdrom drive
0261 
0262 
0263         usage::
0264 
0265           ioctl(fd, CDROMSTOP, 0);
0266 
0267 
0268         inputs:
0269                 none
0270 
0271 
0272         outputs:
0273                 none
0274 
0275 
0276         error return:
0277           - ENOSYS      cd drive not audio-capable.
0278 
0279         notes:
0280           - Exact interpretation of this ioctl depends on the device,
0281             but most seem to spin the drive down.
0282 
0283 
0284 CDROMSTART
0285         Start the cdrom drive
0286 
0287 
0288         usage::
0289 
0290           ioctl(fd, CDROMSTART, 0);
0291 
0292 
0293         inputs:
0294                 none
0295 
0296 
0297         outputs:
0298                 none
0299 
0300 
0301         error return:
0302           - ENOSYS      cd drive not audio-capable.
0303 
0304         notes:
0305           - Exact interpretation of this ioctl depends on the device,
0306             but most seem to spin the drive up and/or close the tray.
0307             Other devices ignore the ioctl completely.
0308 
0309 
0310 CDROMEJECT
0311         - Ejects the cdrom media
0312 
0313 
0314         usage::
0315 
0316           ioctl(fd, CDROMEJECT, 0);
0317 
0318 
0319         inputs:
0320                 none
0321 
0322 
0323         outputs:
0324                 none
0325 
0326 
0327         error returns:
0328           - ENOSYS      cd drive not capable of ejecting
0329           - EBUSY       other processes are accessing drive, or door is locked
0330 
0331         notes:
0332                 - See CDROM_LOCKDOOR, below.
0333 
0334 
0335 
0336 
0337 CDROMCLOSETRAY
0338         pendant of CDROMEJECT
0339 
0340 
0341         usage::
0342 
0343           ioctl(fd, CDROMCLOSETRAY, 0);
0344 
0345 
0346         inputs:
0347                 none
0348 
0349 
0350         outputs:
0351                 none
0352 
0353 
0354         error returns:
0355           - ENOSYS      cd drive not capable of closing the tray
0356           - EBUSY       other processes are accessing drive, or door is locked
0357 
0358         notes:
0359                 - See CDROM_LOCKDOOR, below.
0360 
0361 
0362 
0363 
0364 CDROMVOLCTRL
0365         Control output volume (struct cdrom_volctrl)
0366 
0367 
0368         usage::
0369 
0370           struct cdrom_volctrl volume;
0371 
0372           ioctl(fd, CDROMVOLCTRL, &volume);
0373 
0374         inputs:
0375                 cdrom_volctrl structure containing volumes for up to 4
0376                 channels.
0377 
0378         outputs:
0379                 none
0380 
0381 
0382         error return:
0383           - ENOSYS      cd drive not audio-capable.
0384 
0385 
0386 
0387 CDROMVOLREAD
0388         Get the drive's volume setting
0389 
0390         (struct cdrom_volctrl)
0391 
0392 
0393         usage::
0394 
0395           struct cdrom_volctrl volume;
0396 
0397           ioctl(fd, CDROMVOLREAD, &volume);
0398 
0399         inputs:
0400                 none
0401 
0402 
0403         outputs:
0404                 The current volume settings.
0405 
0406 
0407         error return:
0408           - ENOSYS      cd drive not audio-capable.
0409 
0410 
0411 
0412 CDROMSUBCHNL
0413         Read subchannel data
0414 
0415         (struct cdrom_subchnl)
0416 
0417 
0418         usage::
0419 
0420           struct cdrom_subchnl q;
0421 
0422           ioctl(fd, CDROMSUBCHNL, &q);
0423 
0424         inputs:
0425                 cdrom_subchnl structure
0426 
0427 
0428         outputs:
0429                 cdrom_subchnl structure
0430 
0431 
0432         error return:
0433           - ENOSYS      cd drive not audio-capable.
0434           - EINVAL      format not CDROM_MSF or CDROM_LBA
0435 
0436         notes:
0437                 - Format is converted to CDROM_MSF or CDROM_LBA
0438                   as per user request on return
0439 
0440 
0441 
0442 CDROMREADRAW
0443         read data in raw mode (2352 Bytes)
0444 
0445         (struct cdrom_read)
0446 
0447         usage::
0448 
0449           union {
0450 
0451             struct cdrom_msf msf;               /* input */
0452             char buffer[CD_FRAMESIZE_RAW];      /* return */
0453           } arg;
0454           ioctl(fd, CDROMREADRAW, &arg);
0455 
0456         inputs:
0457                 cdrom_msf structure indicating an address to read.
0458 
0459                 Only the start values are significant.
0460 
0461         outputs:
0462                 Data written to address provided by user.
0463 
0464 
0465         error return:
0466           - EINVAL      address less than 0, or msf less than 0:2:0
0467           - ENOMEM      out of memory
0468 
0469         notes:
0470                 - As of 2.6.8.1, comments in <linux/cdrom.h> indicate that this
0471                   ioctl accepts a cdrom_read structure, but actual source code
0472                   reads a cdrom_msf structure and writes a buffer of data to
0473                   the same address.
0474 
0475                 - MSF values are converted to LBA values via this formula::
0476 
0477                     lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;
0478 
0479 
0480 
0481 
0482 CDROMREADMODE1
0483         Read CDROM mode 1 data (2048 Bytes)
0484 
0485         (struct cdrom_read)
0486 
0487         notes:
0488                 Identical to CDROMREADRAW except that block size is
0489                 CD_FRAMESIZE (2048) bytes
0490 
0491 
0492 
0493 CDROMREADMODE2
0494         Read CDROM mode 2 data (2336 Bytes)
0495 
0496         (struct cdrom_read)
0497 
0498         notes:
0499                 Identical to CDROMREADRAW except that block size is
0500                 CD_FRAMESIZE_RAW0 (2336) bytes
0501 
0502 
0503 
0504 CDROMREADAUDIO
0505         (struct cdrom_read_audio)
0506 
0507         usage::
0508 
0509           struct cdrom_read_audio ra;
0510 
0511           ioctl(fd, CDROMREADAUDIO, &ra);
0512 
0513         inputs:
0514                 cdrom_read_audio structure containing read start
0515                 point and length
0516 
0517         outputs:
0518                 audio data, returned to buffer indicated by ra
0519 
0520 
0521         error return:
0522           - EINVAL      format not CDROM_MSF or CDROM_LBA
0523           - EINVAL      nframes not in range [1 75]
0524           - ENXIO       drive has no queue (probably means invalid fd)
0525           - ENOMEM      out of memory
0526 
0527 
0528 CDROMEJECT_SW
0529         enable(1)/disable(0) auto-ejecting
0530 
0531 
0532         usage::
0533 
0534           int val;
0535 
0536           ioctl(fd, CDROMEJECT_SW, val);
0537 
0538         inputs:
0539                 Flag specifying auto-eject flag.
0540 
0541 
0542         outputs:
0543                 none
0544 
0545 
0546         error return:
0547           - ENOSYS      Drive is not capable of ejecting.
0548           - EBUSY       Door is locked
0549 
0550 
0551 
0552 
0553 CDROMMULTISESSION
0554         Obtain the start-of-last-session address of multi session disks
0555 
0556         (struct cdrom_multisession)
0557 
0558         usage::
0559 
0560           struct cdrom_multisession ms_info;
0561 
0562           ioctl(fd, CDROMMULTISESSION, &ms_info);
0563 
0564         inputs:
0565                 cdrom_multisession structure containing desired
0566 
0567           format.
0568 
0569         outputs:
0570                 cdrom_multisession structure is filled with last_session
0571                 information.
0572 
0573         error return:
0574           - EINVAL      format not CDROM_MSF or CDROM_LBA
0575 
0576 
0577 CDROM_GET_MCN
0578         Obtain the "Universal Product Code"
0579         if available
0580 
0581         (struct cdrom_mcn)
0582 
0583 
0584         usage::
0585 
0586           struct cdrom_mcn mcn;
0587 
0588           ioctl(fd, CDROM_GET_MCN, &mcn);
0589 
0590         inputs:
0591                 none
0592 
0593 
0594         outputs:
0595                 Universal Product Code
0596 
0597 
0598         error return:
0599           - ENOSYS      Drive is not capable of reading MCN data.
0600 
0601         notes:
0602                 - Source code comments state::
0603 
0604                     The following function is implemented, although very few
0605                     audio discs give Universal Product Code information, which
0606                     should just be the Medium Catalog Number on the box.  Note,
0607                     that the way the code is written on the CD is /not/ uniform
0608                     across all discs!
0609 
0610 
0611 
0612 
0613 CDROM_GET_UPC
0614         CDROM_GET_MCN  (deprecated)
0615 
0616 
0617         Not implemented, as of 2.6.8.1
0618 
0619 
0620 
0621 CDROMRESET
0622         hard-reset the drive
0623 
0624 
0625         usage::
0626 
0627           ioctl(fd, CDROMRESET, 0);
0628 
0629 
0630         inputs:
0631                 none
0632 
0633 
0634         outputs:
0635                 none
0636 
0637 
0638         error return:
0639           - EACCES      Access denied:  requires CAP_SYS_ADMIN
0640           - ENOSYS      Drive is not capable of resetting.
0641 
0642 
0643 
0644 
0645 CDROMREADCOOKED
0646         read data in cooked mode
0647 
0648 
0649         usage::
0650 
0651           u8 buffer[CD_FRAMESIZE]
0652 
0653           ioctl(fd, CDROMREADCOOKED, buffer);
0654 
0655         inputs:
0656                 none
0657 
0658 
0659         outputs:
0660                 2048 bytes of data, "cooked" mode.
0661 
0662 
0663         notes:
0664                 Not implemented on all drives.
0665 
0666 
0667 
0668 
0669 
0670 CDROMREADALL
0671         read all 2646 bytes
0672 
0673 
0674         Same as CDROMREADCOOKED, but reads 2646 bytes.
0675 
0676 
0677 
0678 CDROMSEEK
0679         seek msf address
0680 
0681 
0682         usage::
0683 
0684           struct cdrom_msf msf;
0685 
0686           ioctl(fd, CDROMSEEK, &msf);
0687 
0688         inputs:
0689                 MSF address to seek to.
0690 
0691 
0692         outputs:
0693                 none
0694 
0695 
0696 
0697 
0698 CDROMPLAYBLK
0699         scsi-cd only
0700 
0701         (struct cdrom_blk)
0702 
0703 
0704         usage::
0705 
0706           struct cdrom_blk blk;
0707 
0708           ioctl(fd, CDROMPLAYBLK, &blk);
0709 
0710         inputs:
0711                 Region to play
0712 
0713 
0714         outputs:
0715                 none
0716 
0717 
0718 
0719 
0720 CDROMGETSPINDOWN
0721         Obsolete, was ide-cd only
0722 
0723 
0724         usage::
0725 
0726           char spindown;
0727 
0728           ioctl(fd, CDROMGETSPINDOWN, &spindown);
0729 
0730         inputs:
0731                 none
0732 
0733 
0734         outputs:
0735                 The value of the current 4-bit spindown value.
0736 
0737 
0738 
0739 
0740 
0741 CDROMSETSPINDOWN
0742         Obsolete, was ide-cd only
0743 
0744 
0745         usage::
0746 
0747           char spindown
0748 
0749           ioctl(fd, CDROMSETSPINDOWN, &spindown);
0750 
0751         inputs:
0752                 4-bit value used to control spindown (TODO: more detail here)
0753 
0754 
0755         outputs:
0756                 none
0757 
0758 
0759 
0760 
0761 
0762 
0763 CDROM_SET_OPTIONS
0764         Set behavior options
0765 
0766 
0767         usage::
0768 
0769           int options;
0770 
0771           ioctl(fd, CDROM_SET_OPTIONS, options);
0772 
0773         inputs:
0774                 New values for drive options.  The logical 'or' of:
0775 
0776             ==============      ==================================
0777             CDO_AUTO_CLOSE      close tray on first open(2)
0778             CDO_AUTO_EJECT      open tray on last release
0779             CDO_USE_FFLAGS      use O_NONBLOCK information on open
0780             CDO_LOCK            lock tray on open files
0781             CDO_CHECK_TYPE      check type on open for data
0782             ==============      ==================================
0783 
0784         outputs:
0785                 Returns the resulting options settings in the
0786                 ioctl return value.  Returns -1 on error.
0787 
0788         error return:
0789           - ENOSYS      selected option(s) not supported by drive.
0790 
0791 
0792 
0793 
0794 CDROM_CLEAR_OPTIONS
0795         Clear behavior options
0796 
0797 
0798         Same as CDROM_SET_OPTIONS, except that selected options are
0799         turned off.
0800 
0801 
0802 
0803 CDROM_SELECT_SPEED
0804         Set the CD-ROM speed
0805 
0806 
0807         usage::
0808 
0809           int speed;
0810 
0811           ioctl(fd, CDROM_SELECT_SPEED, speed);
0812 
0813         inputs:
0814                 New drive speed.
0815 
0816 
0817         outputs:
0818                 none
0819 
0820 
0821         error return:
0822           - ENOSYS      speed selection not supported by drive.
0823 
0824 
0825 
0826 CDROM_SELECT_DISC
0827         Select disc (for juke-boxes)
0828 
0829 
0830         usage::
0831 
0832           int disk;
0833 
0834           ioctl(fd, CDROM_SELECT_DISC, disk);
0835 
0836         inputs:
0837                 Disk to load into drive.
0838 
0839 
0840         outputs:
0841                 none
0842 
0843 
0844         error return:
0845           - EINVAL      Disk number beyond capacity of drive
0846 
0847 
0848 
0849 CDROM_MEDIA_CHANGED
0850         Check is media changed
0851 
0852 
0853         usage::
0854 
0855           int slot;
0856 
0857           ioctl(fd, CDROM_MEDIA_CHANGED, slot);
0858 
0859         inputs:
0860                 Slot number to be tested, always zero except for jukeboxes.
0861 
0862                 May also be special values CDSL_NONE or CDSL_CURRENT
0863 
0864         outputs:
0865                 Ioctl return value is 0 or 1 depending on whether the media
0866 
0867           has been changed, or -1 on error.
0868 
0869         error returns:
0870           - ENOSYS      Drive can't detect media change
0871           - EINVAL      Slot number beyond capacity of drive
0872           - ENOMEM      Out of memory
0873 
0874 
0875 
0876 CDROM_DRIVE_STATUS
0877         Get tray position, etc.
0878 
0879 
0880         usage::
0881 
0882           int slot;
0883 
0884           ioctl(fd, CDROM_DRIVE_STATUS, slot);
0885 
0886         inputs:
0887                 Slot number to be tested, always zero except for jukeboxes.
0888 
0889                 May also be special values CDSL_NONE or CDSL_CURRENT
0890 
0891         outputs:
0892                 Ioctl return value will be one of the following values
0893 
0894           from <linux/cdrom.h>:
0895 
0896             =================== ==========================
0897             CDS_NO_INFO         Information not available.
0898             CDS_NO_DISC
0899             CDS_TRAY_OPEN
0900             CDS_DRIVE_NOT_READY
0901             CDS_DISC_OK
0902             -1                  error
0903             =================== ==========================
0904 
0905         error returns:
0906           - ENOSYS      Drive can't detect drive status
0907           - EINVAL      Slot number beyond capacity of drive
0908           - ENOMEM      Out of memory
0909 
0910 
0911 
0912 
0913 CDROM_DISC_STATUS
0914         Get disc type, etc.
0915 
0916 
0917         usage::
0918 
0919           ioctl(fd, CDROM_DISC_STATUS, 0);
0920 
0921 
0922         inputs:
0923                 none
0924 
0925 
0926         outputs:
0927                 Ioctl return value will be one of the following values
0928 
0929           from <linux/cdrom.h>:
0930 
0931             - CDS_NO_INFO
0932             - CDS_AUDIO
0933             - CDS_MIXED
0934             - CDS_XA_2_2
0935             - CDS_XA_2_1
0936             - CDS_DATA_1
0937 
0938         error returns:
0939                 none at present
0940 
0941         notes:
0942             - Source code comments state::
0943 
0944 
0945                 Ok, this is where problems start.  The current interface for
0946                 the CDROM_DISC_STATUS ioctl is flawed.  It makes the false
0947                 assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc.
0948                 Unfortunately, while this is often the case, it is also
0949                 very common for CDs to have some tracks with data, and some
0950                 tracks with audio.      Just because I feel like it, I declare
0951                 the following to be the best way to cope.  If the CD has
0952                 ANY data tracks on it, it will be returned as a data CD.
0953                 If it has any XA tracks, I will return it as that.      Now I
0954                 could simplify this interface by combining these returns with
0955                 the above, but this more clearly demonstrates the problem
0956                 with the current interface.  Too bad this wasn't designed
0957                 to use bitmasks...             -Erik
0958 
0959                 Well, now we have the option CDS_MIXED: a mixed-type CD.
0960                 User level programmers might feel the ioctl is not very
0961                 useful.
0962                                 ---david
0963 
0964 
0965 
0966 
0967 CDROM_CHANGER_NSLOTS
0968         Get number of slots
0969 
0970 
0971         usage::
0972 
0973           ioctl(fd, CDROM_CHANGER_NSLOTS, 0);
0974 
0975 
0976         inputs:
0977                 none
0978 
0979 
0980         outputs:
0981                 The ioctl return value will be the number of slots in a
0982                 CD changer.  Typically 1 for non-multi-disk devices.
0983 
0984         error returns:
0985                 none
0986 
0987 
0988 
0989 CDROM_LOCKDOOR
0990         lock or unlock door
0991 
0992 
0993         usage::
0994 
0995           int lock;
0996 
0997           ioctl(fd, CDROM_LOCKDOOR, lock);
0998 
0999         inputs:
1000                 Door lock flag, 1=lock, 0=unlock
1001 
1002 
1003         outputs:
1004                 none
1005 
1006 
1007         error returns:
1008           - EDRIVE_CANT_DO_THIS
1009 
1010                                 Door lock function not supported.
1011           - EBUSY
1012 
1013                                 Attempt to unlock when multiple users
1014                                 have the drive open and not CAP_SYS_ADMIN
1015 
1016         notes:
1017                 As of 2.6.8.1, the lock flag is a global lock, meaning that
1018                 all CD drives will be locked or unlocked together.  This is
1019                 probably a bug.
1020 
1021                 The EDRIVE_CANT_DO_THIS value is defined in <linux/cdrom.h>
1022                 and is currently (2.6.8.1) the same as EOPNOTSUPP
1023 
1024 
1025 
1026 CDROM_DEBUG
1027         Turn debug messages on/off
1028 
1029 
1030         usage::
1031 
1032           int debug;
1033 
1034           ioctl(fd, CDROM_DEBUG, debug);
1035 
1036         inputs:
1037                 Cdrom debug flag, 0=disable, 1=enable
1038 
1039 
1040         outputs:
1041                 The ioctl return value will be the new debug flag.
1042 
1043 
1044         error return:
1045           - EACCES      Access denied:  requires CAP_SYS_ADMIN
1046 
1047 
1048 
1049 CDROM_GET_CAPABILITY
1050         get capabilities
1051 
1052 
1053         usage::
1054 
1055           ioctl(fd, CDROM_GET_CAPABILITY, 0);
1056 
1057 
1058         inputs:
1059                 none
1060 
1061 
1062         outputs:
1063                 The ioctl return value is the current device capability
1064                 flags.  See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc.
1065 
1066 
1067 
1068 CDROMAUDIOBUFSIZ
1069         set the audio buffer size
1070 
1071 
1072         usage::
1073 
1074           int arg;
1075 
1076           ioctl(fd, CDROMAUDIOBUFSIZ, val);
1077 
1078         inputs:
1079                 New audio buffer size
1080 
1081 
1082         outputs:
1083                 The ioctl return value is the new audio buffer size, or -1
1084                 on error.
1085 
1086         error return:
1087           - ENOSYS      Not supported by this driver.
1088 
1089         notes:
1090                 Not supported by all drivers.
1091 
1092 
1093 
1094 
1095 DVD_READ_STRUCT                 Read structure
1096 
1097         usage::
1098 
1099           dvd_struct s;
1100 
1101           ioctl(fd, DVD_READ_STRUCT, &s);
1102 
1103         inputs:
1104                 dvd_struct structure, containing:
1105 
1106             =================== ==========================================
1107             type                specifies the information desired, one of
1108                                 DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT,
1109                                 DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA,
1110                                 DVD_STRUCT_MANUFACT
1111             physical.layer_num  desired layer, indexed from 0
1112             copyright.layer_num desired layer, indexed from 0
1113             disckey.agid
1114             =================== ==========================================
1115 
1116         outputs:
1117                 dvd_struct structure, containing:
1118 
1119             =================== ================================
1120             physical            for type == DVD_STRUCT_PHYSICAL
1121             copyright           for type == DVD_STRUCT_COPYRIGHT
1122             disckey.value       for type == DVD_STRUCT_DISCKEY
1123             bca.{len,value}     for type == DVD_STRUCT_BCA
1124             manufact.{len,valu} for type == DVD_STRUCT_MANUFACT
1125             =================== ================================
1126 
1127         error returns:
1128           - EINVAL      physical.layer_num exceeds number of layers
1129           - EIO         Received invalid response from drive
1130 
1131 
1132 
1133 DVD_WRITE_STRUCT                Write structure
1134 
1135         Not implemented, as of 2.6.8.1
1136 
1137 
1138 
1139 DVD_AUTH                        Authentication
1140 
1141         usage::
1142 
1143           dvd_authinfo ai;
1144 
1145           ioctl(fd, DVD_AUTH, &ai);
1146 
1147         inputs:
1148                 dvd_authinfo structure.  See <linux/cdrom.h>
1149 
1150 
1151         outputs:
1152                 dvd_authinfo structure.
1153 
1154 
1155         error return:
1156           - ENOTTY      ai.type not recognized.
1157 
1158 
1159 
1160 CDROM_SEND_PACKET
1161         send a packet to the drive
1162 
1163 
1164         usage::
1165 
1166           struct cdrom_generic_command cgc;
1167 
1168           ioctl(fd, CDROM_SEND_PACKET, &cgc);
1169 
1170         inputs:
1171                 cdrom_generic_command structure containing the packet to send.
1172 
1173 
1174         outputs:
1175                 none
1176 
1177           cdrom_generic_command structure containing results.
1178 
1179         error return:
1180           - EIO
1181 
1182                         command failed.
1183           - EPERM
1184 
1185                         Operation not permitted, either because a
1186                         write command was attempted on a drive which
1187                         is opened read-only, or because the command
1188                         requires CAP_SYS_RAWIO
1189           - EINVAL
1190 
1191                         cgc.data_direction not set
1192 
1193 
1194 
1195 CDROM_NEXT_WRITABLE
1196         get next writable block
1197 
1198 
1199         usage::
1200 
1201           long next;
1202 
1203           ioctl(fd, CDROM_NEXT_WRITABLE, &next);
1204 
1205         inputs:
1206                 none
1207 
1208 
1209         outputs:
1210                 The next writable block.
1211 
1212 
1213         notes:
1214                 If the device does not support this ioctl directly, the
1215 
1216           ioctl will return CDROM_LAST_WRITTEN + 7.
1217 
1218 
1219 
1220 CDROM_LAST_WRITTEN
1221         get last block written on disc
1222 
1223 
1224         usage::
1225 
1226           long last;
1227 
1228           ioctl(fd, CDROM_LAST_WRITTEN, &last);
1229 
1230         inputs:
1231                 none
1232 
1233 
1234         outputs:
1235                 The last block written on disc
1236 
1237 
1238         notes:
1239                 If the device does not support this ioctl directly, the
1240                 result is derived from the disc's table of contents.  If the
1241                 table of contents can't be read, this ioctl returns an
1242                 error.