1 // BeOSKernelFileSystem.cpp 2 3 #include "BeOSKernelFileSystem.h" 4 5 #include <new> 6 7 #include "beos_fs_interface.h" 8 #include "BeOSKernelVolume.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 fCapabilities.clientFSType = CLIENT_FS_BEOS_KERNEL; 58 59 // FS operations 60 fCapabilities.Set(FS_CAPABILITY_MOUNT, fFSOps->mount); 61 fCapabilities.Set(FS_CAPABILITY_UNMOUNT, fFSOps->unmount); 62 63 fCapabilities.Set(FS_CAPABILITY_READ_FS_INFO, fFSOps->rfsstat); 64 fCapabilities.Set(FS_CAPABILITY_WRITE_FS_INFO, fFSOps->wfsstat); 65 fCapabilities.Set(FS_CAPABILITY_SYNC, fFSOps->sync); 66 67 // vnode operations 68 fCapabilities.Set(FS_CAPABILITY_LOOKUP, fFSOps->walk); 69 // missing: FS_CAPABILITY_GET_VNODE_NAME, 70 71 fCapabilities.Set(FS_CAPABILITY_GET_VNODE, fFSOps->read_vnode); 72 fCapabilities.Set(FS_CAPABILITY_PUT_VNODE, fFSOps->write_vnode); 73 fCapabilities.Set(FS_CAPABILITY_REMOVE_VNODE, fFSOps->remove_vnode); 74 75 // VM file access 76 // missing: FS_CAPABILITY_CAN_PAGE, 77 // missing: FS_CAPABILITY_READ_PAGES, 78 // missing: FS_CAPABILITY_WRITE_PAGES, 79 80 // cache file access 81 // missing: FS_CAPABILITY_GET_FILE_MAP, 82 83 // common operations 84 fCapabilities.Set(FS_CAPABILITY_IOCTL, fFSOps->ioctl); 85 fCapabilities.Set(FS_CAPABILITY_SET_FLAGS, fFSOps->setflags); 86 fCapabilities.Set(FS_CAPABILITY_SELECT, fFSOps->select); 87 fCapabilities.Set(FS_CAPABILITY_DESELECT, fFSOps->deselect); 88 fCapabilities.Set(FS_CAPABILITY_FSYNC, fFSOps->fsync); 89 90 fCapabilities.Set(FS_CAPABILITY_READ_SYMLINK, fFSOps->readlink); 91 fCapabilities.Set(FS_CAPABILITY_CREATE_SYMLINK, fFSOps->symlink); 92 93 fCapabilities.Set(FS_CAPABILITY_LINK, fFSOps->link); 94 fCapabilities.Set(FS_CAPABILITY_UNLINK, fFSOps->unlink); 95 fCapabilities.Set(FS_CAPABILITY_RENAME, fFSOps->rename); 96 97 fCapabilities.Set(FS_CAPABILITY_ACCESS, fFSOps->access); 98 fCapabilities.Set(FS_CAPABILITY_READ_STAT, fFSOps->rstat); 99 fCapabilities.Set(FS_CAPABILITY_WRITE_STAT, fFSOps->wstat); 100 101 // file operations 102 fCapabilities.Set(FS_CAPABILITY_CREATE, fFSOps->create); 103 fCapabilities.Set(FS_CAPABILITY_OPEN, fFSOps->open); 104 fCapabilities.Set(FS_CAPABILITY_CLOSE, fFSOps->close); 105 fCapabilities.Set(FS_CAPABILITY_FREE_COOKIE, fFSOps->free_cookie); 106 fCapabilities.Set(FS_CAPABILITY_READ, fFSOps->read); 107 fCapabilities.Set(FS_CAPABILITY_WRITE, fFSOps->write); 108 109 // directory operations 110 fCapabilities.Set(FS_CAPABILITY_CREATE_DIR, fFSOps->mkdir); 111 fCapabilities.Set(FS_CAPABILITY_REMOVE_DIR, fFSOps->rmdir); 112 fCapabilities.Set(FS_CAPABILITY_OPEN_DIR, fFSOps->opendir); 113 fCapabilities.Set(FS_CAPABILITY_CLOSE_DIR, fFSOps->closedir); 114 fCapabilities.Set(FS_CAPABILITY_FREE_DIR_COOKIE, fFSOps->free_dircookie); 115 fCapabilities.Set(FS_CAPABILITY_READ_DIR, fFSOps->readdir); 116 fCapabilities.Set(FS_CAPABILITY_REWIND_DIR, fFSOps->rewinddir); 117 118 // attribute directory operations 119 fCapabilities.Set(FS_CAPABILITY_OPEN_ATTR_DIR, fFSOps->open_attrdir); 120 fCapabilities.Set(FS_CAPABILITY_CLOSE_ATTR_DIR, fFSOps->close_attrdir); 121 fCapabilities.Set(FS_CAPABILITY_FREE_ATTR_DIR_COOKIE, 122 fFSOps->free_attrdircookie); 123 fCapabilities.Set(FS_CAPABILITY_READ_ATTR_DIR, fFSOps->read_attrdir); 124 fCapabilities.Set(FS_CAPABILITY_REWIND_ATTR_DIR, fFSOps->rewind_attrdir); 125 126 // attribute operations 127 // we emulate open_attr() and free_attr_dir_cookie() if either read_attr() 128 // or write_attr() is present 129 bool hasAttributes = (fFSOps->read_attr || fFSOps->write_attr); 130 fCapabilities.Set(FS_CAPABILITY_CREATE_ATTR, hasAttributes); 131 fCapabilities.Set(FS_CAPABILITY_OPEN_ATTR, hasAttributes); 132 fCapabilities.Set(FS_CAPABILITY_CLOSE_ATTR, false); 133 fCapabilities.Set(FS_CAPABILITY_FREE_ATTR_COOKIE, hasAttributes); 134 fCapabilities.Set(FS_CAPABILITY_READ_ATTR, fFSOps->read_attr); 135 fCapabilities.Set(FS_CAPABILITY_WRITE_ATTR, fFSOps->write_attr); 136 137 fCapabilities.Set(FS_CAPABILITY_READ_ATTR_STAT, fFSOps->stat_attr); 138 // missing: FS_CAPABILITY_WRITE_ATTR_STAT 139 fCapabilities.Set(FS_CAPABILITY_RENAME_ATTR, fFSOps->rename_attr); 140 fCapabilities.Set(FS_CAPABILITY_REMOVE_ATTR, fFSOps->remove_attr); 141 142 // index directory & index operations 143 fCapabilities.Set(FS_CAPABILITY_OPEN_INDEX_DIR, fFSOps->open_indexdir); 144 fCapabilities.Set(FS_CAPABILITY_CLOSE_INDEX_DIR, fFSOps->close_indexdir); 145 fCapabilities.Set(FS_CAPABILITY_FREE_INDEX_DIR_COOKIE, 146 fFSOps->free_indexdircookie); 147 fCapabilities.Set(FS_CAPABILITY_READ_INDEX_DIR, fFSOps->read_indexdir); 148 fCapabilities.Set(FS_CAPABILITY_REWIND_INDEX_DIR, fFSOps->rewind_indexdir); 149 150 fCapabilities.Set(FS_CAPABILITY_CREATE_INDEX, fFSOps->create_index); 151 fCapabilities.Set(FS_CAPABILITY_REMOVE_INDEX, fFSOps->remove_index); 152 fCapabilities.Set(FS_CAPABILITY_READ_INDEX_STAT, fFSOps->stat_index); 153 154 // query operations 155 fCapabilities.Set(FS_CAPABILITY_OPEN_QUERY, fFSOps->open_query); 156 fCapabilities.Set(FS_CAPABILITY_CLOSE_QUERY, fFSOps->close_query); 157 fCapabilities.Set(FS_CAPABILITY_FREE_QUERY_COOKIE, 158 fFSOps->free_querycookie); 159 fCapabilities.Set(FS_CAPABILITY_READ_QUERY, fFSOps->read_query); 160 // missing: FS_CAPABILITY_REWIND_QUERY, 161 } 162