From f84387d6c4c44dfe083ad2ec14e25d89b903047c Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 13 Jun 2011 00:35:49 +0000 Subject: [PATCH] _user_initialize_partition(): After performing the operation don't set the new disk system, if the partition already has a disk system set. This can happen when the disk system's initialization function is lazy and just lets the DDM rescan the partition. In bad cases the previous disk system has a higher priority than the new one and, if its on-disk structures have not been destroyed, it will win the rescan. Not setting the disk system in such cases at least leaves the partition object in a consistent state. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42139 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../disk_device_manager/ddm_userland_interface.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp b/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp index 43ce5c7f2d..36cdefb1ec 100644 --- a/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp +++ b/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp @@ -1197,7 +1197,16 @@ _user_initialize_partition(partition_id partitionID, int32* _changeCounter, if (error != B_OK) return error; - partition->SetDiskSystem(diskSystem); + // Set the disk system. Re-check whether a disk system is already set on the + // partition. Some disk systems just write the on-disk structures and let + // the DDM rescan the partition, in which case the disk system will already + // be set. In very unfortunate cases the on-disk structure of the previous + // disk system has not been destroyed and the previous disk system has a + // higher priority than the new one. The old disk system will thus prevail. + // Not setting the new disk system will at least prevent that the partition + // object gets into an inconsistent state. + if (partition->DiskSystem() == NULL) + partition->SetDiskSystem(diskSystem); // return change counter error = copy_to_user_value(_changeCounter, partition->ChangeCounter());