File = EfiDeviceOpenByType (EfiOpenBlockIo, Index);\r
if (File != NULL) {\r
if (File->FsBlockIoMedia->RemovableMedia) {\r
- if (File->FsBlockIoMedia->MediaPresent) {\r
- // Probe to see if media is present\r
- Status = File->FsBlockIo->ReadBlocks (File->FsBlockIo, File->FsBlockIo->Media->MediaId, (EFI_LBA)0, 0, NULL);\r
- if (Status == EFI_NO_MEDIA) {\r
- gBS->DisconnectController (File->EfiHandle, NULL, NULL);\r
- }\r
- } else {\r
- // Probe for media insertion and connect partition and filesystem drivers if needed\r
- gBS->ConnectController (File->EfiHandle, NULL, NULL, TRUE);\r
- }\r
+ // Probe to see if media is present (or not) or media changed\r
+ // this causes the ReinstallProtocolInterface() to fire in the\r
+ // block io driver to update the system about media change events\r
+ File->FsBlockIo->ReadBlocks (File->FsBlockIo, File->FsBlockIo->Media->MediaId, (EFI_LBA)0, 0, NULL);\r
}\r
EfiClose (File);\r
}\r