* Added an UninitializeMedia() method to KDiskDevice that also resets the

device geometry.
* If SetTo() reports no media, and GetGeometry() fails, the device geometry
  is now reset as well.
* KDiskDeviceManager::_ScanPartition() no longer unmarks the partition busy;
  this is now done by the caller, and done independently from the outcome of
  _ScanPartition(). This also fixes the problem that devices with no media
  were never marked unbusy (and thus were ignored subsequently).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22912 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-11-12 23:20:33 +00:00
parent ef6f42349c
commit 88ef411154
3 changed files with 33 additions and 22 deletions
@@ -71,7 +71,8 @@ KDiskDevice::SetTo(const char *path)
} else {
// no media: try to get the device geometry, but don't fail, if
// we can't get it
GetGeometry(&fDeviceData.geometry);
if (GetGeometry(&fDeviceData.geometry) != B_OK)
_ResetGeometry();
}
// set device flags
if (fDeviceData.geometry.removable)
@@ -102,14 +103,7 @@ KDiskDevice::Unset()
free(fDeviceData.path);
fDeviceData.path = NULL;
}
fDeviceData.geometry.bytes_per_sector = 0;
fDeviceData.geometry.sectors_per_track = 0;
fDeviceData.geometry.cylinder_count = 0;
fDeviceData.geometry.head_count = 0;
fDeviceData.geometry.device_type = B_DISK;
fDeviceData.geometry.removable = true;
fDeviceData.geometry.read_only = true;
fDeviceData.geometry.write_once = false;
_ResetGeometry();
}
// InitCheck
@@ -248,6 +242,14 @@ KDiskDevice::UpdateMediaStatusIfNeeded()
}
void
KDiskDevice::UninitializeMedia()
{
UninitializeContents();
_ResetGeometry();
}
// SetPath
status_t
KDiskDevice::SetPath(const char *path)
@@ -383,3 +385,17 @@ KDiskDevice::_InitPartitionData()
fPartitionData.flags |= B_PARTITION_IS_DEVICE;
}
void
KDiskDevice::_ResetGeometry()
{
fDeviceData.geometry.bytes_per_sector = 0;
fDeviceData.geometry.sectors_per_track = 0;
fDeviceData.geometry.cylinder_count = 0;
fDeviceData.geometry.head_count = 0;
fDeviceData.geometry.device_type = B_DISK;
fDeviceData.geometry.removable = true;
fDeviceData.geometry.read_only = true;
fDeviceData.geometry.write_once = false;
}