[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Files Reference

cd Special File


Provides access to the CD-ROM device driver.


The CD-ROM special file provides block and character (raw) access to disks in the CD-ROM drives.

The r prefix on a special file name means the drive is accessed as a raw device rather than a block device. Performing raw I/O with a compact disk requires the performance of all data transfers in multiples of the compact-disk logical block length. Also, all lseek subroutines made to the raw CD-ROM device driver must set the file offset pointer to a value that is a multiple of the specified logical block size.

CD-ROM Device Drivers

Compact disks, used in CD-ROM device drivers, are read-only media that provide storage for large amounts of data. The special files /dev/cd0, /dev/cd1,... provide block access to compact disks. The special files /dev/rcd0, /dev/rc1,... provide character access.

When a CD-ROM disc is ejected from the drive for a mounted CD-ROM file system, the files on the compact disc can no longer be accessed. Before these files can be accessed again, the file systems mounted from the CD-ROM must be unmounted. Processes having files open on these file systems should be exited. Processes having current directories on these file systems should be moved. If these actions do not work, perform a forced unmount.

Another problem that results from ejecting the CD-ROM disc for a mounted CD-ROM file system is that the man command can become unresponsive. Reinserting the CD-ROM disc will not fix the problem. All processes (graphical and ASCII) should be exited and the file system should be forced unmounted and mounted again. Afterwards, any man commands can be started again.

Device-Dependent Subroutines

Most CD-ROM operations are implemented using the open, read, and close subroutines. However, for some purposes, use of the openx (extended) subroutine is required.

openx Subroutine The openx subroutine is supported to provide additional functions to the open sequence. The openx subroutine requires appropriate authority to start. Attempting to execute this subroutine without the proper authority results in a return value of -1, with the errno global variable set to EPERM.
ioctl Subroutine The IOCINFO ioctl operation is defined for all device drivers that use the ioctl subroutine. The remaining ioctl operations are all physical volume device-specific operations. Diagnostic mode is not required for the following operation. The IOCINFO operation returns a devinfo structure, which is defined in the devinfo.h file.

Error Codes

In addition to the error codes listed for the ioctl, open, read, and write subroutines, the following error codes are also possible:

EACCES A subroutine other than ioctl or close was attempted while in Diagnostic mode.
EACCES A normal read call was attempted while in Diagnostic mode.
EFAULT Illegal user address.
EBUSY The target device is reserved by another initiator.
EINVAL The device was opened with a mode other than read-only.
EINVAL An nbyte parameter to a read subroutine is not an even multiple of the block size.
EINVAL A sense-data buffer length greater than 255 is not valid for a CDIOCMD ioctl operation.
EINVAL A data buffer length greater than that allowed by the drive is not valid for a CDIOCMD ioctl operation.
EINVAL An attempt was made to configure a device that is still open.
EINVAL An illegal configuration command has been given.
EMFILE An open call has been attempted for a SCSI adapter that already has the maximum permissible number of open devices.
ENOTREADY There is no compact disk in the drive.
ENODEV An attempt was made to access a device that is not defined.
ENODEV An attempt was made to close a device that has not been defined.
EMEDIA The media was changed.
EIO Hardware error or aborted command or illegal request.
EIO An attempt has been made to read beyond the end of media.
EPERM This subroutine requires appropriate authority.
ESTALE A CD-ROM disk was ejected (without first being closed by the user) and then either re-inserted or replaced with a second disk.
ETIMEDOUT An I/O operation has exceeded the given timer value.

Related Information

The close subroutine, ioctl subroutine, lseek subroutine, open subroutine, read subroutine.

Special Files Overview.

The scdisk SCSI Device Driver in AIX 5L Version 5.2 Technical Reference: Kernel and Subsystems Volume 1.

SCSI Subsystem Overview in AIX 5L Version 5.2 Kernel Extensions and Device Support Programming Concepts.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]