On a media change, the KDiskDevice must do a bit more than it did:

* it now updates the partition data,
* the flags,
* and the disk geometry - and that now allows the session add-on to actually
  detect a newly inserted CD.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22918 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-11-13 12:18:06 +00:00
parent bab57370a4
commit 7333992516
3 changed files with 36 additions and 8 deletions

View File

@ -57,6 +57,8 @@ public:
void UpdateMediaStatusIfNeeded();
void UninitializeMedia();
void UpdateGeometry();
status_t SetPath(const char *path);
// TODO: Remove this method or make it private. Once initialized the
// path must not be changed.
@ -85,6 +87,7 @@ protected:
private:
void _ResetGeometry();
void _InitPartitionData();
void _UpdateDeviceFlags();
disk_device_data fDeviceData;
RWLocker fLocker;

View File

@ -74,15 +74,9 @@ KDiskDevice::SetTo(const char *path)
if (GetGeometry(&fDeviceData.geometry) != B_OK)
_ResetGeometry();
}
// set device flags
if (fDeviceData.geometry.removable)
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_REMOVABLE);
if (fMediaStatus == B_OK)
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_HAS_MEDIA);
if (fDeviceData.geometry.read_only)
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_READ_ONLY);
if (fDeviceData.geometry.write_once)
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_WRITE_ONCE);
_UpdateDeviceFlags();
// update partition data
_InitPartitionData();
return B_OK;
@ -247,6 +241,19 @@ KDiskDevice::UninitializeMedia()
{
UninitializeContents();
_ResetGeometry();
_UpdateDeviceFlags();
_InitPartitionData();
}
void
KDiskDevice::UpdateGeometry()
{
if (GetGeometry(&fDeviceData.geometry) != B_OK)
return;
_UpdateDeviceFlags();
_InitPartitionData();
}
@ -399,3 +406,20 @@ KDiskDevice::_ResetGeometry()
fDeviceData.geometry.write_once = false;
}
void
KDiskDevice::_UpdateDeviceFlags()
{
if (fDeviceData.geometry.removable)
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_REMOVABLE);
if (HasMedia())
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_HAS_MEDIA);
else
SetDeviceFlags(DeviceFlags() & ~B_DISK_DEVICE_HAS_MEDIA);
if (fDeviceData.geometry.read_only)
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_READ_ONLY);
if (fDeviceData.geometry.write_once)
SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_WRITE_ONCE);
}

View File

@ -1148,6 +1148,7 @@ KDiskDeviceManager::_CheckMediaStatus()
if (device->MediaChanged()) {
dprintf("Media changed from %s\n", device->Path());
device->UpdateGeometry();
_ScanPartition(device, false);
} else if (!device->HasMedia() && hadMedia) {
dprintf("Media removed from %s\n", device->Path());