1 /* 2 * Copyright 2007-2015, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef AUTO_MOUNTER_H 6 #define AUTO_MOUNTER_H 7 8 9 #include <DiskDeviceDefs.h> 10 #include <File.h> 11 #include <Message.h> 12 #include <Server.h> 13 14 15 class BPartition; 16 class BPath; 17 18 19 enum mount_mode { 20 kNoVolumes, 21 kOnlyBFSVolumes, 22 kAllVolumes, 23 kRestorePreviousVolumes 24 }; 25 26 27 class AutoMounter : public BServer { 28 public: 29 AutoMounter(); 30 virtual ~AutoMounter(); 31 32 virtual void ReadyToRun(); 33 virtual void MessageReceived(BMessage* message); 34 virtual bool QuitRequested(); 35 36 private: 37 void _GetSettings(BMessage* message); 38 39 void _MountVolumes(mount_mode normal, 40 mount_mode removable, 41 bool initialRescan = false, 42 partition_id deviceID = -1); 43 void _MountVolume(const BMessage* message); 44 bool _SuggestForceUnmount(const char* name, 45 status_t error); 46 void _ReportUnmountError(const char* name, 47 status_t error); 48 void _UnmountAndEjectVolume(BPartition* partition, 49 BPath& mountPoint, const char* name); 50 void _UnmountAndEjectVolume(BMessage* message); 51 52 void _FromMode(mount_mode mode, bool& all, 53 bool& bfs, bool& restore); 54 mount_mode _ToMode(bool all, bool bfs, 55 bool restore = false); 56 57 void _UpdateSettingsFromMessage(BMessage* message); 58 void _ReadSettings(); 59 void _WriteSettings(); 60 61 static bool _SuggestMountFlags(const BPartition* partition, 62 uint32* _flags); 63 64 friend class MountVisitor; 65 66 private: 67 mount_mode fNormalMode; 68 mount_mode fRemovableMode; 69 bool fEjectWhenUnmounting; 70 71 BFile fPrefsFile; 72 BMessage fSettings; 73 }; 74 75 76 #endif // AUTO_MOUNTER_H 77