xref: /haiku/src/add-ons/kernel/file_systems/userlandfs/server/Volume.h (revision 3cf43c26516b695e35b7433196a530f7541c4ca8)
14649fe05SIngo Weinhold /*
24649fe05SIngo Weinhold  * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
34649fe05SIngo Weinhold  * Distributed under the terms of the MIT License.
44649fe05SIngo Weinhold  */
55d3147f6SIngo Weinhold #ifndef USERLAND_FS_VOLUME_H
65d3147f6SIngo Weinhold #define USERLAND_FS_VOLUME_H
75d3147f6SIngo Weinhold 
88474904eSIngo Weinhold #include <fs_interface.h>
95d3147f6SIngo Weinhold #include <SupportDefs.h>
105d3147f6SIngo Weinhold 
119accd619SIngo Weinhold #include <kernel/util/DoublyLinkedList.h>
129accd619SIngo Weinhold 
13cdebdeb0SIngo Weinhold #include "FSCapabilities.h"
14cdebdeb0SIngo Weinhold 
159accd619SIngo Weinhold 
165d3147f6SIngo Weinhold namespace UserlandFS {
175d3147f6SIngo Weinhold 
185d3147f6SIngo Weinhold class FileSystem;
19f1c6ce08SIngo Weinhold class IORequestInfo;
205d3147f6SIngo Weinhold 
21cdebdeb0SIngo Weinhold using UserlandFSUtil::FSVolumeCapabilities;
22cdebdeb0SIngo Weinhold 
239accd619SIngo Weinhold class Volume : public DoublyLinkedListLinkImpl<Volume> {
245d3147f6SIngo Weinhold public:
25245aecdaSAxel Dörfler 								Volume(FileSystem* fileSystem, dev_t id);
265d3147f6SIngo Weinhold 	virtual						~Volume();
275d3147f6SIngo Weinhold 
285d3147f6SIngo Weinhold 			FileSystem*			GetFileSystem() const;
29245aecdaSAxel Dörfler 			dev_t				GetID() const;
305d3147f6SIngo Weinhold 
GetCapabilities(FSVolumeCapabilities & capabilities)31cdebdeb0SIngo Weinhold 			void				GetCapabilities(
32cdebdeb0SIngo Weinhold 									FSVolumeCapabilities& capabilities) const
33cdebdeb0SIngo Weinhold 									{ capabilities = fCapabilities; }
34cdebdeb0SIngo Weinhold 
355d3147f6SIngo Weinhold 	// FS
368474904eSIngo Weinhold 	virtual	status_t			Mount(const char* device, uint32 flags,
37245aecdaSAxel Dörfler 									const char* parameters, ino_t* rootID);
385d3147f6SIngo Weinhold 	virtual	status_t			Unmount();
395d3147f6SIngo Weinhold 	virtual	status_t			Sync();
408474904eSIngo Weinhold 	virtual	status_t			ReadFSInfo(fs_info* info);
418474904eSIngo Weinhold 	virtual	status_t			WriteFSInfo(const struct fs_info* info,
428474904eSIngo Weinhold 									uint32 mask);
435d3147f6SIngo Weinhold 
445d3147f6SIngo Weinhold 	// vnodes
45cdebdeb0SIngo Weinhold 	virtual	status_t			Lookup(void* dir, const char* entryName,
46cdebdeb0SIngo Weinhold 									ino_t* vnid);
479accd619SIngo Weinhold 	virtual	status_t			GetVNodeType(void* node, int* type);
489accd619SIngo Weinhold 									// Only needs to be implemented when
499accd619SIngo Weinhold 									// the three parameters publish_vnode() is
509accd619SIngo Weinhold 									// used.
51cdebdeb0SIngo Weinhold 	virtual	status_t			GetVNodeName(void* node, char* buffer,
52ed07b9c7SIngo Weinhold 									size_t bufferSize);
53245aecdaSAxel Dörfler 	virtual	status_t			ReadVNode(ino_t vnid, bool reenter,
544649fe05SIngo Weinhold 									void** node, int* type, uint32* flags,
554649fe05SIngo Weinhold 									FSVNodeCapabilities* _capabilities);
56cdebdeb0SIngo Weinhold 	virtual	status_t			WriteVNode(void* node, bool reenter);
57cdebdeb0SIngo Weinhold 	virtual	status_t			RemoveVNode(void* node, bool reenter);
585d3147f6SIngo Weinhold 
59f1c6ce08SIngo Weinhold 	// asynchronous I/O
60f1c6ce08SIngo Weinhold 	virtual	status_t			DoIO(void* node, void* cookie,
617c1ffcb9SIngo Weinhold 									const IORequestInfo& requestInfo);
62f1c6ce08SIngo Weinhold 	virtual	status_t			CancelIO(void* node, void* cookie,
63f1c6ce08SIngo Weinhold 									int32 ioRequestID);
64c76e8d36SIngo Weinhold 	virtual	status_t			IterativeIOGetVecs(void* cookie,
65c76e8d36SIngo Weinhold 									int32 requestID, off_t offset, size_t size,
66c76e8d36SIngo Weinhold 									struct file_io_vec* vecs, size_t* _count);
67c76e8d36SIngo Weinhold 	virtual	status_t			IterativeIOFinished(void* cookie,
68c76e8d36SIngo Weinhold 									int32 requestID, status_t status,
69c76e8d36SIngo Weinhold 									bool partialTransfer,
70c76e8d36SIngo Weinhold 									size_t bytesTransferred);
71f1c6ce08SIngo Weinhold 
725d3147f6SIngo Weinhold 	// nodes
73cdebdeb0SIngo Weinhold 	virtual	status_t			IOCtl(void* node, void* cookie,
748474904eSIngo Weinhold 									uint32 command, void* buffer, size_t size);
75cdebdeb0SIngo Weinhold 	virtual	status_t			SetFlags(void* node, void* cookie,
768474904eSIngo Weinhold 									int flags);
77cdebdeb0SIngo Weinhold 	virtual	status_t			Select(void* node, void* cookie,
78cdebdeb0SIngo Weinhold 									uint8 event, selectsync* sync);
79cdebdeb0SIngo Weinhold 	virtual	status_t			Deselect(void* node, void* cookie,
808474904eSIngo Weinhold 									uint8 event, selectsync* sync);
818474904eSIngo Weinhold 
82cdebdeb0SIngo Weinhold 	virtual	status_t			FSync(void* node);
838474904eSIngo Weinhold 
84cdebdeb0SIngo Weinhold 	virtual	status_t			ReadSymlink(void* node, char* buffer,
858474904eSIngo Weinhold 									size_t bufferSize, size_t* bytesRead);
86cdebdeb0SIngo Weinhold 	virtual	status_t			CreateSymlink(void* dir, const char* name,
878474904eSIngo Weinhold 									const char* target, int mode);
888474904eSIngo Weinhold 
89cdebdeb0SIngo Weinhold 	virtual	status_t			Link(void* dir, const char* name,
90cdebdeb0SIngo Weinhold 									void* node);
91cdebdeb0SIngo Weinhold 	virtual	status_t			Unlink(void* dir, const char* name);
92cdebdeb0SIngo Weinhold 	virtual	status_t			Rename(void* oldDir, const char* oldName,
93cdebdeb0SIngo Weinhold 									void* newDir, const char* newName);
948474904eSIngo Weinhold 
95cdebdeb0SIngo Weinhold 	virtual	status_t			Access(void* node, int mode);
96cdebdeb0SIngo Weinhold 	virtual	status_t			ReadStat(void* node, struct stat* st);
97cdebdeb0SIngo Weinhold 	virtual	status_t			WriteStat(void* node, const struct stat *st,
988474904eSIngo Weinhold 									uint32 mask);
995d3147f6SIngo Weinhold 
1005d3147f6SIngo Weinhold 	// files
101cdebdeb0SIngo Weinhold 	virtual	status_t			Create(void* dir, const char* name,
102cdebdeb0SIngo Weinhold 									int openMode, int mode, void** cookie,
103245aecdaSAxel Dörfler 									ino_t* vnid);
104cdebdeb0SIngo Weinhold 	virtual	status_t			Open(void* node, int openMode,
105cdebdeb0SIngo Weinhold 									void** cookie);
106cdebdeb0SIngo Weinhold 	virtual	status_t			Close(void* node, void* cookie);
107cdebdeb0SIngo Weinhold 	virtual	status_t			FreeCookie(void* node, void* cookie);
108cdebdeb0SIngo Weinhold 	virtual	status_t			Read(void* node, void* cookie, off_t pos,
1095d3147f6SIngo Weinhold 									void* buffer, size_t bufferSize,
1105d3147f6SIngo Weinhold 									size_t* bytesRead);
111cdebdeb0SIngo Weinhold 	virtual	status_t			Write(void* node, void* cookie,
1128474904eSIngo Weinhold 									off_t pos, const void* buffer,
1138474904eSIngo Weinhold 									size_t bufferSize, size_t* bytesWritten);
1145d3147f6SIngo Weinhold 
1155d3147f6SIngo Weinhold 	// directories
116cdebdeb0SIngo Weinhold 	virtual	status_t			CreateDir(void* dir, const char* name,
117*3cf43c26SIngo Weinhold 									int mode);
118cdebdeb0SIngo Weinhold 	virtual	status_t			RemoveDir(void* dir, const char* name);
119cdebdeb0SIngo Weinhold 	virtual	status_t			OpenDir(void* node, void** cookie);
120cdebdeb0SIngo Weinhold 	virtual	status_t			CloseDir(void* node, void* cookie);
121cdebdeb0SIngo Weinhold 	virtual	status_t			FreeDirCookie(void* node, void* cookie);
122cdebdeb0SIngo Weinhold 	virtual	status_t			ReadDir(void* node, void* cookie,
1235d3147f6SIngo Weinhold 									void* buffer, size_t bufferSize,
1248474904eSIngo Weinhold 									uint32 count, uint32* countRead);
125cdebdeb0SIngo Weinhold 	virtual	status_t			RewindDir(void* node, void* cookie);
1268474904eSIngo Weinhold 
1278474904eSIngo Weinhold 	// attribute directories
128cdebdeb0SIngo Weinhold 	virtual	status_t			OpenAttrDir(void* node, void** cookie);
129cdebdeb0SIngo Weinhold 	virtual	status_t			CloseAttrDir(void* node, void* cookie);
130cdebdeb0SIngo Weinhold 	virtual	status_t			FreeAttrDirCookie(void* node,
131cdebdeb0SIngo Weinhold 									void* cookie);
132cdebdeb0SIngo Weinhold 	virtual	status_t			ReadAttrDir(void* node, void* cookie,
1338474904eSIngo Weinhold 									void* buffer, size_t bufferSize,
1348474904eSIngo Weinhold 									uint32 count, uint32* countRead);
135cdebdeb0SIngo Weinhold 	virtual	status_t			RewindAttrDir(void* node, void* cookie);
1365d3147f6SIngo Weinhold 
1375d3147f6SIngo Weinhold 	// attributes
138cdebdeb0SIngo Weinhold 	virtual	status_t			CreateAttr(void* node, const char* name,
139617ed3e4SIngo Weinhold 									uint32 type, int openMode,
140cdebdeb0SIngo Weinhold 									void** cookie);
141cdebdeb0SIngo Weinhold 	virtual	status_t			OpenAttr(void* node, const char* name,
142cdebdeb0SIngo Weinhold 									int openMode, void** cookie);
143cdebdeb0SIngo Weinhold 	virtual	status_t			CloseAttr(void* node, void* cookie);
144cdebdeb0SIngo Weinhold 	virtual	status_t			FreeAttrCookie(void* node, void* cookie);
145cdebdeb0SIngo Weinhold 	virtual	status_t			ReadAttr(void* node, void* cookie,
1468474904eSIngo Weinhold 									off_t pos, void* buffer, size_t bufferSize,
1478474904eSIngo Weinhold 									size_t* bytesRead);
148cdebdeb0SIngo Weinhold 	virtual	status_t			WriteAttr(void* node, void* cookie,
1498474904eSIngo Weinhold 									off_t pos, const void* buffer,
1505d3147f6SIngo Weinhold 									size_t bufferSize, size_t* bytesWritten);
151cdebdeb0SIngo Weinhold 	virtual	status_t			ReadAttrStat(void* node, void* cookie,
1528474904eSIngo Weinhold 									struct stat* st);
153cdebdeb0SIngo Weinhold 	virtual	status_t			WriteAttrStat(void* node, void* cookie,
154ed07b9c7SIngo Weinhold 									const struct stat* st, int statMask);
155cdebdeb0SIngo Weinhold 	virtual	status_t			RenameAttr(void* oldNode,
156cdebdeb0SIngo Weinhold 									const char* oldName, void* newNode,
1575d3147f6SIngo Weinhold 									const char* newName);
158cdebdeb0SIngo Weinhold 	virtual	status_t			RemoveAttr(void* node, const char* name);
1595d3147f6SIngo Weinhold 
1605d3147f6SIngo Weinhold 	// indices
161cdebdeb0SIngo Weinhold 	virtual	status_t			OpenIndexDir(void** cookie);
162cdebdeb0SIngo Weinhold 	virtual	status_t			CloseIndexDir(void* cookie);
163cdebdeb0SIngo Weinhold 	virtual	status_t			FreeIndexDirCookie(void* cookie);
164cdebdeb0SIngo Weinhold 	virtual	status_t			ReadIndexDir(void* cookie, void* buffer,
1658474904eSIngo Weinhold 									size_t bufferSize, uint32 count,
1668474904eSIngo Weinhold 									uint32* countRead);
167cdebdeb0SIngo Weinhold 	virtual	status_t			RewindIndexDir(void* cookie);
1688474904eSIngo Weinhold 	virtual	status_t			CreateIndex(const char* name, uint32 type,
1698474904eSIngo Weinhold 									uint32 flags);
1705d3147f6SIngo Weinhold 	virtual	status_t			RemoveIndex(const char* name);
1718474904eSIngo Weinhold 	virtual	status_t			ReadIndexStat(const char *name,
1728474904eSIngo Weinhold 									struct stat *st);
1735d3147f6SIngo Weinhold 
1745d3147f6SIngo Weinhold 	// queries
1755d3147f6SIngo Weinhold 	virtual	status_t			OpenQuery(const char* queryString,
1768474904eSIngo Weinhold 									uint32 flags, port_id port, uint32 token,
177cdebdeb0SIngo Weinhold 									void** cookie);
178cdebdeb0SIngo Weinhold 	virtual	status_t			CloseQuery(void* cookie);
179cdebdeb0SIngo Weinhold 	virtual	status_t			FreeQueryCookie(void* cookie);
180cdebdeb0SIngo Weinhold 	virtual	status_t			ReadQuery(void* cookie, void* buffer,
1818474904eSIngo Weinhold 									size_t bufferSize, uint32 count,
1828474904eSIngo Weinhold 									uint32* countRead);
183cdebdeb0SIngo Weinhold 	virtual	status_t			RewindQuery(void* cookie);
1845d3147f6SIngo Weinhold 
1855d3147f6SIngo Weinhold protected:
1865d3147f6SIngo Weinhold 			FileSystem*			fFileSystem;
187245aecdaSAxel Dörfler 			dev_t				fID;
188cdebdeb0SIngo Weinhold 			FSVolumeCapabilities fCapabilities;
1895d3147f6SIngo Weinhold };
1905d3147f6SIngo Weinhold 
1915d3147f6SIngo Weinhold }	// namespace UserlandFS
1925d3147f6SIngo Weinhold 
1935d3147f6SIngo Weinhold using UserlandFS::Volume;
1945d3147f6SIngo Weinhold 
1955d3147f6SIngo Weinhold #endif	// USERLAND_FS_VOLUME_H
196