|
|
1.1 root 1: /*
2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
3:
4: Governed by the TrueCrypt License 2.4 the full text of which is contained
5: in the file License.txt included in TrueCrypt binary and source code
6: distribution packages.
7: */
8:
9: #ifndef TC_HEADER_Driver_Fuse_FuseService
10: #define TC_HEADER_Driver_Fuse_FuseService
11:
12: #include "Platform/Platform.h"
13: #include "Platform/Unix/Process.h"
14: #include "Volume/VolumeInfo.h"
15: #include "Volume/Volume.h"
16:
17: namespace TrueCrypt
18: {
19:
20: class FuseService
21: {
22: protected:
23: struct ExecFunctor : public ProcessExecFunctor
24: {
25: ExecFunctor (shared_ptr <Volume> openVolume, VolumeSlotNumber slotNumber)
26: : MountedVolume (openVolume), SlotNumber (slotNumber)
27: {
28: }
29: virtual void operator() (int argc, char *argv[]);
30:
31: protected:
32: shared_ptr <Volume> MountedVolume;
33: VolumeSlotNumber SlotNumber;
34: };
35:
36: friend class ExecFunctor;
37:
38: public:
39: static bool CheckAccessRights ();
40: static void Dismount ();
41: static int ExceptionToErrorCode ();
42: static const char *GetControlPath () { return "/control"; }
43: static const char *GetVolumeImagePath ();
44: static string GetDeviceType () { return "truecrypt"; }
45: static uid_t GetGroupId () { return GroupId; }
46: static DevicePath GetLoopDevice () { return OpenVolumeInfo.LoopDevice; }
47: static uid_t GetUserId () { return UserId; }
48: static shared_ptr <Buffer> GetVolumeInfo ();
49: static uint64 GetVolumeSize ();
50: static uint64 GetVolumeSectorSize () { return MountedVolume->GetSectorSize(); }
51: static void Mount (shared_ptr <Volume> openVolume, VolumeSlotNumber slotNumber, const string &fuseMountPoint);
52: static void ReadVolumeSectors (const BufferPtr &buffer, uint64 byteOffset);
53: static void ReceiveLoopDevice (const ConstBufferPtr &buffer);
54: static void SendLoopDevice (const DirectoryPath &fuseMountPoint, const DevicePath &loopDevice);
55: static void WriteVolumeSectors (const ConstBufferPtr &buffer, uint64 byteOffset);
56:
57: protected:
58: FuseService ();
59:
60: static VolumeInfo OpenVolumeInfo;
61: static Mutex OpenVolumeInfoMutex;
62: static shared_ptr <Volume> MountedVolume;
63: static VolumeSlotNumber SlotNumber;
64: static uid_t UserId;
65: static gid_t GroupId;
66: };
67: }
68:
69: #endif // TC_HEADER_Driver_Fuse_FuseService
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.