15d3147f6SIngo Weinhold // Volume.h 25d3147f6SIngo Weinhold 35d3147f6SIngo Weinhold #ifndef USERLAND_FS_VOLUME_H 45d3147f6SIngo Weinhold #define USERLAND_FS_VOLUME_H 55d3147f6SIngo Weinhold 68474904eSIngo Weinhold #include <fs_interface.h> 75d3147f6SIngo Weinhold #include <SupportDefs.h> 85d3147f6SIngo Weinhold 99accd619SIngo Weinhold #include <kernel/util/DoublyLinkedList.h> 109accd619SIngo Weinhold 11cdebdeb0SIngo Weinhold #include "FSCapabilities.h" 12cdebdeb0SIngo Weinhold 139accd619SIngo Weinhold 145d3147f6SIngo Weinhold namespace UserlandFS { 155d3147f6SIngo Weinhold 165d3147f6SIngo Weinhold class FileSystem; 17*f1c6ce08SIngo Weinhold class IORequestInfo; 185d3147f6SIngo Weinhold 19cdebdeb0SIngo Weinhold using UserlandFSUtil::FSVolumeCapabilities; 20cdebdeb0SIngo Weinhold 219accd619SIngo Weinhold class Volume : public DoublyLinkedListLinkImpl<Volume> { 225d3147f6SIngo Weinhold public: 23245aecdaSAxel Dörfler Volume(FileSystem* fileSystem, dev_t id); 245d3147f6SIngo Weinhold virtual ~Volume(); 255d3147f6SIngo Weinhold 265d3147f6SIngo Weinhold FileSystem* GetFileSystem() const; 27245aecdaSAxel Dörfler dev_t GetID() const; 285d3147f6SIngo Weinhold 29cdebdeb0SIngo Weinhold void GetCapabilities( 30cdebdeb0SIngo Weinhold FSVolumeCapabilities& capabilities) const 31cdebdeb0SIngo Weinhold { capabilities = fCapabilities; } 32cdebdeb0SIngo Weinhold 335d3147f6SIngo Weinhold // FS 348474904eSIngo Weinhold virtual status_t Mount(const char* device, uint32 flags, 35245aecdaSAxel Dörfler const char* parameters, ino_t* rootID); 365d3147f6SIngo Weinhold virtual status_t Unmount(); 375d3147f6SIngo Weinhold virtual status_t Sync(); 388474904eSIngo Weinhold virtual status_t ReadFSInfo(fs_info* info); 398474904eSIngo Weinhold virtual status_t WriteFSInfo(const struct fs_info* info, 408474904eSIngo Weinhold uint32 mask); 415d3147f6SIngo Weinhold 425d3147f6SIngo Weinhold // vnodes 43cdebdeb0SIngo Weinhold virtual status_t Lookup(void* dir, const char* entryName, 44cdebdeb0SIngo Weinhold ino_t* vnid); 459accd619SIngo Weinhold virtual status_t GetVNodeType(void* node, int* type); 469accd619SIngo Weinhold // Only needs to be implemented when 479accd619SIngo Weinhold // the three parameters publish_vnode() is 489accd619SIngo Weinhold // used. 49cdebdeb0SIngo Weinhold virtual status_t GetVNodeName(void* node, char* buffer, 50ed07b9c7SIngo Weinhold size_t bufferSize); 51245aecdaSAxel Dörfler virtual status_t ReadVNode(ino_t vnid, bool reenter, 52cdebdeb0SIngo Weinhold void** node, int* type, uint32* flags); 53cdebdeb0SIngo Weinhold virtual status_t WriteVNode(void* node, bool reenter); 54cdebdeb0SIngo Weinhold virtual status_t RemoveVNode(void* node, bool reenter); 555d3147f6SIngo Weinhold 56*f1c6ce08SIngo Weinhold // asynchronous I/O 57*f1c6ce08SIngo Weinhold virtual status_t DoIO(void* node, void* cookie, 58*f1c6ce08SIngo Weinhold IORequestInfo* requestInfo); 59*f1c6ce08SIngo Weinhold virtual status_t CancelIO(void* node, void* cookie, 60*f1c6ce08SIngo Weinhold int32 ioRequestID); 61*f1c6ce08SIngo Weinhold 625d3147f6SIngo Weinhold // nodes 63cdebdeb0SIngo Weinhold virtual status_t IOCtl(void* node, void* cookie, 648474904eSIngo Weinhold uint32 command, void* buffer, size_t size); 65cdebdeb0SIngo Weinhold virtual status_t SetFlags(void* node, void* cookie, 668474904eSIngo Weinhold int flags); 67cdebdeb0SIngo Weinhold virtual status_t Select(void* node, void* cookie, 68cdebdeb0SIngo Weinhold uint8 event, selectsync* sync); 69cdebdeb0SIngo Weinhold virtual status_t Deselect(void* node, void* cookie, 708474904eSIngo Weinhold uint8 event, selectsync* sync); 718474904eSIngo Weinhold 72cdebdeb0SIngo Weinhold virtual status_t FSync(void* node); 738474904eSIngo Weinhold 74cdebdeb0SIngo Weinhold virtual status_t ReadSymlink(void* node, char* buffer, 758474904eSIngo Weinhold size_t bufferSize, size_t* bytesRead); 76cdebdeb0SIngo Weinhold virtual status_t CreateSymlink(void* dir, const char* name, 778474904eSIngo Weinhold const char* target, int mode); 788474904eSIngo Weinhold 79cdebdeb0SIngo Weinhold virtual status_t Link(void* dir, const char* name, 80cdebdeb0SIngo Weinhold void* node); 81cdebdeb0SIngo Weinhold virtual status_t Unlink(void* dir, const char* name); 82cdebdeb0SIngo Weinhold virtual status_t Rename(void* oldDir, const char* oldName, 83cdebdeb0SIngo Weinhold void* newDir, const char* newName); 848474904eSIngo Weinhold 85cdebdeb0SIngo Weinhold virtual status_t Access(void* node, int mode); 86cdebdeb0SIngo Weinhold virtual status_t ReadStat(void* node, struct stat* st); 87cdebdeb0SIngo Weinhold virtual status_t WriteStat(void* node, const struct stat *st, 888474904eSIngo Weinhold uint32 mask); 895d3147f6SIngo Weinhold 905d3147f6SIngo Weinhold // files 91cdebdeb0SIngo Weinhold virtual status_t Create(void* dir, const char* name, 92cdebdeb0SIngo Weinhold int openMode, int mode, void** cookie, 93245aecdaSAxel Dörfler ino_t* vnid); 94cdebdeb0SIngo Weinhold virtual status_t Open(void* node, int openMode, 95cdebdeb0SIngo Weinhold void** cookie); 96cdebdeb0SIngo Weinhold virtual status_t Close(void* node, void* cookie); 97cdebdeb0SIngo Weinhold virtual status_t FreeCookie(void* node, void* cookie); 98cdebdeb0SIngo Weinhold virtual status_t Read(void* node, void* cookie, off_t pos, 995d3147f6SIngo Weinhold void* buffer, size_t bufferSize, 1005d3147f6SIngo Weinhold size_t* bytesRead); 101cdebdeb0SIngo Weinhold virtual status_t Write(void* node, void* cookie, 1028474904eSIngo Weinhold off_t pos, const void* buffer, 1038474904eSIngo Weinhold size_t bufferSize, size_t* bytesWritten); 1045d3147f6SIngo Weinhold 1055d3147f6SIngo Weinhold // directories 106cdebdeb0SIngo Weinhold virtual status_t CreateDir(void* dir, const char* name, 107245aecdaSAxel Dörfler int mode, ino_t *newDir); 108cdebdeb0SIngo Weinhold virtual status_t RemoveDir(void* dir, const char* name); 109cdebdeb0SIngo Weinhold virtual status_t OpenDir(void* node, void** cookie); 110cdebdeb0SIngo Weinhold virtual status_t CloseDir(void* node, void* cookie); 111cdebdeb0SIngo Weinhold virtual status_t FreeDirCookie(void* node, void* cookie); 112cdebdeb0SIngo Weinhold virtual status_t ReadDir(void* node, void* cookie, 1135d3147f6SIngo Weinhold void* buffer, size_t bufferSize, 1148474904eSIngo Weinhold uint32 count, uint32* countRead); 115cdebdeb0SIngo Weinhold virtual status_t RewindDir(void* node, void* cookie); 1168474904eSIngo Weinhold 1178474904eSIngo Weinhold // attribute directories 118cdebdeb0SIngo Weinhold virtual status_t OpenAttrDir(void* node, void** cookie); 119cdebdeb0SIngo Weinhold virtual status_t CloseAttrDir(void* node, void* cookie); 120cdebdeb0SIngo Weinhold virtual status_t FreeAttrDirCookie(void* node, 121cdebdeb0SIngo Weinhold void* cookie); 122cdebdeb0SIngo Weinhold virtual status_t ReadAttrDir(void* node, void* cookie, 1238474904eSIngo Weinhold void* buffer, size_t bufferSize, 1248474904eSIngo Weinhold uint32 count, uint32* countRead); 125cdebdeb0SIngo Weinhold virtual status_t RewindAttrDir(void* node, void* cookie); 1265d3147f6SIngo Weinhold 1275d3147f6SIngo Weinhold // attributes 128cdebdeb0SIngo Weinhold virtual status_t CreateAttr(void* node, const char* name, 129617ed3e4SIngo Weinhold uint32 type, int openMode, 130cdebdeb0SIngo Weinhold void** cookie); 131cdebdeb0SIngo Weinhold virtual status_t OpenAttr(void* node, const char* name, 132cdebdeb0SIngo Weinhold int openMode, void** cookie); 133cdebdeb0SIngo Weinhold virtual status_t CloseAttr(void* node, void* cookie); 134cdebdeb0SIngo Weinhold virtual status_t FreeAttrCookie(void* node, void* cookie); 135cdebdeb0SIngo Weinhold virtual status_t ReadAttr(void* node, void* cookie, 1368474904eSIngo Weinhold off_t pos, void* buffer, size_t bufferSize, 1378474904eSIngo Weinhold size_t* bytesRead); 138cdebdeb0SIngo Weinhold virtual status_t WriteAttr(void* node, void* cookie, 1398474904eSIngo Weinhold off_t pos, const void* buffer, 1405d3147f6SIngo Weinhold size_t bufferSize, size_t* bytesWritten); 141cdebdeb0SIngo Weinhold virtual status_t ReadAttrStat(void* node, void* cookie, 1428474904eSIngo Weinhold struct stat* st); 143cdebdeb0SIngo Weinhold virtual status_t WriteAttrStat(void* node, void* cookie, 144ed07b9c7SIngo Weinhold const struct stat* st, int statMask); 145cdebdeb0SIngo Weinhold virtual status_t RenameAttr(void* oldNode, 146cdebdeb0SIngo Weinhold const char* oldName, void* newNode, 1475d3147f6SIngo Weinhold const char* newName); 148cdebdeb0SIngo Weinhold virtual status_t RemoveAttr(void* node, const char* name); 1495d3147f6SIngo Weinhold 1505d3147f6SIngo Weinhold // indices 151cdebdeb0SIngo Weinhold virtual status_t OpenIndexDir(void** cookie); 152cdebdeb0SIngo Weinhold virtual status_t CloseIndexDir(void* cookie); 153cdebdeb0SIngo Weinhold virtual status_t FreeIndexDirCookie(void* cookie); 154cdebdeb0SIngo Weinhold virtual status_t ReadIndexDir(void* cookie, void* buffer, 1558474904eSIngo Weinhold size_t bufferSize, uint32 count, 1568474904eSIngo Weinhold uint32* countRead); 157cdebdeb0SIngo Weinhold virtual status_t RewindIndexDir(void* cookie); 1588474904eSIngo Weinhold virtual status_t CreateIndex(const char* name, uint32 type, 1598474904eSIngo Weinhold uint32 flags); 1605d3147f6SIngo Weinhold virtual status_t RemoveIndex(const char* name); 1618474904eSIngo Weinhold virtual status_t ReadIndexStat(const char *name, 1628474904eSIngo Weinhold struct stat *st); 1635d3147f6SIngo Weinhold 1645d3147f6SIngo Weinhold // queries 1655d3147f6SIngo Weinhold virtual status_t OpenQuery(const char* queryString, 1668474904eSIngo Weinhold uint32 flags, port_id port, uint32 token, 167cdebdeb0SIngo Weinhold void** cookie); 168cdebdeb0SIngo Weinhold virtual status_t CloseQuery(void* cookie); 169cdebdeb0SIngo Weinhold virtual status_t FreeQueryCookie(void* cookie); 170cdebdeb0SIngo Weinhold virtual status_t ReadQuery(void* cookie, void* buffer, 1718474904eSIngo Weinhold size_t bufferSize, uint32 count, 1728474904eSIngo Weinhold uint32* countRead); 173cdebdeb0SIngo Weinhold virtual status_t RewindQuery(void* cookie); 1745d3147f6SIngo Weinhold 1755d3147f6SIngo Weinhold protected: 1765d3147f6SIngo Weinhold FileSystem* fFileSystem; 177245aecdaSAxel Dörfler dev_t fID; 178cdebdeb0SIngo Weinhold FSVolumeCapabilities fCapabilities; 1795d3147f6SIngo Weinhold }; 1805d3147f6SIngo Weinhold 1815d3147f6SIngo Weinhold } // namespace UserlandFS 1825d3147f6SIngo Weinhold 1835d3147f6SIngo Weinhold using UserlandFS::Volume; 1845d3147f6SIngo Weinhold 1855d3147f6SIngo Weinhold #endif // USERLAND_FS_VOLUME_H 186