xref: /haiku/src/add-ons/kernel/file_systems/userlandfs/server/FileSystem.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef USERLAND_FS_FILE_SYSTEM_H
6 #define USERLAND_FS_FILE_SYSTEM_H
7 
8 #include <fs_interface.h>
9 #include <image.h>
10 #include <OS.h>
11 
12 #include <kernel/util/DoublyLinkedList.h>
13 
14 #include "FSCapabilities.h"
15 #include "Locker.h"
16 
17 
18 namespace UserlandFS {
19 
20 class RequestThreadContext;
21 class Volume;
22 
23 
24 class FileSystem {
25 public:
26 								FileSystem(const char* fsName);
27 	virtual						~FileSystem();
28 
29 	static	FileSystem*			GetInstance();
30 
31 			const char*			GetName() const	{ return fName; }
32 
33 	virtual	status_t			CreateVolume(Volume** volume, dev_t id) = 0;
34 	virtual	status_t			DeleteVolume(Volume* volume) = 0;
35 
36 	virtual	void				InitRequestThreadContext(
37 									RequestThreadContext* context);
38 
39 			void				RegisterVolume(Volume* volume);
40 			void				UnregisterVolume(Volume* volume);
41 			Volume*				VolumeWithID(dev_t id);
42 
43 			void				GetCapabilities(
44 									FSCapabilities& capabilities) const
45 									{ capabilities = fCapabilities; }
46 			client_fs_type		GetClientFSType() const
47 									{ return fClientFSType; }
48 
49 protected:
50 			typedef DoublyLinkedList<Volume> VolumeList;
51 
52 protected:
53 			Locker				fLock;
54 			VolumeList			fVolumes;
55 			FSCapabilities		fCapabilities;
56 			client_fs_type		fClientFSType;
57 			char				fName[B_FILE_NAME_LENGTH];
58 
59 	static	FileSystem*			sInstance;
60 };
61 
62 }	// namespace UserlandFS
63 
64 using UserlandFS::FileSystem;
65 
66 
67 // implemented by the interface implementations
68 extern "C" status_t userlandfs_create_file_system(const char* fsName,
69 	image_id image, FileSystem** _fileSystem);
70 
71 #endif	// USERLAND_FS_FILE_SYSTEM_H
72