1 /* 2 * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "FileSystem.h" 7 8 #include "AutoLocker.h" 9 #include "Volume.h" 10 11 12 FileSystem* FileSystem::sInstance = NULL; 13 14 15 // constructor 16 FileSystem::FileSystem(const char* fsName) 17 { 18 strlcpy(fName, fsName, sizeof(fName)); 19 20 sInstance = this; 21 } 22 23 24 // destructor 25 FileSystem::~FileSystem() 26 { 27 sInstance = NULL; 28 } 29 30 31 /*static*/ FileSystem* 32 FileSystem::GetInstance() 33 { 34 return sInstance; 35 } 36 37 38 void 39 FileSystem::InitRequestThreadContext(RequestThreadContext* context) 40 { 41 } 42 43 44 void 45 FileSystem::RegisterVolume(Volume* volume) 46 { 47 AutoLocker<Locker> _(fLock); 48 fVolumes.Add(volume); 49 } 50 51 52 void 53 FileSystem::UnregisterVolume(Volume* volume) 54 { 55 AutoLocker<Locker> _(fLock); 56 fVolumes.Remove(volume); 57 } 58 59 60 Volume* 61 FileSystem::VolumeWithID(dev_t id) 62 { 63 AutoLocker<Locker> _(fLock); 64 65 VolumeList::Iterator it = fVolumes.GetIterator(); 66 while (Volume* volume = it.Next()) { 67 if (volume->GetID() == id) 68 return volume; 69 } 70 71 return NULL; 72 } 73