- From: "muriwai" <muriwai@xxxxxxxxxxxxx>
- Date: Mon, 26 Mar 2007 10:47:06 +1200
I have a kernel mode driver which opens a storage device via its device
interface (say, GUID_DEVCLASS_DISKDRIVE). I also have a user mode program
with the eject button. When the button is clicked, I want the driver to
either eject the medium from the storage device, or eject the device itself
if the medium is not removable but the device itself is. This is to make
sure the user can remove/unplug the medium/drive without data loss.
So I want the following:
A) If the media is physically removable, eject the medium (eg, CD-ROM from a
USB or EIDE CD-ROM drive)
B) If the media is fixed and the drive is fixed, do nothing.
C) If the media is fixed and the drive is ejectable (can be dynamically
removed from the system), eject the drive (which means putting it into the
state when Windows usually says "it's safe to remove the device now").
I have no troubles ejecting the media from say a CD-ROM with
I can "eject" media from a USB pen drive. For some reason, USB pen drives
are marked as if they have removable media. Ejecting the media makes the
drive letter inaccessible, though the pen drive is still shown as connected.
Ugly, but that's OK for my purposes.
I can't eject an HDD in an external USB enclosure. IOCTL_STORAGE_EJECT_MEDIA
fails with STATUS_IO_DEVICE_ERROR.
My questions are below:
1) It seems that I can't "safely remove" a USB pen drive because I have no
way to distinguish between truly removable media and a pen drive, can I?
For example, both an external USB CD-ROM and USB pen drive have their media
marked as removable. Ejecting the media ejects the CD-ROM disc, and sort of
"ejects" the pen drive "media", but leaves the pen drive itself connected
with the safe removal icon on the screen.
If I eject the device as opposed to media, this ejects the USB CD-ROM
drive itself, which is not what I want.
2) What will happen if I call IoRequestDeviceEject() on the device that
doesn't support removal, for example, an IDE hard disk drive? Can I rely on
DEVICE_CAPABILITIES.Removable to avoid calling IoRequestDeviceEject() on
internal IDE HDDs?
3) To use IoRequestDeviceEject(), I need PDO. Can I use
IoGetLowerDeviceObject to walk down the stack from the device object opened
by the device interface to PDO? Is the last device object guaranteed to be
PDO? How can I distinguish between FDO and PDO to make sure the system won't
crash if I pass FDO to IoRequestDeviceEject?
- Prev by Date: System hang with ATI x1600 or x300 video card installed
- Next by Date: Re: IoGetLowerDeviceObject
- Previous by thread: System hang with ATI x1600 or x300 video card installed
- Next by thread: Re: IoGetLowerDeviceObject