From d3a46694d5bb611f98a7df5ff3551731a6db9492 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 1 May 2015 08:06:05 +0200 Subject: [PATCH] Fix "eject when unmounting". It seems getting the device from the partition after it is unmounted does not work reliably. Get the device much earlier in the function, before actually unmounting it. Fixes #2630. --- src/servers/mount/AutoMounter.cpp | 12 ++++++++---- src/servers/mount/Jamfile | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/servers/mount/AutoMounter.cpp b/src/servers/mount/AutoMounter.cpp index 8248ed706e..74545f15b6 100644 --- a/src/servers/mount/AutoMounter.cpp +++ b/src/servers/mount/AutoMounter.cpp @@ -616,11 +616,15 @@ void AutoMounter::_UnmountAndEjectVolume(BPartition* partition, BPath& mountPoint, const char* name) { - BDiskDevice device; + BDiskDevice deviceStorage; + BDiskDevice* device; if (partition == NULL) { // Try to retrieve partition BDiskDeviceRoster().FindPartitionByMountPoint(mountPoint.Path(), - &device, &partition); + &deviceStorage, &partition); + device = &deviceStorage; + } else { + device = partition->Device(); } status_t status; @@ -678,10 +682,10 @@ AutoMounter::_UnmountAndEjectVolume(BPartition* partition, BPath& mountPoint, bool fHasMounted; } visitor; - partition->Device()->VisitEachDescendant(&visitor); + device->VisitEachDescendant(&visitor); if (!visitor.HasMountedPartitions()) - partition->Device()->Eject(); + device->Eject(); } // remove the directory if it's a directory in rootfs diff --git a/src/servers/mount/Jamfile b/src/servers/mount/Jamfile index 15fa0d58b7..469feef6c7 100644 --- a/src/servers/mount/Jamfile +++ b/src/servers/mount/Jamfile @@ -3,8 +3,8 @@ SubDir HAIKU_TOP src servers mount ; UsePrivateHeaders mount shared storage ; Server mount_server - : - AutoMounter.cpp + : + AutoMounter.cpp # AutoMounterSettings.cpp : libbe.so localestub