Documentation/cdrom/cdrom-standard.rst

Source file repositories/reference/linux-study-clean/Documentation/cdrom/cdrom-standard.rst

File Facts

System
Linux kernel
Corpus path
Documentation/cdrom/cdrom-standard.rst
Extension
.rst
Size
48186 bytes
Lines
1048
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

*struct file_operations*::

	struct file_operations cdrom_fops = {
		NULL,			/* lseek */
		block _read ,		/* read--general block-dev read */
		block _write,		/* write--general block-dev write */
		NULL,			/* readdir */
		NULL,			/* select */
		cdrom_ioctl,		/* ioctl */
		NULL,			/* mmap */
		cdrom_open,		/* open */
		cdrom_release,		/* release */
		NULL,			/* fsync */
		NULL,			/* fasync */
		NULL			/* revalidate */
	};

Every active CD-ROM device shares this *struct*. The routines
declared above are all implemented in `cdrom.c`, since this file is the
place where the behavior of all CD-ROM-devices is defined and
standardized. The actual interface to the various types of CD-ROM
hardware is still performed by various low-level CD-ROM-device
drivers. These routines simply implement certain **capabilities**
that are common to all CD-ROM (and really, all removable-media
devices).

Registration of a low-level CD-ROM device driver is now done through
the general routines in `cdrom.c`, not through the Virtual File System
(VFS) any more. The interface implemented in `cdrom.c` is carried out
through two general structures that contain information about the
capabilities of the driver, and the specific drives on which the
driver operates. The structures are:

cdrom_device_ops
  This structure contains information about the low-level driver for a
  CD-ROM device. This structure is conceptually connected to the major
  number of the device (although some drivers may have different
  major numbers, as is the case for the IDE driver).

cdrom_device_info
  This structure contains information about a particular CD-ROM drive,
  such as its device name, speed, etc. This structure is conceptually
  connected to the minor number of the device.

Registering a particular CD-ROM drive with the Uniform CD-ROM Driver
is done by the low-level device driver though a call to::

	register_cdrom(struct cdrom_device_info * <device>_info)

The device information structure, *<device>_info*, contains all the
information needed for the kernel to interface with the low-level
CD-ROM device driver. One of the most important entries in this
structure is a pointer to the *cdrom_device_ops* structure of the
low-level driver.

The device operations structure, *cdrom_device_ops*, contains a list
of pointers to the functions which are implemented in the low-level
device driver. When `cdrom.c` accesses a CD-ROM device, it does it
through the functions in this structure. It is impossible to know all
the capabilities of future CD-ROM drives, so it is expected that this
list may need to be expanded from time to time as new technologies are
developed. For example, CD-R and CD-R/W drives are beginning to become
popular, and support will soon need to be added for them. For now, the
current *struct* is::

	struct cdrom_device_ops {
		int (*open)(struct cdrom_device_info *, int)
		void (*release)(struct cdrom_device_info *);
		int (*drive_status)(struct cdrom_device_info *, int);
		unsigned int (*check_events)(struct cdrom_device_info *,

Annotation

Implementation Notes