xref: /haiku/src/add-ons/kernel/file_systems/netfs/server/FDManager.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 // FDManager.h
2 
3 #ifndef NET_FS_FD_MANAGER_H
4 #define NET_FS_FD_MANAGER_H
5 
6 #include <SupportDefs.h>
7 
8 #include "Locker.h"
9 
10 class BDirectory;
11 class BEntry;
12 class BFile;
13 class BNode;
14 
15 class FDManager {
16 private:
17 								FDManager();
18 								~FDManager();
19 
20 			status_t			Init();
21 
22 public:
23 	static	status_t			CreateDefault();
24 	static	void				DeleteDefault();
25 	static	FDManager*			GetDefault();
26 
27 	static	status_t			SetDirectory(BDirectory* directory,
28 									const node_ref* ref);
29 	static	status_t			SetEntry(BEntry* entry, const entry_ref* ref);
30 	static	status_t			SetEntry(BEntry* entry, const char* path);
31 	static	status_t			SetFile(BFile* file, const char* path,
32 									uint32 openMode);
33 	static	status_t			SetNode(BNode* node, const entry_ref* ref);
34 
35 	static	status_t			Open(const char* path, uint32 openMode,
36 									mode_t mode, int& fd);
37 	static	status_t			OpenDir(const char* path, DIR*& dir);
38 	static	status_t			OpenAttrDir(const char* path, DIR*& dir);
39 
40 private:
41 			status_t			_IncreaseLimit();
42 
43 private:
44 			Locker				fLock;
45 			int32				fFDLimit;
46 
47 	static	FDManager*			sManager;
48 };
49 
50 #endif	// NET_FS_FD_MANAGER_H
51