Skip to content

Commit

Permalink
Fix "eject when unmounting".
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pulkomandy committed May 1, 2015
1 parent 487d015 commit d3a4669
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/servers/mount/AutoMounter.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/servers/mount/Jamfile
Expand Up @@ -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
Expand Down

0 comments on commit d3a4669

Please sign in to comment.