1*5a1d355fSStephan Aßmus // Volume.h 2*5a1d355fSStephan Aßmus 3*5a1d355fSStephan Aßmus #ifndef NET_FS_VOLUME_H 4*5a1d355fSStephan Aßmus #define NET_FS_VOLUME_H 5*5a1d355fSStephan Aßmus 6*5a1d355fSStephan Aßmus #include <fsproto.h> 7*5a1d355fSStephan Aßmus 8*5a1d355fSStephan Aßmus #include <HashString.h> 9*5a1d355fSStephan Aßmus 10*5a1d355fSStephan Aßmus #include "FSObject.h" 11*5a1d355fSStephan Aßmus #include "Locker.h" 12*5a1d355fSStephan Aßmus 13*5a1d355fSStephan Aßmus class Node; 14*5a1d355fSStephan Aßmus class QueryIterator; 15*5a1d355fSStephan Aßmus class VolumeEvent; 16*5a1d355fSStephan Aßmus class VolumeManager; 17*5a1d355fSStephan Aßmus 18*5a1d355fSStephan Aßmus class Volume : public FSObject { 19*5a1d355fSStephan Aßmus public: 20*5a1d355fSStephan Aßmus Volume(VolumeManager* volumeManager); 21*5a1d355fSStephan Aßmus ~Volume(); 22*5a1d355fSStephan Aßmus 23*5a1d355fSStephan Aßmus VolumeManager* GetVolumeManager() const; 24*5a1d355fSStephan Aßmus 25*5a1d355fSStephan Aßmus void SetParentVolume(Volume* parent); 26*5a1d355fSStephan Aßmus Volume* GetParentVolume() const; 27*5a1d355fSStephan Aßmus // TODO: Add the parent node ID and maybe get rid of parent volume. 28*5a1d355fSStephan Aßmus 29*5a1d355fSStephan Aßmus void PutVolume(); 30*5a1d355fSStephan Aßmus 31*5a1d355fSStephan Aßmus status_t Init(const char* name); 32*5a1d355fSStephan Aßmus void Uninit(); 33*5a1d355fSStephan Aßmus 34*5a1d355fSStephan Aßmus const char* GetName() const; 35*5a1d355fSStephan Aßmus 36*5a1d355fSStephan Aßmus vnode_id GetRootID() const; 37*5a1d355fSStephan Aßmus virtual Node* GetRootNode() const = 0; 38*5a1d355fSStephan Aßmus 39*5a1d355fSStephan Aßmus void SetUnmounting(bool unmounting); 40*5a1d355fSStephan Aßmus bool IsUnmounting() const; 41*5a1d355fSStephan Aßmus 42*5a1d355fSStephan Aßmus virtual void PrepareToUnmount(); 43*5a1d355fSStephan Aßmus 44*5a1d355fSStephan Aßmus virtual void RemoveChildVolume(Volume* volume) = 0; 45*5a1d355fSStephan Aßmus 46*5a1d355fSStephan Aßmus virtual void HandleEvent(VolumeEvent* event); 47*5a1d355fSStephan Aßmus 48*5a1d355fSStephan Aßmus // client methods 49*5a1d355fSStephan Aßmus status_t GetVNode(vnode_id vnid, Node** node); 50*5a1d355fSStephan Aßmus status_t PutVNode(vnode_id vnid); 51*5a1d355fSStephan Aßmus status_t NewVNode(vnode_id vnid, Node* node); 52*5a1d355fSStephan Aßmus status_t RemoveVNode(vnode_id vnid); 53*5a1d355fSStephan Aßmus status_t UnremoveVNode(vnode_id vnid); 54*5a1d355fSStephan Aßmus int IsVNodeRemoved(vnode_id vnid); 55*5a1d355fSStephan Aßmus 56*5a1d355fSStephan Aßmus int SendNotification(port_id port, int32 token, 57*5a1d355fSStephan Aßmus uint32 what, int32 op, nspace_id nsida, 58*5a1d355fSStephan Aßmus nspace_id nsidb, vnode_id vnida, 59*5a1d355fSStephan Aßmus vnode_id vnidb, vnode_id vnidc, 60*5a1d355fSStephan Aßmus const char *name); 61*5a1d355fSStephan Aßmus int NotifyListener(int32 opcode, nspace_id nsid, 62*5a1d355fSStephan Aßmus vnode_id vnida, vnode_id vnidb, 63*5a1d355fSStephan Aßmus vnode_id vnidc, const char *name); 64*5a1d355fSStephan Aßmus 65*5a1d355fSStephan Aßmus // FS 66*5a1d355fSStephan Aßmus virtual status_t Unmount(); 67*5a1d355fSStephan Aßmus virtual status_t Sync(); 68*5a1d355fSStephan Aßmus virtual status_t ReadFSStat(fs_info* info); 69*5a1d355fSStephan Aßmus virtual status_t WriteFSStat(struct fs_info* info, int32 mask); 70*5a1d355fSStephan Aßmus 71*5a1d355fSStephan Aßmus // vnodes 72*5a1d355fSStephan Aßmus virtual status_t ReadVNode(vnode_id vnid, char reenter, 73*5a1d355fSStephan Aßmus Node** node); 74*5a1d355fSStephan Aßmus virtual status_t WriteVNode(Node* node, char reenter); 75*5a1d355fSStephan Aßmus virtual status_t RemoveVNode(Node* node, char reenter); 76*5a1d355fSStephan Aßmus 77*5a1d355fSStephan Aßmus // nodes 78*5a1d355fSStephan Aßmus virtual status_t FSync(Node* node); 79*5a1d355fSStephan Aßmus virtual status_t ReadStat(Node* node, struct stat* st); 80*5a1d355fSStephan Aßmus virtual status_t WriteStat(Node* node, struct stat *st, 81*5a1d355fSStephan Aßmus uint32 mask); 82*5a1d355fSStephan Aßmus virtual status_t Access(Node* node, int mode); 83*5a1d355fSStephan Aßmus 84*5a1d355fSStephan Aßmus // files 85*5a1d355fSStephan Aßmus virtual status_t Create(Node* dir, const char* name, 86*5a1d355fSStephan Aßmus int openMode, int mode, vnode_id* vnid, 87*5a1d355fSStephan Aßmus void** cookie); 88*5a1d355fSStephan Aßmus virtual status_t Open(Node* node, int openMode, 89*5a1d355fSStephan Aßmus void** cookie); 90*5a1d355fSStephan Aßmus virtual status_t Close(Node* node, void* cookie); 91*5a1d355fSStephan Aßmus virtual status_t FreeCookie(Node* node, void* cookie); 92*5a1d355fSStephan Aßmus virtual status_t Read(Node* node, void* cookie, off_t pos, 93*5a1d355fSStephan Aßmus void* buffer, size_t bufferSize, 94*5a1d355fSStephan Aßmus size_t* bytesRead); 95*5a1d355fSStephan Aßmus virtual status_t Write(Node* node, void* cookie, off_t pos, 96*5a1d355fSStephan Aßmus const void* buffer, size_t bufferSize, 97*5a1d355fSStephan Aßmus size_t* bytesWritten); 98*5a1d355fSStephan Aßmus virtual status_t IOCtl(Node* node, void* cookie, int cmd, 99*5a1d355fSStephan Aßmus void* buffer, size_t bufferSize); 100*5a1d355fSStephan Aßmus virtual status_t SetFlags(Node* node, void* cookie, 101*5a1d355fSStephan Aßmus int flags); 102*5a1d355fSStephan Aßmus 103*5a1d355fSStephan Aßmus // hard links / symlinks 104*5a1d355fSStephan Aßmus virtual status_t Link(Node* dir, const char* name, 105*5a1d355fSStephan Aßmus Node* node); 106*5a1d355fSStephan Aßmus virtual status_t Unlink(Node* dir, const char* name); 107*5a1d355fSStephan Aßmus virtual status_t Symlink(Node* dir, const char* name, 108*5a1d355fSStephan Aßmus const char* target); 109*5a1d355fSStephan Aßmus virtual status_t ReadLink(Node* node, char* buffer, 110*5a1d355fSStephan Aßmus size_t bufferSize, size_t* bytesRead); 111*5a1d355fSStephan Aßmus virtual status_t Rename(Node* oldDir, const char* oldName, 112*5a1d355fSStephan Aßmus Node* newDir, const char* newName); 113*5a1d355fSStephan Aßmus 114*5a1d355fSStephan Aßmus // directories 115*5a1d355fSStephan Aßmus virtual status_t MkDir(Node* dir, const char* name, 116*5a1d355fSStephan Aßmus int mode); 117*5a1d355fSStephan Aßmus virtual status_t RmDir(Node* dir, const char* name); 118*5a1d355fSStephan Aßmus virtual status_t OpenDir(Node* node, void** cookie); 119*5a1d355fSStephan Aßmus virtual status_t CloseDir(Node* node, void* cookie); 120*5a1d355fSStephan Aßmus virtual status_t FreeDirCookie(Node* node, void* cookie); 121*5a1d355fSStephan Aßmus virtual status_t ReadDir(Node* node, void* cookie, 122*5a1d355fSStephan Aßmus struct dirent* buffer, size_t bufferSize, 123*5a1d355fSStephan Aßmus int32 count, int32* countRead); 124*5a1d355fSStephan Aßmus virtual status_t RewindDir(Node* node, void* cookie); 125*5a1d355fSStephan Aßmus virtual status_t Walk(Node* dir, const char* entryName, 126*5a1d355fSStephan Aßmus char** resolvedPath, vnode_id* vnid); 127*5a1d355fSStephan Aßmus 128*5a1d355fSStephan Aßmus // attributes 129*5a1d355fSStephan Aßmus virtual status_t OpenAttrDir(Node* node, void** cookie); 130*5a1d355fSStephan Aßmus virtual status_t CloseAttrDir(Node* node, void* cookie); 131*5a1d355fSStephan Aßmus virtual status_t FreeAttrDirCookie(Node* node, 132*5a1d355fSStephan Aßmus void* cookie); 133*5a1d355fSStephan Aßmus virtual status_t ReadAttrDir(Node* node, void* cookie, 134*5a1d355fSStephan Aßmus struct dirent* buffer, size_t bufferSize, 135*5a1d355fSStephan Aßmus int32 count, int32* countRead); 136*5a1d355fSStephan Aßmus virtual status_t RewindAttrDir(Node* node, void* cookie); 137*5a1d355fSStephan Aßmus virtual status_t ReadAttr(Node* node, const char* name, 138*5a1d355fSStephan Aßmus int type, off_t pos, void* buffer, 139*5a1d355fSStephan Aßmus size_t bufferSize, size_t* bytesRead); 140*5a1d355fSStephan Aßmus virtual status_t WriteAttr(Node* node, const char* name, 141*5a1d355fSStephan Aßmus int type, off_t pos, const void* buffer, 142*5a1d355fSStephan Aßmus size_t bufferSize, size_t* bytesWritten); 143*5a1d355fSStephan Aßmus virtual status_t RemoveAttr(Node* node, const char* name); 144*5a1d355fSStephan Aßmus virtual status_t RenameAttr(Node* node, 145*5a1d355fSStephan Aßmus const char* oldName, const char* newName); 146*5a1d355fSStephan Aßmus virtual status_t StatAttr(Node* node, const char* name, 147*5a1d355fSStephan Aßmus struct attr_info* attrInfo); 148*5a1d355fSStephan Aßmus 149*5a1d355fSStephan Aßmus // queries 150*5a1d355fSStephan Aßmus virtual status_t OpenQuery(const char* queryString, 151*5a1d355fSStephan Aßmus uint32 flags, port_id port, int32 token, 152*5a1d355fSStephan Aßmus QueryIterator** iterator); 153*5a1d355fSStephan Aßmus virtual void FreeQueryIterator(QueryIterator* iterator); 154*5a1d355fSStephan Aßmus virtual status_t ReadQuery(QueryIterator* iterator, 155*5a1d355fSStephan Aßmus struct dirent* buffer, size_t bufferSize, 156*5a1d355fSStephan Aßmus int32 count, int32* countRead); 157*5a1d355fSStephan Aßmus 158*5a1d355fSStephan Aßmus protected: 159*5a1d355fSStephan Aßmus Locker fLock; 160*5a1d355fSStephan Aßmus VolumeManager* fVolumeManager; 161*5a1d355fSStephan Aßmus Volume* fParentVolume; 162*5a1d355fSStephan Aßmus HashString fName; 163*5a1d355fSStephan Aßmus bool fUnmounting; 164*5a1d355fSStephan Aßmus }; 165*5a1d355fSStephan Aßmus 166*5a1d355fSStephan Aßmus #endif // NET_FS_VOLUME_H 167