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
This commit is contained in:
Stephan Aßmus
2009-05-12 18:32:11 +00:00
parent 83936c1c26
commit be5788f81c
2 changed files with 33 additions and 15 deletions
+29 -14
View File
@@ -165,7 +165,7 @@ suggest_mount_flags(const BPartition* partition, uint32* _flags)
void void
AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable, AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable,
bool initialRescan) bool initialRescan, partition_id deviceID)
{ {
if (normal == kNoVolumes && removable == kNoVolumes) if (normal == kNoVolumes && removable == kNoVolumes)
return; return;
@@ -173,12 +173,14 @@ AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable,
class InitialMountVisitor : public BDiskDeviceVisitor { class InitialMountVisitor : public BDiskDeviceVisitor {
public: public:
InitialMountVisitor(mount_mode normalMode, mount_mode removableMode, InitialMountVisitor(mount_mode normalMode, mount_mode removableMode,
bool initialRescan, BMessage& previous) bool initialRescan, BMessage& previous,
partition_id deviceID)
: :
fNormalMode(normalMode), fNormalMode(normalMode),
fRemovableMode(removableMode), fRemovableMode(removableMode),
fInitialRescan(initialRescan), fInitialRescan(initialRescan),
fPrevious(previous) fPrevious(previous),
fOnlyOnDeviceID(deviceID)
{ {
} }
@@ -196,7 +198,17 @@ AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable,
virtual bool virtual bool
Visit(BPartition* partition, int32 level) 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; ? fRemovableMode : fNormalMode;
if (mode == kNoVolumes if (mode == kNoVolumes
|| partition->IsMounted() || partition->IsMounted()
@@ -248,11 +260,12 @@ AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable,
} }
private: private:
mount_mode fNormalMode; mount_mode fNormalMode;
mount_mode fRemovableMode; mount_mode fRemovableMode;
bool fInitialRescan; bool fInitialRescan;
BMessage& fPrevious; BMessage& fPrevious;
} visitor(normal, removable, initialRescan, fSettings); partition_id fOnlyOnDeviceID;
} visitor(normal, removable, initialRescan, fSettings, deviceID);
BDiskDeviceList devices; BDiskDeviceList devices;
status_t status = devices.Fetch(); status_t status = devices.Fetch();
@@ -638,24 +651,26 @@ AutoMounter::MessageReceived(BMessage* message)
_WriteSettings(); _WriteSettings();
if (rescanNow) if (rescanNow)
_MountVolumes(fNormalMode, fRemovableMode, false); _MountVolumes(fNormalMode, fRemovableMode);
break; break;
} }
case kMountAllNow: case kMountAllNow:
_MountVolumes(kAllVolumes, kAllVolumes, false); _MountVolumes(kAllVolumes, kAllVolumes);
break; break;
case B_DEVICE_UPDATE: case B_DEVICE_UPDATE:
printf("B_DEVICE_UPDATE\n");
message->PrintToStream();
int32 event; int32 event;
if (message->FindInt32("event", &event) != B_OK if (message->FindInt32("event", &event) != B_OK
|| (event != B_DEVICE_MEDIA_CHANGED || (event != B_DEVICE_MEDIA_CHANGED
&& event != B_DEVICE_ADDED)) && event != B_DEVICE_ADDED))
break; break;
_MountVolumes(kNoVolumes, fRemovableMode, false); partition_id deviceID;
if (message->FindInt32("id", &deviceID) != B_OK)
break;
_MountVolumes(kNoVolumes, fRemovableMode, false, deviceID);
break; break;
#if 0 #if 0
+4 -1
View File
@@ -42,6 +42,7 @@ All rights reserved.
#ifndef __HAIKU__ #ifndef __HAIKU__
# include "DeviceMap.h" # include "DeviceMap.h"
#else #else
# include <DiskDeviceDefs.h>
class BPartition; class BPartition;
class BPath; class BPath;
#endif #endif
@@ -74,7 +75,9 @@ private:
}; };
void _MountVolumes(mount_mode normal, 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); void _MountVolume(const BMessage* message);
bool _SuggestForceUnmount(const char* name, bool _SuggestForceUnmount(const char* name,
status_t error); status_t error);