• G
    make windows notice media change · 93c8cfd9
    Gleb Natapov 提交于
    Windows seems to be very stupid about cdrom media change. It polls
    cdrom status and if status goes ready->media not present->ready
    it assumes that media was changed. If "media not present" step doesn't
    happen even if "medium may have changed" was seen it assumes media
    haven't changed. Fake "media not present" step.
    
    Filip Navara did a great job debugging this issue in Windows and this is
    what he found out:
    
    BINGO! ... The media present notifications were broken ever since
    Windows 2000 it seems. The media change is detected properly and it's
    passed to ClassSetMediaChangeState function which in turn calls
    ClasspInternalSetMediaChangeState. This function is responsible for
    changing some internal state of the device object and sending the PnP
    events which later result in application notifications. It has this
    tiny bit of code (not copied byte for byte):
    
    if (oldMediaState == NewState) {
      // Media is in the same state it was before.
      return;
    }
    
    so the end result is that for the case of UNIT NEEDS ATTENTION /
    MEDIUM MAY HAVE CHANGED without NOT READY in-between is really broken.
    It results in the internal media change counter incremented, so the
    media contents are re-read when necessary, instead of relying on the
    cache, but the notifications to applications are never sent.
    Signed-off-by: NGleb Natapov <gleb@redhat.com>
    Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
    Message-Id: 
    93c8cfd9
ide.c 132.4 KB