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
12FileSystem* FileSystem::sInstance = NULL;
13
14
15// constructor
16FileSystem::FileSystem(const char* fsName)
17{
18	strlcpy(fName, fsName, sizeof(fName));
19
20	sInstance = this;
21}
22
23
24// destructor
25FileSystem::~FileSystem()
26{
27	sInstance = NULL;
28}
29
30
31/*static*/ FileSystem*
32FileSystem::GetInstance()
33{
34	return sInstance;
35}
36
37
38void
39FileSystem::InitRequestThreadContext(RequestThreadContext* context)
40{
41}
42
43
44void
45FileSystem::RegisterVolume(Volume* volume)
46{
47	AutoLocker<Locker> _(fLock);
48	fVolumes.Add(volume);
49}
50
51
52void
53FileSystem::UnregisterVolume(Volume* volume)
54{
55	AutoLocker<Locker> _(fLock);
56	fVolumes.Remove(volume);
57}
58
59
60Volume*
61FileSystem::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