xref: /haiku/src/add-ons/kernel/file_systems/netfs/client/VirtualVolume.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 // VirtualVolume.h
2 
3 #ifndef NET_FS_VIRTUAL_VOLUME_H
4 #define NET_FS_VIRTUAL_VOLUME_H
5 
6 #include <fsproto.h>
7 
8 #include "Locker.h"
9 #include "VirtualDir.h"
10 #include "Volume.h"
11 
12 class VirtualNode;
13 
14 class VirtualVolume : public Volume {
15 public:
16 								VirtualVolume(VolumeManager* volumeManager);
17 								~VirtualVolume();
18 
19 			status_t			Init(const char* name);
20 			void				Uninit();
21 
22 	virtual	Node*				GetRootNode() const;
23 
24 	virtual	void				PrepareToUnmount();
25 
26 	virtual	status_t			AddChildVolume(Volume* volume);
27 	virtual	void				RemoveChildVolume(Volume* volume);
28 	virtual	Volume*				GetChildVolume(const char* name);
29 
30 			status_t			GetUniqueEntryName(const char* baseName,
31 									char* buffer);
32 
33 			// FS
34 	virtual	status_t			Unmount();
35 	virtual	status_t			Sync();
36 
37 			// vnodes
38 	virtual	status_t			ReadVNode(vnode_id vnid, char reenter,
39 									Node** node);
40 	virtual	status_t			WriteVNode(Node* node, char reenter);
41 	virtual	status_t			RemoveVNode(Node* node, char reenter);
42 
43 			// nodes
44 	virtual	status_t			FSync(Node* node);
45 	virtual	status_t			ReadStat(Node* node, struct stat* st);
46 	virtual	status_t			WriteStat(Node* node, struct stat *st,
47 									uint32 mask);
48 	virtual	status_t			Access(Node* node, int mode);
49 
50 			// files
51 	virtual	status_t			Create(Node* dir, const char* name,
52 									int openMode, int mode, vnode_id* vnid,
53 									void** cookie);
54 	virtual	status_t			Open(Node* node, int openMode,
55 									void** cookie);
56 	virtual	status_t			Close(Node* node, void* cookie);
57 	virtual	status_t			FreeCookie(Node* node, void* cookie);
58 	virtual	status_t			Read(Node* node, void* cookie, off_t pos,
59 									void* buffer, size_t bufferSize,
60 									size_t* bytesRead);
61 	virtual	status_t			Write(Node* node, void* cookie, off_t pos,
62 									const void* buffer, size_t bufferSize,
63 									size_t* bytesWritten);
64 	virtual	status_t			IOCtl(Node* node, void* cookie, int cmd,
65 									void* buffer, size_t bufferSize);
66 	virtual	status_t			SetFlags(Node* node, void* cookie,
67 									int flags);
68 
69 			// hard links / symlinks
70 	virtual	status_t			Link(Node* dir, const char* name,
71 									Node* node);
72 	virtual	status_t			Unlink(Node* dir, const char* name);
73 	virtual	status_t			Symlink(Node* dir, const char* name,
74 									const char* target);
75 	virtual	status_t			ReadLink(Node* node, char* buffer,
76 									size_t bufferSize, size_t* bytesRead);
77 	virtual	status_t			Rename(Node* oldDir, const char* oldName,
78 									Node* newDir, const char* newName);
79 
80 			// directories
81 	virtual	status_t			MkDir(Node* dir, const char* name,
82 									int mode);
83 	virtual	status_t			RmDir(Node* dir, const char* name);
84 	virtual	status_t			OpenDir(Node* node, void** cookie);
85 	virtual	status_t			CloseDir(Node* node, void* cookie);
86 	virtual	status_t			FreeDirCookie(Node* node, void* cookie);
87 	virtual	status_t			ReadDir(Node* node, void* cookie,
88 									struct dirent* buffer, size_t bufferSize,
89 									int32 count, int32* countRead);
90 	virtual	status_t			RewindDir(Node* node, void* cookie);
91 	virtual	status_t			Walk(Node* dir, const char* entryName,
92 									char** resolvedPath, vnode_id* vnid);
93 
94 			// attributes
95 	virtual	status_t			OpenAttrDir(Node* node, void** cookie);
96 	virtual	status_t			CloseAttrDir(Node* node, void* cookie);
97 	virtual	status_t			FreeAttrDirCookie(Node* node,
98 									void* cookie);
99 	virtual	status_t			ReadAttrDir(Node* node, void* cookie,
100 									struct dirent* buffer, size_t bufferSize,
101 									int32 count, int32* countRead);
102 	virtual	status_t			RewindAttrDir(Node* node, void* cookie);
103 	virtual	status_t			ReadAttr(Node* node, const char* name,
104 									int type, off_t pos, void* buffer,
105 									size_t bufferSize, size_t* bytesRead);
106 	virtual	status_t			WriteAttr(Node* node, const char* name,
107 									int type, off_t pos, const void* buffer,
108 									size_t bufferSize, size_t* bytesWritten);
109 	virtual	status_t			RemoveAttr(Node* node, const char* name);
110 	virtual	status_t			RenameAttr(Node* node,
111 									const char* oldName, const char* newName);
112 	virtual	status_t			StatAttr(Node* node, const char* name,
113 									struct attr_info* attrInfo);
114 
115 			// queries
116 	virtual	status_t			OpenQuery(const char* queryString,
117 									uint32 flags, port_id port, int32 token,
118 									QueryIterator** iterator);
119 	virtual	void				FreeQueryIterator(QueryIterator* iterator);
120 	virtual	status_t			ReadQuery(QueryIterator* iterator,
121 									struct dirent* buffer, size_t bufferSize,
122 									int32 count, int32* countRead);
123 
124 protected:
125 			VirtualDir*			fRootNode;
126 };
127 
128 #endif	// NET_FS_VIRTUAL_VOLUME_H
129