1 // VolumeManager.h 2 3 #ifndef NET_FS_VOLUME_MANAGER_H 4 #define NET_FS_VOLUME_MANAGER_H 5 6 #include "Locker.h" 7 #include "Volume.h" 8 9 class QueryManager; 10 class RootVolume; 11 class Volume; 12 class VolumeEvent; 13 14 // VolumeManager 15 class VolumeManager : private Locker { 16 public: 17 VolumeManager(nspace_id id, uint32 flags); 18 ~VolumeManager(); 19 20 nspace_id GetID() const { return fID; } 21 uint32 GetMountFlags() const { return fMountFlags; } 22 uid_t GetMountUID() const { return fMountUID; } 23 uid_t GetMountGID() const { return fMountGID; } 24 25 status_t MountRootVolume(const char* device, 26 const char* parameters, int32 len, 27 Volume** volume); 28 void UnmountRootVolume(); 29 30 QueryManager* GetQueryManager() const; 31 32 Volume* GetRootVolume(); 33 status_t AddVolume(Volume* volume); 34 Volume* GetVolume(vnode_id nodeID); 35 private: 36 Volume* GetVolume(Volume* volume); 37 // TODO: This is actually a bit dangerous, since the volume 38 // might be delete and another one reallocated at the same 39 // location. (Use the node ID of its root node instead?!) 40 public: 41 void PutVolume(Volume* volume); 42 43 vnode_id NewNodeID(Volume* volume); 44 void RemoveNodeID(vnode_id nodeID); 45 46 void SendVolumeEvent(VolumeEvent* event); 47 48 private: 49 struct VolumeSet; 50 struct NodeIDVolumeMap; 51 class VolumeEventQueue; 52 53 static int32 _EventDelivererEntry(void* data); 54 int32 _EventDeliverer(); 55 56 private: 57 nspace_id fID; 58 uint32 fMountFlags; 59 uid_t fMountUID; 60 gid_t fMountGID; 61 vnode_id fRootID; 62 volatile vnode_id fNextNodeID; 63 QueryManager* fQueryManager; 64 VolumeSet* fVolumes; 65 NodeIDVolumeMap* fNodeIDs2Volumes; 66 VolumeEventQueue* fVolumeEvents; 67 thread_id fEventDeliverer; 68 }; 69 70 // VolumePutter 71 class VolumePutter { 72 public: 73 VolumePutter(Volume* volume) 74 : fVolume(volume) 75 { 76 } 77 78 ~VolumePutter() 79 { 80 Put(); 81 } 82 83 void Put() 84 { 85 if (fVolume) { 86 fVolume->PutVolume(); 87 fVolume = NULL; 88 } 89 } 90 91 void Detach() 92 { 93 fVolume = NULL; 94 } 95 96 private: 97 Volume* fVolume; 98 }; 99 100 #endif // NET_FS_VOLUME_MANAGER_H 101