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:
parent
bab57370a4
commit
7333992516
@ -57,6 +57,8 @@ public:
|
|||||||
void UpdateMediaStatusIfNeeded();
|
void UpdateMediaStatusIfNeeded();
|
||||||
void UninitializeMedia();
|
void UninitializeMedia();
|
||||||
|
|
||||||
|
void UpdateGeometry();
|
||||||
|
|
||||||
status_t SetPath(const char *path);
|
status_t SetPath(const char *path);
|
||||||
// TODO: Remove this method or make it private. Once initialized the
|
// TODO: Remove this method or make it private. Once initialized the
|
||||||
// path must not be changed.
|
// path must not be changed.
|
||||||
@ -85,6 +87,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void _ResetGeometry();
|
void _ResetGeometry();
|
||||||
void _InitPartitionData();
|
void _InitPartitionData();
|
||||||
|
void _UpdateDeviceFlags();
|
||||||
|
|
||||||
disk_device_data fDeviceData;
|
disk_device_data fDeviceData;
|
||||||
RWLocker fLocker;
|
RWLocker fLocker;
|
||||||
|
@ -74,15 +74,9 @@ KDiskDevice::SetTo(const char *path)
|
|||||||
if (GetGeometry(&fDeviceData.geometry) != B_OK)
|
if (GetGeometry(&fDeviceData.geometry) != B_OK)
|
||||||
_ResetGeometry();
|
_ResetGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set device flags
|
// set device flags
|
||||||
if (fDeviceData.geometry.removable)
|
_UpdateDeviceFlags();
|
||||||
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);
|
|
||||||
// update partition data
|
// update partition data
|
||||||
_InitPartitionData();
|
_InitPartitionData();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@ -247,6 +241,19 @@ KDiskDevice::UninitializeMedia()
|
|||||||
{
|
{
|
||||||
UninitializeContents();
|
UninitializeContents();
|
||||||
_ResetGeometry();
|
_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;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1148,6 +1148,7 @@ KDiskDeviceManager::_CheckMediaStatus()
|
|||||||
|
|
||||||
if (device->MediaChanged()) {
|
if (device->MediaChanged()) {
|
||||||
dprintf("Media changed from %s\n", device->Path());
|
dprintf("Media changed from %s\n", device->Path());
|
||||||
|
device->UpdateGeometry();
|
||||||
_ScanPartition(device, false);
|
_ScanPartition(device, false);
|
||||||
} else if (!device->HasMedia() && hadMedia) {
|
} else if (!device->HasMedia() && hadMedia) {
|
||||||
dprintf("Media removed from %s\n", device->Path());
|
dprintf("Media removed from %s\n", device->Path());
|
||||||
|
Loading…
Reference in New Issue
Block a user