* Implemented the AutoMounter for Haiku - it's barely tested at this point, but
at least mounting/unmounting seems to work. This fixes bug #191. * Also changed the way how Tracker automatically mounts/unmounts volumes: it now only differentiates between removable and fixed storage, not between initial scan at boot, and periodical scans during runtime. Also removed all HFS stuff. * Got rid of _INCLUDES_CLASS_DEVICE_MAP for the BeOS build. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19893 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+1146
-710
File diff suppressed because it is too large
Load Diff
+112
-69
@@ -39,19 +39,63 @@ All rights reserved.
|
|||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
#if OPEN_TRACKER
|
#ifndef __HAIKU__
|
||||||
#include "DeviceMap.h"
|
# include "DeviceMap.h"
|
||||||
#else
|
|
||||||
#include <private/storage/DeviceMap.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
const uint32 kMountVolume = 'mntv';
|
||||||
|
const uint32 kMountAllNow = 'mntn';
|
||||||
const uint32 kSetAutomounterParams = 'pmst';
|
const uint32 kSetAutomounterParams = 'pmst';
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
// #pragma mark - Haiku Disk Device API
|
||||||
|
|
||||||
|
class AutoMounter : public BLooper {
|
||||||
|
public:
|
||||||
|
AutoMounter();
|
||||||
|
virtual ~AutoMounter();
|
||||||
|
|
||||||
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
void GetSettings(BMessage* message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum mount_mode {
|
||||||
|
kNoVolumes,
|
||||||
|
kOnlyBFSVolumes,
|
||||||
|
kAllVolumes,
|
||||||
|
kRestorePreviousVolumes
|
||||||
|
};
|
||||||
|
|
||||||
|
void _MountVolumes(mount_mode normal, mount_mode removable);
|
||||||
|
void _MountVolume(BMessage* message);
|
||||||
|
bool _ForceUnmount(const char* name, status_t error);
|
||||||
|
void _ReportUnmountError(const char* name, status_t error);
|
||||||
|
void _UnmountAndEjectVolume(BMessage* message);
|
||||||
|
|
||||||
|
void _FromMode(mount_mode mode, bool& all, bool& bfs, bool& restore);
|
||||||
|
mount_mode _ToMode(bool all, bool bfs, bool restore = false);
|
||||||
|
void _UpdateSettingsFromMessage(BMessage* message);
|
||||||
|
void _ReadSettings();
|
||||||
|
void _WriteSettings();
|
||||||
|
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
mount_mode fNormalMode;
|
||||||
|
mount_mode fRemovableMode;
|
||||||
|
|
||||||
|
BFile fPrefsFile;
|
||||||
|
BMessage fSettings;
|
||||||
|
};
|
||||||
|
|
||||||
|
#else // !__HAIKU__
|
||||||
|
// #pragma mark - R5 DeviceMap API
|
||||||
|
|
||||||
const uint32 kSuspendAutomounter = 'amsp';
|
const uint32 kSuspendAutomounter = 'amsp';
|
||||||
const uint32 kResumeAutomounter = 'amsr';
|
const uint32 kResumeAutomounter = 'amsr';
|
||||||
const uint32 kMountAllNow = 'mntn';
|
|
||||||
const uint32 kMountVolume = 'mntv';
|
|
||||||
const uint32 kTryMountingFloppy = 'mntf';
|
const uint32 kTryMountingFloppy = 'mntf';
|
||||||
const uint32 kAutomounterRescan = 'rscn';
|
const uint32 kAutomounterRescan = 'rscn';
|
||||||
|
|
||||||
@@ -65,89 +109,88 @@ struct AutomountParams {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class AutoMounter : public BLooper {
|
class AutoMounter : public BLooper {
|
||||||
public:
|
public:
|
||||||
AutoMounter(
|
AutoMounter(
|
||||||
bool checkRemovableOnly = true, // do not poll nonremovable disks
|
bool checkRemovableOnly = true, // do not poll nonremovable disks
|
||||||
bool checkCDs = true, // currently ignored
|
bool checkCDs = true, // currently ignored
|
||||||
bool checkFloppies = false, //
|
bool checkFloppies = false, //
|
||||||
bool checkOtherRemovables = true, // currently ignored
|
bool checkOtherRemovables = true, // currently ignored
|
||||||
bool autoMountRemovableOnly = true, // if false, automount nonremovables too
|
bool autoMountRemovableOnly = true, // if false, automount nonremovables too
|
||||||
bool autoMountAll = false, // disregard the file system during autoumont
|
bool autoMountAll = false, // disregard the file system during autoumont
|
||||||
bool autoMountAllBFS = true, // automount bfs disks
|
bool autoMountAllBFS = true, // automount bfs disks
|
||||||
bool autoMountAllHFS = false, // automount hfs diska
|
bool autoMountAllHFS = false, // automount hfs diska
|
||||||
bool initialMountAll = false, // mount everything during boot
|
bool initialMountAll = false, // mount everything during boot
|
||||||
bool initialMountAllBFS = true, // mount every bfs volume during boot
|
bool initialMountAllBFS = true, // mount every bfs volume during boot
|
||||||
bool initialMountRestore = false, // restore volumes that were mounted at last shutdown
|
bool initialMountRestore = false, // restore volumes that were mounted at last shutdown
|
||||||
bool initialMountAllHFS = false); // mount every hfs volume during boot
|
bool initialMountAllHFS = false); // mount every hfs volume during boot
|
||||||
virtual ~AutoMounter();
|
virtual ~AutoMounter();
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
void GetSettings(BMessage *);
|
void GetSettings(BMessage *);
|
||||||
|
|
||||||
void CheckVolumesNow();
|
|
||||||
// mounts everything respecting the current automounting settings
|
|
||||||
// used to sync up right after settings changed
|
|
||||||
|
|
||||||
void EachMountableItemAndFloppy(EachPartitionFunction , void *);
|
void CheckVolumesNow();
|
||||||
void EachMountedItem(EachPartitionFunction, void *);
|
// mounts everything respecting the current automounting settings
|
||||||
Partition * EachPartition(EachPartitionFunction, void *);
|
// used to sync up right after settings changed
|
||||||
Partition *FindPartition(dev_t id);
|
|
||||||
|
|
||||||
private:
|
void EachMountableItemAndFloppy(EachPartitionFunction , void *);
|
||||||
void ReadSettings();
|
void EachMountedItem(EachPartitionFunction, void *);
|
||||||
void WriteSettings();
|
Partition * EachPartition(EachPartitionFunction, void *);
|
||||||
|
Partition *FindPartition(dev_t id);
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *);
|
private:
|
||||||
|
void ReadSettings();
|
||||||
void UnmountAndEjectVolume(BMessage *);
|
void WriteSettings();
|
||||||
void SetParams(BMessage *, bool rescan);
|
|
||||||
|
|
||||||
static status_t WatchVolumeBinder(void *);
|
virtual void MessageReceived(BMessage *);
|
||||||
void WatchVolumes();
|
|
||||||
|
|
||||||
static status_t InitialRescanBinder(void *);
|
void UnmountAndEjectVolume(BMessage *);
|
||||||
void InitialRescan();
|
void SetParams(BMessage *, bool rescan);
|
||||||
|
|
||||||
void SuspendResume(bool);
|
static status_t WatchVolumeBinder(void *);
|
||||||
|
void WatchVolumes();
|
||||||
|
|
||||||
void MountAllNow();
|
static status_t InitialRescanBinder(void *);
|
||||||
// used by the mount all now button
|
void InitialRescan();
|
||||||
// ignores the automounting settings and mounts everything it can
|
|
||||||
|
|
||||||
void MountVolume(BMessage *);
|
void SuspendResume(bool);
|
||||||
|
|
||||||
void RescanDevices();
|
void MountAllNow();
|
||||||
|
// used by the mount all now button
|
||||||
|
// ignores the automounting settings and mounts everything it can
|
||||||
|
|
||||||
|
void MountVolume(BMessage *);
|
||||||
|
|
||||||
void TryMountingFloppy();
|
void RescanDevices();
|
||||||
bool IsFloppyMounted();
|
|
||||||
bool FloppyInList();
|
|
||||||
|
|
||||||
#if _INCLUDES_CLASS_DEVICE_MAP
|
void TryMountingFloppy();
|
||||||
DeviceList fList;
|
bool IsFloppyMounted();
|
||||||
#endif
|
bool FloppyInList();
|
||||||
|
|
||||||
// automounter settings
|
DeviceList fList;
|
||||||
DeviceScanParams fScanParams;
|
|
||||||
AutomountParams fAutomountParams;
|
|
||||||
|
|
||||||
bool fInitialMountAll;
|
// automounter settings
|
||||||
bool fInitialMountAllBFS;
|
DeviceScanParams fScanParams;
|
||||||
bool fInitialMountRestore;
|
AutomountParams fAutomountParams;
|
||||||
bool fInitialMountAllHFS;
|
|
||||||
bool fSuspended;
|
bool fInitialMountAll;
|
||||||
|
bool fInitialMountAllBFS;
|
||||||
// misc.
|
bool fInitialMountRestore;
|
||||||
thread_id fScanThread;
|
bool fInitialMountAllHFS;
|
||||||
volatile bool fQuitting;
|
bool fSuspended;
|
||||||
|
|
||||||
BFile fPrefsFile;
|
// misc.
|
||||||
|
thread_id fScanThread;
|
||||||
|
volatile bool fQuitting;
|
||||||
|
|
||||||
|
BFile fPrefsFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
Partition *AddMountableItemToMessage(Partition *, void *);
|
Partition *AddMountableItemToMessage(Partition *, void *);
|
||||||
|
|
||||||
|
#endif // !__HAIKU__
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
#endif
|
#endif // _AUTO_MOUNTER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user