From be5788f81c287a211ea88214ecbc541c562adcb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 12 May 2009 18:32:11 +0000 Subject: [PATCH] Fixed a number of remaining problems with the AutoMounter: * During boot, the mount mode was ignored for any removable volumes, they simply got mounted always. * When automounting later, all partitions on all removable devices would be mounted, not only the ones on the newly inserted device. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30719 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/AutoMounter.cpp | 43 +++++++++++++++++++++----------- src/kits/tracker/AutoMounter.h | 5 +++- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/kits/tracker/AutoMounter.cpp b/src/kits/tracker/AutoMounter.cpp index fac3dbb3aa..b4d607bcb8 100644 --- a/src/kits/tracker/AutoMounter.cpp +++ b/src/kits/tracker/AutoMounter.cpp @@ -165,7 +165,7 @@ suggest_mount_flags(const BPartition* partition, uint32* _flags) void AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable, - bool initialRescan) + bool initialRescan, partition_id deviceID) { if (normal == kNoVolumes && removable == kNoVolumes) return; @@ -173,12 +173,14 @@ AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable, class InitialMountVisitor : public BDiskDeviceVisitor { public: InitialMountVisitor(mount_mode normalMode, mount_mode removableMode, - bool initialRescan, BMessage& previous) + bool initialRescan, BMessage& previous, + partition_id deviceID) : fNormalMode(normalMode), fRemovableMode(removableMode), fInitialRescan(initialRescan), - fPrevious(previous) + fPrevious(previous), + fOnlyOnDeviceID(deviceID) { } @@ -196,7 +198,17 @@ AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable, virtual bool Visit(BPartition* partition, int32 level) { - mount_mode mode = partition->Device()->IsRemovableMedia() + if (fOnlyOnDeviceID >= 0) { + // only mount partitions on the given device id + BPartition* device = partition; + while (device->Parent() != NULL) + device = device->Parent(); + if (device->ID() != fOnlyOnDeviceID) + return false; + } + + mount_mode mode = !fInitialRescan + && partition->Device()->IsRemovableMedia() ? fRemovableMode : fNormalMode; if (mode == kNoVolumes || partition->IsMounted() @@ -248,11 +260,12 @@ AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable, } private: - mount_mode fNormalMode; - mount_mode fRemovableMode; - bool fInitialRescan; - BMessage& fPrevious; - } visitor(normal, removable, initialRescan, fSettings); + mount_mode fNormalMode; + mount_mode fRemovableMode; + bool fInitialRescan; + BMessage& fPrevious; + partition_id fOnlyOnDeviceID; + } visitor(normal, removable, initialRescan, fSettings, deviceID); BDiskDeviceList devices; status_t status = devices.Fetch(); @@ -638,24 +651,26 @@ AutoMounter::MessageReceived(BMessage* message) _WriteSettings(); if (rescanNow) - _MountVolumes(fNormalMode, fRemovableMode, false); + _MountVolumes(fNormalMode, fRemovableMode); break; } case kMountAllNow: - _MountVolumes(kAllVolumes, kAllVolumes, false); + _MountVolumes(kAllVolumes, kAllVolumes); break; case B_DEVICE_UPDATE: -printf("B_DEVICE_UPDATE\n"); -message->PrintToStream(); int32 event; if (message->FindInt32("event", &event) != B_OK || (event != B_DEVICE_MEDIA_CHANGED && event != B_DEVICE_ADDED)) break; - _MountVolumes(kNoVolumes, fRemovableMode, false); + partition_id deviceID; + if (message->FindInt32("id", &deviceID) != B_OK) + break; + + _MountVolumes(kNoVolumes, fRemovableMode, false, deviceID); break; #if 0 diff --git a/src/kits/tracker/AutoMounter.h b/src/kits/tracker/AutoMounter.h index f027d701c7..6456fae5ab 100644 --- a/src/kits/tracker/AutoMounter.h +++ b/src/kits/tracker/AutoMounter.h @@ -42,6 +42,7 @@ All rights reserved. #ifndef __HAIKU__ # include "DeviceMap.h" #else +# include class BPartition; class BPath; #endif @@ -74,7 +75,9 @@ private: }; void _MountVolumes(mount_mode normal, - mount_mode removable, bool initialRescan); + mount_mode removable, + bool initialRescan = false, + partition_id deviceID = -1); void _MountVolume(const BMessage* message); bool _SuggestForceUnmount(const char* name, status_t error);