1 /* 2 * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef USERLAND_FS_BEOS_KERNEL_VOLUME_H 6 #define USERLAND_FS_BEOS_KERNEL_VOLUME_H 7 8 #include "../Volume.h" 9 10 struct beos_vnode_ops; 11 12 namespace UserlandFS { 13 14 class BeOSKernelFileSystem; 15 16 17 class BeOSKernelVolume : public Volume { 18 public: 19 BeOSKernelVolume(FileSystem* fileSystem, 20 dev_t id, beos_vnode_ops* fsOps, 21 const FSVolumeCapabilities& capabilities); 22 virtual ~BeOSKernelVolume(); 23 24 // FS 25 virtual status_t Mount(const char* device, uint32 flags, 26 const char* parameters, ino_t* rootID); 27 virtual status_t Unmount(); 28 virtual status_t Sync(); 29 virtual status_t ReadFSInfo(fs_info* info); 30 virtual status_t WriteFSInfo(const struct fs_info* info, 31 uint32 mask); 32 33 // vnodes 34 virtual status_t Lookup(void* dir, const char* entryName, 35 ino_t* vnid); 36 virtual status_t GetVNodeType(void* node, int* type); 37 // Only needs to be implemented when 38 // the three parameters publish_vnode() is 39 // used. 40 virtual status_t ReadVNode(ino_t vnid, bool reenter, 41 void** node, int* type, uint32* flags, 42 FSVNodeCapabilities* _capabilities); 43 virtual status_t WriteVNode(void* node, bool reenter); 44 virtual status_t RemoveVNode(void* node, bool reenter); 45 46 // nodes 47 virtual status_t IOCtl(void* node, void* cookie, 48 uint32 command, void* buffer, size_t size); 49 virtual status_t SetFlags(void* node, void* cookie, 50 int flags); 51 virtual status_t Select(void* node, void* cookie, 52 uint8 event, selectsync* sync); 53 virtual status_t Deselect(void* node, void* cookie, 54 uint8 event, selectsync* sync); 55 56 virtual status_t FSync(void* node); 57 58 virtual status_t ReadSymlink(void* node, char* buffer, 59 size_t bufferSize, size_t* bytesRead); 60 virtual status_t CreateSymlink(void* dir, const char* name, 61 const char* target, int mode); 62 63 virtual status_t Link(void* dir, const char* name, 64 void* node); 65 virtual status_t Unlink(void* dir, const char* name); 66 virtual status_t Rename(void* oldDir, const char* oldName, 67 void* newDir, const char* newName); 68 69 virtual status_t Access(void* node, int mode); 70 virtual status_t ReadStat(void* node, struct stat* st); 71 virtual status_t WriteStat(void* node, const struct stat *st, 72 uint32 mask); 73 74 // files 75 virtual status_t Create(void* dir, const char* name, 76 int openMode, int mode, void** cookie, 77 ino_t* vnid); 78 virtual status_t Open(void* node, int openMode, 79 void** cookie); 80 virtual status_t Close(void* node, void* cookie); 81 virtual status_t FreeCookie(void* node, void* cookie); 82 virtual status_t Read(void* node, void* cookie, off_t pos, 83 void* buffer, size_t bufferSize, 84 size_t* bytesRead); 85 virtual status_t Write(void* node, void* cookie, 86 off_t pos, const void* buffer, 87 size_t bufferSize, size_t* bytesWritten); 88 89 // directories 90 virtual status_t CreateDir(void* dir, const char* name, 91 int mode); 92 virtual status_t RemoveDir(void* dir, const char* name); 93 virtual status_t OpenDir(void* node, void** cookie); 94 virtual status_t CloseDir(void* node, void* cookie); 95 virtual status_t FreeDirCookie(void* node, void* cookie); 96 virtual status_t ReadDir(void* node, void* cookie, 97 void* buffer, size_t bufferSize, 98 uint32 count, uint32* countRead); 99 virtual status_t RewindDir(void* node, void* cookie); 100 101 // attribute directories 102 virtual status_t OpenAttrDir(void* node, void** cookie); 103 virtual status_t CloseAttrDir(void* node, void* cookie); 104 virtual status_t FreeAttrDirCookie(void* node, 105 void* cookie); 106 virtual status_t ReadAttrDir(void* node, void* cookie, 107 void* buffer, size_t bufferSize, 108 uint32 count, uint32* countRead); 109 virtual status_t RewindAttrDir(void* node, void* cookie); 110 111 // attributes 112 virtual status_t CreateAttr(void* node, const char *name, 113 uint32 type, int openMode, 114 void** cookie); 115 virtual status_t OpenAttr(void* node, const char *name, 116 int openMode, void** cookie); 117 virtual status_t CloseAttr(void* node, void* cookie); 118 virtual status_t FreeAttrCookie(void* node, void* cookie); 119 virtual status_t ReadAttr(void* node, void* cookie, 120 off_t pos, void* buffer, size_t bufferSize, 121 size_t* bytesRead); 122 virtual status_t WriteAttr(void* node, void* cookie, 123 off_t pos, const void* buffer, 124 size_t bufferSize, size_t* bytesWritten); 125 virtual status_t ReadAttrStat(void* node, void* cookie, 126 struct stat *st); 127 virtual status_t RenameAttr(void* oldNode, 128 const char* oldName, void* newNode, 129 const char* newName); 130 virtual status_t RemoveAttr(void* node, const char* name); 131 132 // indices 133 virtual status_t OpenIndexDir(void** cookie); 134 virtual status_t CloseIndexDir(void* cookie); 135 virtual status_t FreeIndexDirCookie(void* cookie); 136 virtual status_t ReadIndexDir(void* cookie, void* buffer, 137 size_t bufferSize, uint32 count, 138 uint32* countRead); 139 virtual status_t RewindIndexDir(void* cookie); 140 virtual status_t CreateIndex(const char* name, uint32 type, 141 uint32 flags); 142 virtual status_t RemoveIndex(const char* name); 143 virtual status_t ReadIndexStat(const char *name, 144 struct stat *st); 145 146 // queries 147 virtual status_t OpenQuery(const char* queryString, 148 uint32 flags, port_id port, uint32 token, 149 void** cookie); 150 virtual status_t CloseQuery(void* cookie); 151 virtual status_t FreeQueryCookie(void* cookie); 152 virtual status_t ReadQuery(void* cookie, void* buffer, 153 size_t bufferSize, uint32 count, 154 uint32* countRead); 155 156 private: 157 class AttributeCookie; 158 159 private: 160 status_t _OpenAttr(void* node, const char* name, 161 uint32 type, int openMode, bool create, 162 void** cookie); 163 inline BeOSKernelFileSystem* _FileSystem() const; 164 165 private: 166 beos_vnode_ops* fFSOps; 167 void* fVolumeCookie; 168 bool fMounted; 169 }; 170 171 } // namespace UserlandFS 172 173 using UserlandFS::BeOSKernelVolume; 174 175 #endif // USERLAND_FS_BEOS_KERNEL_VOLUME_H 176