1 // Volume.cpp 2 3 #include "Volume.h" 4 5 #include <new> 6 7 #include <AutoLocker.h> 8 9 #include "Compatibility.h" 10 #include "DebugSupport.h" 11 #include "Node.h" 12 #include "QueryManager.h" 13 #include "VolumeManager.h" 14 15 // constructor 16 Volume::Volume(VolumeManager* volumeManager) 17 : FSObject(), 18 fLock("volume"), 19 fVolumeManager(volumeManager), 20 fParentVolume(NULL), 21 fName(), 22 fUnmounting(false) 23 { 24 } 25 26 // destructor 27 Volume::~Volume() 28 { 29 } 30 31 // GetVolumeManager 32 VolumeManager* 33 Volume::GetVolumeManager() const 34 { 35 return fVolumeManager; 36 } 37 38 // SetParentVolume 39 void 40 Volume::SetParentVolume(Volume* parent) 41 { 42 AutoLocker<Locker> _(fLock); 43 fParentVolume = parent; 44 } 45 46 // GetParentVolume 47 Volume* 48 Volume::GetParentVolume() const 49 { 50 return fParentVolume; 51 } 52 53 // PutVolume 54 void 55 Volume::PutVolume() 56 { 57 fVolumeManager->PutVolume(this); 58 } 59 60 // Init 61 status_t 62 Volume::Init(const char* name) 63 { 64 if (!name || strlen(name) == 0) 65 return B_BAD_VALUE; 66 67 if (!fName.SetTo(name)) 68 return B_NO_MEMORY; 69 70 return B_OK; 71 } 72 73 // Uninit 74 void 75 Volume::Uninit() 76 { 77 } 78 79 // GetName 80 const char* 81 Volume::GetName() const 82 { 83 return fName.GetString(); 84 } 85 86 // GetRootID 87 vnode_id 88 Volume::GetRootID() const 89 { 90 return GetRootNode()->GetID(); 91 } 92 93 // SetUnmounting 94 void 95 Volume::SetUnmounting(bool unmounting) 96 { 97 fUnmounting = unmounting; 98 } 99 100 // IsUnmounting 101 bool 102 Volume::IsUnmounting() const 103 { 104 return fUnmounting; 105 } 106 107 // HandleEvent 108 void 109 Volume::HandleEvent(VolumeEvent* event) 110 { 111 } 112 113 // PrepareToUnmount 114 void 115 Volume::PrepareToUnmount() 116 { 117 fVolumeManager->GetQueryManager()->VolumeUnmounting(this); 118 } 119 120 121 // #pragma mark - 122 // #pragma mark ----- client methods ----- 123 124 // GetVNode 125 status_t 126 Volume::GetVNode(vnode_id vnid, Node** node) 127 { 128 return get_vnode(fVolumeManager->GetID(), vnid, (void**)node); 129 } 130 131 // PutVNode 132 status_t 133 Volume::PutVNode(vnode_id vnid) 134 { 135 return put_vnode(fVolumeManager->GetID(), vnid); 136 } 137 138 // NewVNode 139 status_t 140 Volume::NewVNode(vnode_id vnid, Node* node) 141 { 142 status_t error = new_vnode(fVolumeManager->GetID(), vnid, node); 143 if (error == B_OK) 144 node->SetKnownToVFS(true); 145 return error; 146 } 147 148 // RemoveVNode 149 status_t 150 Volume::RemoveVNode(vnode_id vnid) 151 { 152 return remove_vnode(fVolumeManager->GetID(), vnid); 153 } 154 155 // UnremoveVNode 156 status_t 157 Volume::UnremoveVNode(vnode_id vnid) 158 { 159 return unremove_vnode(fVolumeManager->GetID(), vnid); 160 } 161 162 // IsVNodeRemoved 163 int 164 Volume::IsVNodeRemoved(vnode_id vnid) 165 { 166 return is_vnode_removed(fVolumeManager->GetID(), vnid); 167 } 168 169 // SendNotification 170 int 171 Volume::SendNotification(port_id port, int32 token, uint32 what, int32 op, 172 nspace_id nsida, nspace_id nsidb, vnode_id vnida, vnode_id vnidb, 173 vnode_id vnidc, const char *name) 174 { 175 PRINT("Volume::SendNotification(%ld, %ld, 0x%lx, 0x%lx, %ld, %ld, %lld," 176 " %lld, %lld, \"%s\")\n", port, token, what, op, nsida, nsidb, 177 vnida, vnidb, vnidc, name); 178 return send_notification(port, token, what, op, nsida, nsidb, vnida, 179 vnidb, vnidc, name); 180 } 181 182 // NotifyListener 183 int 184 Volume::NotifyListener(int32 opcode, nspace_id nsid, vnode_id vnida, 185 vnode_id vnidb, vnode_id vnidc, const char *name) 186 { 187 return notify_listener(opcode, nsid, vnida, vnidb, vnidc, name); 188 } 189 190 191 // #pragma mark - 192 // #pragma mark ----- FS ----- 193 194 // Unmount 195 status_t 196 Volume::Unmount() 197 { 198 return B_BAD_VALUE; 199 } 200 201 // Sync 202 status_t 203 Volume::Sync() 204 { 205 return B_BAD_VALUE; 206 } 207 208 // ReadFSStat 209 status_t 210 Volume::ReadFSStat(fs_info* info) 211 { 212 return B_BAD_VALUE; 213 } 214 215 // WriteFSStat 216 status_t 217 Volume::WriteFSStat(struct fs_info* info, int32 mask) 218 { 219 return B_BAD_VALUE; 220 } 221 222 223 // #pragma mark - 224 // #pragma mark ----- vnodes ----- 225 226 // ReadVNode 227 status_t 228 Volume::ReadVNode(vnode_id vnid, char reenter, Node** _node) 229 { 230 return B_BAD_VALUE; 231 } 232 233 // WriteVNode 234 status_t 235 Volume::WriteVNode(Node* node, char reenter) 236 { 237 return B_BAD_VALUE; 238 } 239 240 // RemoveVNode 241 status_t 242 Volume::RemoveVNode(Node* node, char reenter) 243 { 244 return B_BAD_VALUE; 245 } 246 247 248 // #pragma mark - 249 // #pragma mark ----- nodes ----- 250 251 // FSync 252 status_t 253 Volume::FSync(Node* node) 254 { 255 return B_BAD_VALUE; 256 } 257 258 // ReadStat 259 status_t 260 Volume::ReadStat(Node* node, struct stat* st) 261 { 262 return B_BAD_VALUE; 263 } 264 265 // WriteStat 266 status_t 267 Volume::WriteStat(Node* node, struct stat *st, uint32 mask) 268 { 269 return B_BAD_VALUE; 270 } 271 272 // Access 273 status_t 274 Volume::Access(Node* node, int mode) 275 { 276 return B_BAD_VALUE; 277 } 278 279 280 // #pragma mark - 281 // #pragma mark ----- files ----- 282 283 // Create 284 status_t 285 Volume::Create(Node* dir, const char* name, int openMode, int mode, 286 vnode_id* vnid, void** cookie) 287 { 288 return B_BAD_VALUE; 289 } 290 291 // Open 292 status_t 293 Volume::Open(Node* node, int openMode, void** cookie) 294 { 295 return B_BAD_VALUE; 296 } 297 298 // Close 299 status_t 300 Volume::Close(Node* node, void* cookie) 301 { 302 return B_BAD_VALUE; 303 } 304 305 // FreeCookie 306 status_t 307 Volume::FreeCookie(Node* node, void* cookie) 308 { 309 return B_BAD_VALUE; 310 } 311 312 // Read 313 status_t 314 Volume::Read(Node* node, void* cookie, off_t pos, void* _buffer, 315 size_t bufferSize, size_t* _bytesRead) 316 { 317 return B_BAD_VALUE; 318 } 319 320 // Write 321 status_t 322 Volume::Write(Node* node, void* cookie, off_t pos, const void* _buffer, 323 size_t bufferSize, size_t* bytesWritten) 324 { 325 return B_BAD_VALUE; 326 } 327 328 // IOCtl 329 status_t 330 Volume::IOCtl(Node* node, void* cookie, int cmd, void* buffer, 331 size_t bufferSize) 332 { 333 return B_DEV_INVALID_IOCTL; 334 } 335 336 // SetFlags 337 status_t 338 Volume::SetFlags(Node* node, void* cookie, int flags) 339 { 340 return B_BAD_VALUE; 341 } 342 343 344 // #pragma mark - 345 // #pragma mark ----- hard links / symlinks ----- 346 347 // Link 348 status_t 349 Volume::Link(Node* dir, const char* name, Node* node) 350 { 351 return B_BAD_VALUE; 352 } 353 354 // Unlink 355 status_t 356 Volume::Unlink(Node* dir, const char* name) 357 { 358 return B_BAD_VALUE; 359 } 360 361 // Symlink 362 status_t 363 Volume::Symlink(Node* dir, const char* name, const char* target) 364 { 365 return B_BAD_VALUE; 366 } 367 368 // ReadLink 369 status_t 370 Volume::ReadLink(Node* node, char* buffer, size_t bufferSize, 371 size_t* bytesRead) 372 { 373 return B_BAD_VALUE; 374 } 375 376 // Rename 377 status_t 378 Volume::Rename(Node* oldDir, const char* oldName, Node* newDir, 379 const char* newName) 380 { 381 return B_BAD_VALUE; 382 } 383 384 385 // #pragma mark - 386 // #pragma mark ----- directories ----- 387 388 // MkDir 389 status_t 390 Volume::MkDir(Node* dir, const char* name, int mode) 391 { 392 return B_BAD_VALUE; 393 } 394 395 // RmDir 396 status_t 397 Volume::RmDir(Node* dir, const char* name) 398 { 399 return B_BAD_VALUE; 400 } 401 402 // OpenDir 403 status_t 404 Volume::OpenDir(Node* node, void** _cookie) 405 { 406 return B_BAD_VALUE; 407 } 408 409 // CloseDir 410 status_t 411 Volume::CloseDir(Node* node, void* cookie) 412 { 413 return B_BAD_VALUE; 414 } 415 416 // FreeDirCookie 417 status_t 418 Volume::FreeDirCookie(Node* node, void* _cookie) 419 { 420 return B_BAD_VALUE; 421 } 422 423 // ReadDir 424 status_t 425 Volume::ReadDir(Node* node, void* _cookie, struct dirent* buffer, 426 size_t bufferSize, int32 count, int32* countRead) 427 { 428 return B_BAD_VALUE; 429 } 430 431 // RewindDir 432 status_t 433 Volume::RewindDir(Node* node, void* _cookie) 434 { 435 return B_BAD_VALUE; 436 } 437 438 // Walk 439 status_t 440 Volume::Walk(Node* dir, const char* entryName, char** resolvedPath, 441 vnode_id* vnid) 442 { 443 return B_BAD_VALUE; 444 } 445 446 447 // #pragma mark - 448 // #pragma mark ----- attributes ----- 449 450 // OpenAttrDir 451 status_t 452 Volume::OpenAttrDir(Node* node, void** _cookie) 453 { 454 return B_BAD_VALUE; 455 } 456 457 // CloseAttrDir 458 status_t 459 Volume::CloseAttrDir(Node* node, void* cookie) 460 { 461 return B_BAD_VALUE; 462 } 463 464 // FreeAttrDirCookie 465 status_t 466 Volume::FreeAttrDirCookie(Node* node, void* _cookie) 467 { 468 return B_BAD_VALUE; 469 } 470 471 // ReadAttrDir 472 status_t 473 Volume::ReadAttrDir(Node* node, void* _cookie, struct dirent* buffer, 474 size_t bufferSize, int32 count, int32* countRead) 475 { 476 return B_BAD_VALUE; 477 } 478 479 // RewindAttrDir 480 status_t 481 Volume::RewindAttrDir(Node* node, void* _cookie) 482 { 483 return B_BAD_VALUE; 484 } 485 486 // ReadAttr 487 status_t 488 Volume::ReadAttr(Node* node, const char* name, int type, off_t pos, 489 void* _buffer, size_t bufferSize, size_t* _bytesRead) 490 { 491 return B_BAD_VALUE; 492 } 493 494 // WriteAttr 495 status_t 496 Volume::WriteAttr(Node* node, const char* name, int type, off_t pos, 497 const void* _buffer, size_t bufferSize, size_t* bytesWritten) 498 { 499 return B_BAD_VALUE; 500 } 501 502 // RemoveAttr 503 status_t 504 Volume::RemoveAttr(Node* node, const char* name) 505 { 506 return B_BAD_VALUE; 507 } 508 509 // RenameAttr 510 status_t 511 Volume::RenameAttr(Node* node, const char* oldName, const char* newName) 512 { 513 return B_BAD_VALUE; 514 } 515 516 // StatAttr 517 status_t 518 Volume::StatAttr(Node* node, const char* name, struct attr_info* attrInfo) 519 { 520 return B_BAD_VALUE; 521 } 522 523 524 // #pragma mark - 525 // #pragma mark ----- queries ----- 526 527 // OpenQuery 528 status_t 529 Volume::OpenQuery(const char* queryString, uint32 flags, port_id port, 530 int32 token, QueryIterator** iterator) 531 { 532 return B_BAD_VALUE; 533 } 534 535 // FreeQueryIterator 536 void 537 Volume::FreeQueryIterator(QueryIterator* iterator) 538 { 539 } 540 541 // ReadQuery 542 status_t 543 Volume::ReadQuery(QueryIterator* iterator, struct dirent* buffer, 544 size_t bufferSize, int32 count, int32* countRead) 545 { 546 return B_BAD_VALUE; 547 } 548 549