Eject button

Hi,

Can someone explain me how the Eject button on a MOD or DVD device is
handled in Windows (Which IRP’s are used ?)

Is it the PNP manager that initialy processes the Eject Button ? What
happens when a File System driver has open files and the eject button is
pressed ? I expected the eject to be rejected when files are open but that
didnt seem to stop the eject on an MOD drive.

I am assuming that “eject” has not been disabled for the drive in question.

Thanks all,
Jos.

> Is it the PNP manager that initialy processes the Eject Button ?

Surely not so. It is media who ejected, and not device.

Media eject was supported even in NT 3.1, long before PnP.

Eject button causes the drive to switch to the unit attention condition
internally and to eject the disk. The very next request to the drive will be
failed as unit attention. CdRom.sys will notice this, set the DO_VERIFY_VOLUME
flag ("the media was possibly changed) and fail the request as
STATUS_VERIFY_REQUIRED. This will cause the FSD to break the link between its
volume device and the disk device objects, and try to do a fresh mount next
time the file will be opened.

The detached volume device will live in memory till either a) all files will be
closed on it - it is deleted or b) the same old media is re-inserted, in which
case it is re-mounted back, and the caches are preserved.

happens when a File System driver has open files and the eject button is
pressed ? I expected the eject to be rejected when files are open

I don’t think so. At least CDs can be ejected with files open.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

File systems have the option of locking the media in the drive using
IOCTL_STORAGE_EJECTION_CONTROL. If the drive is locked and the eject
button is pressed, some (most new) drives will do one of two things:

(a) report a specific error on the next command saying “eject button
pressed”

(b) report a “GESN” event saying “eject button pressed”

In Windows XP and higher, the CDROM.SYS driver handles both these
events, and propogates a notification to any listening clients (similar
to how media notification occurs – see ioevent.h for GUIDs). If the
file system is listening for and handling this GUID, it can then choose
to flush any dirty caches, prompt the user, or anything else it wants.
One option is to eject the disc on this notification by sending
IOCTL_STORAGE_EJECT_MEDIA.

If the file system is read-only, it is highly unlikely that any of the
above will be done. However, any application can do the exact same
process, as the notifications are broadcast (not single-target).

Events MSDN page:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/b
ase/device_events.asp

Hth,
.

-----Original Message-----
From: Jos Scherders [mailto:xxxxx@home.nl]
Sent: Monday, January 19, 2004 12:45 PM
Subject: Eject button

Hi,

Can someone explain me how the Eject button on a MOD or DVD device is
handled in Windows (Which IRP’s are used ?)

Is it the PNP manager that initialy processes the Eject Button ? What
happens when a File System driver has open files and the eject button is
pressed ? I expected the eject to be rejected when files are open but
that
didnt seem to stop the eject on an MOD drive.

I am assuming that “eject” has not been disabled for the drive in
question.

Thanks all,
Jos.