1 // BeOSKernelFileSystem.cpp 2 3 #include "BeOSKernelFileSystem.h" 4 5 #include <new> 6 7 #include "BeOSKernelVolume.h" 8 #include "fs_interface.h" 9 10 using std::nothrow; 11 12 // constructor 13 BeOSKernelFileSystem::BeOSKernelFileSystem(beos_vnode_ops* fsOps) 14 : FileSystem(), 15 fFSOps(fsOps) 16 { 17 _InitCapabilities(); 18 } 19 20 // destructor 21 BeOSKernelFileSystem::~BeOSKernelFileSystem() 22 { 23 } 24 25 // CreateVolume 26 status_t 27 BeOSKernelFileSystem::CreateVolume(Volume** volume, dev_t id) 28 { 29 // check initialization and parameters 30 if (!fFSOps || !volume) 31 return B_BAD_VALUE; 32 33 // create the volume 34 *volume = new(nothrow) BeOSKernelVolume(this, id, fFSOps); 35 if (!*volume) 36 return B_NO_MEMORY; 37 return B_OK; 38 } 39 40 // DeleteVolume 41 status_t 42 BeOSKernelFileSystem::DeleteVolume(Volume* volume) 43 { 44 if (!volume || !dynamic_cast<BeOSKernelVolume*>(volume)) 45 return B_BAD_VALUE; 46 delete volume; 47 return B_OK; 48 } 49 50 // _InitCapabilities 51 void 52 BeOSKernelFileSystem::_InitCapabilities() 53 { 54 fCapabilities.ClearAll(); 55 56 // FS interface type 57 fClientFSType = CLIENT_FS_BEOS_KERNEL; 58 59 // FS operations 60 fCapabilities.Set(FS_CAPABILITY_MOUNT, fFSOps->mount); 61 62 63 // Volume operations 64 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_UNMOUNT, fFSOps->unmount); 65 66 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_READ_FS_INFO, fFSOps->rfsstat); 67 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_WRITE_FS_INFO, 68 fFSOps->wfsstat); 69 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_SYNC, fFSOps->sync); 70 71 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_GET_VNODE, fFSOps->read_vnode); 72 73 // index directory & index operations 74 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_OPEN_INDEX_DIR, 75 fFSOps->open_indexdir); 76 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_CLOSE_INDEX_DIR, 77 fFSOps->close_indexdir); 78 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_FREE_INDEX_DIR_COOKIE, 79 fFSOps->free_indexdircookie); 80 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_READ_INDEX_DIR, 81 fFSOps->read_indexdir); 82 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_REWIND_INDEX_DIR, 83 fFSOps->rewind_indexdir); 84 85 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_CREATE_INDEX, 86 fFSOps->create_index); 87 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_REMOVE_INDEX, 88 fFSOps->remove_index); 89 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_READ_INDEX_STAT, 90 fFSOps->stat_index); 91 92 // query operations 93 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_OPEN_QUERY, 94 fFSOps->open_query); 95 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_CLOSE_QUERY, 96 fFSOps->close_query); 97 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_FREE_QUERY_COOKIE, 98 fFSOps->free_querycookie); 99 fVolumeCapabilities.Set(FS_VOLUME_CAPABILITY_READ_QUERY, 100 fFSOps->read_query); 101 // missing: FS_VOLUME_CAPABILITY_REWIND_QUERY, 102 103 // vnode operations 104 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_LOOKUP, fFSOps->walk); 105 // missing: FS_VNODE_CAPABILITY_GET_VNODE_NAME, 106 107 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_PUT_VNODE, fFSOps->write_vnode); 108 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_REMOVE_VNODE, 109 fFSOps->remove_vnode); 110 111 // VM file access 112 // missing: FS_VNODE_CAPABILITY_CAN_PAGE, 113 // missing: FS_VNODE_CAPABILITY_READ_PAGES, 114 // missing: FS_VNODE_CAPABILITY_WRITE_PAGES, 115 116 // cache file access 117 // missing: FS_VNODE_CAPABILITY_GET_FILE_MAP, 118 119 // common operations 120 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_IOCTL, fFSOps->ioctl); 121 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_SET_FLAGS, fFSOps->setflags); 122 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_SELECT, fFSOps->select); 123 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_DESELECT, fFSOps->deselect); 124 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_FSYNC, fFSOps->fsync); 125 126 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_READ_SYMLINK, fFSOps->readlink); 127 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CREATE_SYMLINK, fFSOps->symlink); 128 129 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_LINK, fFSOps->link); 130 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_UNLINK, fFSOps->unlink); 131 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_RENAME, fFSOps->rename); 132 133 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_ACCESS, fFSOps->access); 134 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_READ_STAT, fFSOps->rstat); 135 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_WRITE_STAT, fFSOps->wstat); 136 137 // file operations 138 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CREATE, fFSOps->create); 139 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_OPEN, fFSOps->open); 140 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CLOSE, fFSOps->close); 141 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_FREE_COOKIE, fFSOps->free_cookie); 142 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_READ, fFSOps->read); 143 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_WRITE, fFSOps->write); 144 145 // directory operations 146 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CREATE_DIR, fFSOps->mkdir); 147 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_REMOVE_DIR, fFSOps->rmdir); 148 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_OPEN_DIR, fFSOps->opendir); 149 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CLOSE_DIR, fFSOps->closedir); 150 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_FREE_DIR_COOKIE, 151 fFSOps->free_dircookie); 152 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_READ_DIR, fFSOps->readdir); 153 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_REWIND_DIR, fFSOps->rewinddir); 154 155 // attribute directory operations 156 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_OPEN_ATTR_DIR, 157 fFSOps->open_attrdir); 158 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CLOSE_ATTR_DIR, 159 fFSOps->close_attrdir); 160 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_FREE_ATTR_DIR_COOKIE, 161 fFSOps->free_attrdircookie); 162 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_READ_ATTR_DIR, 163 fFSOps->read_attrdir); 164 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_REWIND_ATTR_DIR, 165 fFSOps->rewind_attrdir); 166 167 // attribute operations 168 // we emulate open_attr() and free_attr_dir_cookie() if either read_attr() 169 // or write_attr() is present 170 bool hasAttributes = (fFSOps->read_attr || fFSOps->write_attr); 171 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CREATE_ATTR, hasAttributes); 172 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_OPEN_ATTR, hasAttributes); 173 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_CLOSE_ATTR, false); 174 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_FREE_ATTR_COOKIE, hasAttributes); 175 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_READ_ATTR, fFSOps->read_attr); 176 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_WRITE_ATTR, fFSOps->write_attr); 177 178 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_READ_ATTR_STAT, 179 fFSOps->stat_attr); 180 // missing: FS_VNODE_CAPABILITY_WRITE_ATTR_STAT 181 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_RENAME_ATTR, fFSOps->rename_attr); 182 fNodeCapabilities.Set(FS_VNODE_CAPABILITY_REMOVE_ATTR, fFSOps->remove_attr); 183 } 184