xref: /haiku/src/servers/mount/AutoMounter.h (revision b247f935d133a42c427cad8a759a1bf2f65bc290)
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 class AutoMounter : public BServer {
20 public:
21 								AutoMounter();
22 	virtual						~AutoMounter();
23 
24 	virtual	void				ReadyToRun();
25 	virtual	void				MessageReceived(BMessage* message);
26 	virtual	bool				QuitRequested();
27 
28 private:
29 			enum mount_mode {
30 				kNoVolumes,
31 				kOnlyBFSVolumes,
32 				kAllVolumes,
33 				kRestorePreviousVolumes
34 			};
35 
36 			void				_GetSettings(BMessage* message);
37 
38 			void				_MountVolumes(mount_mode normal,
39 									mount_mode removable,
40 									bool initialRescan = false,
41 									partition_id deviceID = -1);
42 			void				_MountVolume(const BMessage* message);
43 			bool				_SuggestForceUnmount(const char* name,
44 									status_t error);
45 			void				_ReportUnmountError(const char* name,
46 									status_t error);
47 			void				_UnmountAndEjectVolume(BPartition* partition,
48 									BPath& mountPoint, const char* name);
49 			void				_UnmountAndEjectVolume(BMessage* message);
50 
51 			void				_FromMode(mount_mode mode, bool& all,
52 									bool& bfs, bool& restore);
53 			mount_mode			_ToMode(bool all, bool bfs,
54 									bool restore = false);
55 
56 			void				_UpdateSettingsFromMessage(BMessage* message);
57 			void				_ReadSettings();
58 			void				_WriteSettings();
59 
60 	static	bool				_SuggestMountFlags(const BPartition* partition,
61 									uint32* _flags);
62 
63 private:
64 			mount_mode			fNormalMode;
65 			mount_mode			fRemovableMode;
66 			bool				fEjectWhenUnmounting;
67 
68 			BFile				fPrefsFile;
69 			BMessage			fSettings;
70 };
71 
72 
73 #endif // AUTO_MOUNTER_H
74