Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) IDE-CD driver documentation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) ===========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) :Originally by: scott snyder  <snyder@fnald0.fnal.gov> (19 May 1996)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) :Carrying on the torch is: Erik Andersen <andersee@debian.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) :New maintainers (19 Oct 1998): Jens Axboe <axboe@image.dk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 1. Introduction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) The ide-cd driver should work with all ATAPI ver 1.2 to ATAPI 2.6 compliant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) CDROM drives which attach to an IDE interface.  Note that some CDROM vendors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) (including Mitsumi, Sony, Creative, Aztech, and Goldstar) have made
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) both ATAPI-compliant drives and drives which use a proprietary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) interface.  If your drive uses one of those proprietary interfaces,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) this driver will not work with it (but one of the other CDROM drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) probably will).  This driver will not work with `ATAPI` drives which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) attach to the parallel port.  In addition, there is at least one drive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) (CyCDROM CR520ie) which attaches to the IDE port but is not ATAPI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) this driver will not work with drives like that either (but see the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) aztcd driver).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) This driver provides the following features:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  - Reading from data tracks, and mounting ISO 9660 filesystems.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  - Playing audio tracks.  Most of the CDROM player programs floating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)    around should work; I usually use Workman.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  - Multisession support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  - On drives which support it, reading digital audio data directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)    from audio tracks.  The program cdda2wav can be used for this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)    Note, however, that only some drives actually support this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  - There is now support for CDROM changers which comply with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)    ATAPI 2.6 draft standard (such as the NEC CDR-251).  This additional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)    functionality includes a function call to query which slot is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)    currently selected slot, a function call to query which slots contain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)    CDs, etc. A sample program which demonstrates this functionality is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)    appended to the end of this file.  The Sanyo 3-disc changer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)    (which does not conform to the standard) is also now supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)    Please note the driver refers to the first CD as slot # 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 2. Installation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 0. The ide-cd relies on the ide disk driver.  See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)    Documentation/ide/ide.rst for up-to-date information on the ide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)    driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 1. Make sure that the ide and ide-cd drivers are compiled into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)    kernel you're using.  When configuring the kernel, in the section
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)    entitled "Floppy, IDE, and other block devices", say either `Y`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)    (which will compile the support directly into the kernel) or `M`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)    (to compile support as a module which can be loaded and unloaded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)    to the options::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)       ATA/ATAPI/MFM/RLL support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)       Include IDE/ATAPI CDROM support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)    Depending on what type of IDE interface you have, you may need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)    specify additional configuration options.  See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)    Documentation/ide/ide.rst.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 2. You should also ensure that the iso9660 filesystem is either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)    compiled into the kernel or available as a loadable module.  You
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)    can see if a filesystem is known to the kernel by catting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)    /proc/filesystems.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 3. The CDROM drive should be connected to the host on an IDE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)    interface.  Each interface on a system is defined by an I/O port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)    address and an IRQ number, the standard assignments being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)    0x1f0 and 14 for the primary interface and 0x170 and 15 for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)    secondary interface.  Each interface can control up to two devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)    where each device can be a hard drive, a CDROM drive, a floppy drive,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)    or a tape drive.  The two devices on an interface are called `master`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)    and `slave`; this is usually selectable via a jumper on the drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)    Linux names these devices as follows.  The master and slave devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)    on the primary IDE interface are called `hda` and `hdb`,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)    respectively.  The drives on the secondary interface are called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)    `hdc` and `hdd`.  (Interfaces at other locations get other letters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)    in the third position; see Documentation/ide/ide.rst.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)    If you want your CDROM drive to be found automatically by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)    driver, you should make sure your IDE interface uses either the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)    primary or secondary addresses mentioned above.  In addition, if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)    the CDROM drive is the only device on the IDE interface, it should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)    be jumpered as `master`.  (If for some reason you cannot configure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)    your system in this manner, you can probably still use the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)    You may have to pass extra configuration information to the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)    when you boot, however.  See Documentation/ide/ide.rst for more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)    information.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 4. Boot the system.  If the drive is recognized, you should see a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)    message which looks like::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)      hdb: NEC CD-ROM DRIVE:260, ATAPI CDROM drive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)    If you do not see this, see section 5 below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 5. You may want to create a symbolic link /dev/cdrom pointing to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)    actual device.  You can do this with the command::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)      ln -s  /dev/hdX  /dev/cdrom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)    where X should be replaced by the letter indicating where your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)    drive is installed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 6. You should be able to see any error messages from the driver with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)    the `dmesg` command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 3. Basic usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) An ISO 9660 CDROM can be mounted by putting the disc in the drive and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) typing (as root)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)   mount -t iso9660 /dev/cdrom /mnt/cdrom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) where it is assumed that /dev/cdrom is a link pointing to the actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) device (as described in step 5 of the last section) and /mnt/cdrom is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) an empty directory.  You should now be able to see the contents of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) CDROM under the /mnt/cdrom directory.  If you want to eject the CDROM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) you must first dismount it with a command like::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)   umount /mnt/cdrom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) Note that audio CDs cannot be mounted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) Some distributions set up /etc/fstab to always try to mount a CDROM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) filesystem on bootup.  It is not required to mount the CDROM in this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) manner, though, and it may be a nuisance if you change CDROMs often.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) You should feel free to remove the cdrom line from /etc/fstab and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) mount CDROMs manually if that suits you better.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) Multisession and photocd discs should work with no special handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) The hpcdtoppm package (ftp.gwdg.de:/pub/linux/hpcdtoppm/) may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) useful for reading photocds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) To play an audio CD, you should first unmount and remove any data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) CDROM.  Any of the CDROM player programs should then work (workman,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) workbone, cdplayer, etc.).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) On a few drives, you can read digital audio directly using a program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) such as cdda2wav.  The only types of drive which I've heard support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) this are Sony and Toshiba drives.  You will get errors if you try to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) use this function on a drive which does not support it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) For supported changers, you can use the `cdchange` program (appended to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) the end of this file) to switch between changer slots.  Note that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) drive should be unmounted before attempting this.  The program takes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) two arguments:  the CDROM device, and the slot number to which you wish
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) to change.  If the slot number is -1, the drive is unloaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 4. Common problems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) This section discusses some common problems encountered when trying to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) use the driver, and some possible solutions.  Note that if you are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) experiencing problems, you should probably also review
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) Documentation/ide/ide.rst for current information about the underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) IDE support code.  Some of these items apply only to earlier versions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) of the driver, but are mentioned here for completeness.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) In most cases, you should probably check with `dmesg` for any errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) from the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) a. Drive is not detected during booting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)    - Review the configuration instructions above and in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)      Documentation/ide/ide.rst, and check how your hardware is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)      configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)    - If your drive is the only device on an IDE interface, it should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)      be jumpered as master, if at all possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)    - If your IDE interface is not at the standard addresses of 0x170
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)      or 0x1f0, you'll need to explicitly inform the driver using a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)      lilo option.  See Documentation/ide/ide.rst.  (This feature was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)      added around kernel version 1.3.30.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)    - If the autoprobing is not finding your drive, you can tell the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)      driver to assume that one exists by using a lilo option of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)      form `hdX=cdrom`, where X is the drive letter corresponding to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)      where your drive is installed.  Note that if you do this and you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)      see a boot message like::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)        hdX: ATAPI cdrom (?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)      this does _not_ mean that the driver has successfully detected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)      the drive; rather, it means that the driver has not detected a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)      drive, but is assuming there's one there anyway because you told
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)      it so.  If you actually try to do I/O to a drive defined at a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)      nonexistent or nonresponding I/O address, you'll probably get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)      errors with a status value of 0xff.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)    - Some IDE adapters require a nonstandard initialization sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)      before they'll function properly.  (If this is the case, there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)      will often be a separate MS-DOS driver just for the controller.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)      IDE interfaces on sound cards often fall into this category.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)      Support for some interfaces needing extra initialization is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)      provided in later 1.3.x kernels.  You may need to turn on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)      additional kernel configuration options to get them to work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)      see Documentation/ide/ide.rst.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)      Even if support is not available for your interface, you may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)      able to get it to work with the following procedure.  First boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)      MS-DOS and load the appropriate drivers.  Then warm-boot linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)      (i.e., without powering off).  If this works, it can be automated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)      by running loadlin from the MS-DOS autoexec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) b. Timeout/IRQ errors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)   - If you always get timeout errors, interrupts from the drive are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)     probably not making it to the host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)   - IRQ problems may also be indicated by the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)     `IRQ probe failed (<n>)` while booting.  If <n> is zero, that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)     means that the system did not see an interrupt from the drive when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)     it was expecting one (on any feasible IRQ).  If <n> is negative,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)     that means the system saw interrupts on multiple IRQ lines, when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)     it was expecting to receive just one from the CDROM drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)   - Double-check your hardware configuration to make sure that the IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)     number of your IDE interface matches what the driver expects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)     (The usual assignments are 14 for the primary (0x1f0) interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)     and 15 for the secondary (0x170) interface.)  Also be sure that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)     you don't have some other hardware which might be conflicting with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)     the IRQ you're using.  Also check the BIOS setup for your system;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)     some have the ability to disable individual IRQ levels, and I've
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)     had one report of a system which was shipped with IRQ 15 disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)     by default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)   - Note that many MS-DOS CDROM drivers will still function even if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)     there are hardware problems with the interrupt setup; they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)     apparently don't use interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)   - If you own a Pioneer DR-A24X, you _will_ get nasty error messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)     on boot such as "irq timeout: status=0x50 { DriveReady SeekComplete }"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)     The Pioneer DR-A24X CDROM drives are fairly popular these days.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)     Unfortunately, these drives seem to become very confused when we perform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)     the standard Linux ATA disk drive probe. If you own one of these drives,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)     you can bypass the ATA probing which confuses these CDROM drives, by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)     adding `append="hdX=noprobe hdX=cdrom"` to your lilo.conf file and running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)     lilo (again where X is the drive letter corresponding to where your drive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)     is installed.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) c. System hangups.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)   - If the system locks up when you try to access the CDROM, the most
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)     likely cause is that you have a buggy IDE adapter which doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)     properly handle simultaneous transactions on multiple interfaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)     The most notorious of these is the CMD640B chip.  This problem can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)     be worked around by specifying the `serialize` option when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)     booting.  Recent kernels should be able to detect the need for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)     this automatically in most cases, but the detection is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)     foolproof.  See Documentation/ide/ide.rst for more information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)     about the `serialize` option and the CMD640B.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)   - Note that many MS-DOS CDROM drivers will work with such buggy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)     hardware, apparently because they never attempt to overlap CDROM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)     operations with other disk activity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) d. Can't mount a CDROM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)   - If you get errors from mount, it may help to check `dmesg` to see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)     if there are any more specific errors from the driver or from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)     filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)   - Make sure there's a CDROM loaded in the drive, and that's it's an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)     ISO 9660 disc.  You can't mount an audio CD.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)   - With the CDROM in the drive and unmounted, try something like::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)       cat /dev/cdrom | od | more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)     If you see a dump, then the drive and driver are probably working
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)     OK, and the problem is at the filesystem level (i.e., the CDROM is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)     not ISO 9660 or has errors in the filesystem structure).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)   - If you see `not a block device` errors, check that the definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)     of the device special files are correct.  They should be as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)     follows::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)       brw-rw----   1 root     disk       3,   0 Nov 11 18:48 /dev/hda
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)       brw-rw----   1 root     disk       3,  64 Nov 11 18:48 /dev/hdb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)       brw-rw----   1 root     disk      22,   0 Nov 11 18:48 /dev/hdc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)       brw-rw----   1 root     disk      22,  64 Nov 11 18:48 /dev/hdd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)     Some early Slackware releases had these defined incorrectly.  If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)     these are wrong, you can remake them by running the script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)     scripts/MAKEDEV.ide.  (You may have to make it executable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)     with chmod first.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)     If you have a /dev/cdrom symbolic link, check that it is pointing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)     to the correct device file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)     If you hear people talking of the devices `hd1a` and `hd1b`, these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)     were old names for what are now called hdc and hdd.  Those names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)     should be considered obsolete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)   - If mount is complaining that the iso9660 filesystem is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)     available, but you know it is (check /proc/filesystems), you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)     probably need a newer version of mount.  Early versions would not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)     always give meaningful error messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) e. Directory listings are unpredictably truncated, and `dmesg` shows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)    `buffer botch` error messages from the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)   - There was a bug in the version of the driver in 1.2.x kernels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)     which could cause this.  It was fixed in 1.3.0.  If you can't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)     upgrade, you can probably work around the problem by specifying a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)     blocksize of 2048 when mounting.  (Note that you won't be able to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)     directly execute binaries off the CDROM in that case.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)     If you see this in kernels later than 1.3.0, please report it as a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)     bug.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) f. Data corruption.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)   - Random data corruption was occasionally observed with the Hitachi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)     CDR-7730 CDROM. If you experience data corruption, using "hdx=slow"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)     as a command line parameter may work around the problem, at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)     expense of low system performance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 5. cdchange.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) -------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)   /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)    * cdchange.c  [-v]  <device>  [<slot>]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)    *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)    * This loads a CDROM from a specified slot in a changer, and displays
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)    * information about the changer status.  The drive should be unmounted before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)    * using this program.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)    *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)    * Changer information is displayed if either the -v flag is specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)    * or no slot was specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)    *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)    * Based on code originally from Gerhard Zuber <zuber@berlin.snafu.de>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)    * Changer status information, and rewrite for the new Uniform CDROM driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)    * interface by Erik Andersen <andersee@debian.org>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)   #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)   #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)   #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)   #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)   #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)   #include <fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)   #include <sys/ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)   #include <linux/cdrom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)   int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)   main (int argc, char **argv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)   {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	char *program;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	char *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	int fd;           /* file descriptor for CD-ROM device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	int status;       /* return status for system calls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	int verbose = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	int slot=-1, x_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	int total_slots_available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	program = argv[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	++argv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	--argc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	if (argc < 1 || argc > 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		fprintf (stderr, "usage: %s [-v] <device> [<slot>]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			 program);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		fprintf (stderr, "       Slots are numbered 1 -- n.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		exit (1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)        if (strcmp (argv[0], "-v") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)                 verbose = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)                 ++argv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)                 --argc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	device = argv[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	if (argc == 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		slot = atoi (argv[1]) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	/* open device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	fd = open(device, O_RDONLY | O_NONBLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	if (fd < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		fprintf (stderr, "%s: open failed for `%s`: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 			 program, device, strerror (errno));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		exit (1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	/* Check CD player status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	total_slots_available = ioctl (fd, CDROM_CHANGER_NSLOTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	if (total_slots_available <= 1 ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		fprintf (stderr, "%s: Device `%s` is not an ATAPI "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 			"compliant CD changer.\n", program, device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		exit (1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	if (slot >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		if (slot >= total_slots_available) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			fprintf (stderr, "Bad slot number.  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 				 "Should be 1 -- %d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 				 total_slots_available);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			exit (1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		/* load */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		slot=ioctl (fd, CDROM_SELECT_DISC, slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		if (slot<0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 			fflush(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 				perror ("CDROM_SELECT_DISC ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 			exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	if (slot < 0 || verbose) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		status=ioctl (fd, CDROM_SELECT_DISC, CDSL_CURRENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		if (status<0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 			fflush(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 			perror (" CDROM_SELECT_DISC");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 			exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 		slot=status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		printf ("Current slot: %d\n", slot+1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		printf ("Total slots available: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			total_slots_available);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		printf ("Drive status: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)                 status = ioctl (fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)                 if (status<0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)                   perror(" CDROM_DRIVE_STATUS");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)                 } else switch(status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		case CDS_DISC_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 			printf ("Ready.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		case CDS_TRAY_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			printf ("Tray Open.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		case CDS_DRIVE_NOT_READY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 			printf ("Drive Not Ready.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 			printf ("This Should not happen!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		for (x_slot=0; x_slot<total_slots_available; x_slot++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 			printf ("Slot %2d: ", x_slot+1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 			status = ioctl (fd, CDROM_DRIVE_STATUS, x_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 			if (status<0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 			     perror(" CDROM_DRIVE_STATUS");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 			} else switch(status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			case CDS_DISC_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 				printf ("Disc present.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 			case CDS_NO_DISC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 				printf ("Empty slot.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 			case CDS_TRAY_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 				printf ("CD-ROM tray open.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 			case CDS_DRIVE_NOT_READY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 				printf ("CD-ROM drive not ready.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 			case CDS_NO_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 				printf ("No Information available.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 				printf ("This Should not happen!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		  if (slot == x_slot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)                   status = ioctl (fd, CDROM_DISC_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)                   if (status<0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 			perror(" CDROM_DISC_STATUS");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)                   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 		  switch (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 			case CDS_AUDIO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 				printf ("\tAudio disc.\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 			case CDS_DATA_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 			case CDS_DATA_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 				printf ("\tData disc type %d.\t", status-CDS_DATA_1+1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 			case CDS_XA_2_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 			case CDS_XA_2_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 				printf ("\tXA data disc type %d.\t", status-CDS_XA_2_1+1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 				printf ("\tUnknown disc type 0x%x!\t", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 			status = ioctl (fd, CDROM_MEDIA_CHANGED, x_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 			if (status<0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 				perror(" CDROM_MEDIA_CHANGED");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 			switch (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 			case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 				printf ("Changed.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 				printf ("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	/* close device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	status = close (fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	if (status != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		fprintf (stderr, "%s: close failed for `%s`: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 			 program, device, strerror (errno));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 		exit (1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	exit (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)   }