before the CDIOCEJECT ioctl otherwise the media is still locked when you attempt the eject. The previous code may have worked on drives that did not support the media lock feature.