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, %lld, %lld, \"%s\")\n", port, token, what, op, nsida, nsidb, vnida, vnidb, vnidc, name)); 176 return send_notification(port, token, what, op, nsida, nsidb, vnida, 177 vnidb, vnidc, name); 178 } 179 180 // NotifyListener 181 int 182 Volume::NotifyListener(int32 opcode, nspace_id nsid, vnode_id vnida, 183 vnode_id vnidb, vnode_id vnidc, const char *name) 184 { 185 return notify_listener(opcode, nsid, vnida, vnidb, vnidc, name); 186 } 187 188 189 // #pragma mark - 190 // #pragma mark ----- FS ----- 191 192 // Unmount 193 status_t 194 Volume::Unmount() 195 { 196 return B_BAD_VALUE; 197 } 198 199 // Sync 200 status_t 201 Volume::Sync() 202 { 203 return B_BAD_VALUE; 204 } 205 206 // ReadFSStat 207 status_t 208 Volume::ReadFSStat(fs_info* info) 209 { 210 return B_BAD_VALUE; 211 } 212 213 // WriteFSStat 214 status_t 215 Volume::WriteFSStat(struct fs_info* info, int32 mask) 216 { 217 return B_BAD_VALUE; 218 } 219 220 221 // #pragma mark - 222 // #pragma mark ----- vnodes ----- 223 224 // ReadVNode 225 status_t 226 Volume::ReadVNode(vnode_id vnid, char reenter, Node** _node) 227 { 228 return B_BAD_VALUE; 229 } 230 231 // WriteVNode 232 status_t 233 Volume::WriteVNode(Node* node, char reenter) 234 { 235 return B_BAD_VALUE; 236 } 237 238 // RemoveVNode 239 status_t 240 Volume::RemoveVNode(Node* node, char reenter) 241 { 242 return B_BAD_VALUE; 243 } 244 245 246 // #pragma mark - 247 // #pragma mark ----- nodes ----- 248 249 // FSync 250 status_t 251 Volume::FSync(Node* node) 252 { 253 return B_BAD_VALUE; 254 } 255 256 // ReadStat 257 status_t 258 Volume::ReadStat(Node* node, struct stat* st) 259 { 260 return B_BAD_VALUE; 261 } 262 263 // WriteStat 264 status_t 265 Volume::WriteStat(Node* node, struct stat *st, uint32 mask) 266 { 267 return B_BAD_VALUE; 268 } 269 270 // Access 271 status_t 272 Volume::Access(Node* node, int mode) 273 { 274 return B_BAD_VALUE; 275 } 276 277 278 // #pragma mark - 279 // #pragma mark ----- files ----- 280 281 // Create 282 status_t 283 Volume::Create(Node* dir, const char* name, int openMode, int mode, 284 vnode_id* vnid, void** cookie) 285 { 286 return B_BAD_VALUE; 287 } 288 289 // Open 290 status_t 291 Volume::Open(Node* node, int openMode, void** cookie) 292 { 293 return B_BAD_VALUE; 294 } 295 296 // Close 297 status_t 298 Volume::Close(Node* node, void* cookie) 299 { 300 return B_BAD_VALUE; 301 } 302 303 // FreeCookie 304 status_t 305 Volume::FreeCookie(Node* node, void* cookie) 306 { 307 return B_BAD_VALUE; 308 } 309 310 // Read 311 status_t 312 Volume::Read(Node* node, void* cookie, off_t pos, void* _buffer, 313 size_t bufferSize, size_t* _bytesRead) 314 { 315 return B_BAD_VALUE; 316 } 317 318 // Write 319 status_t 320 Volume::Write(Node* node, void* cookie, off_t pos, const void* _buffer, 321 size_t bufferSize, size_t* bytesWritten) 322 { 323 return B_BAD_VALUE; 324 } 325 326 // IOCtl 327 status_t 328 Volume::IOCtl(Node* node, void* cookie, int cmd, void* buffer, 329 size_t bufferSize) 330 { 331 return B_BAD_VALUE; 332 } 333 334 // SetFlags 335 status_t 336 Volume::SetFlags(Node* node, void* cookie, int flags) 337 { 338 return B_BAD_VALUE; 339 } 340 341 342 // #pragma mark - 343 // #pragma mark ----- hard links / symlinks ----- 344 345 // Link 346 status_t 347 Volume::Link(Node* dir, const char* name, Node* node) 348 { 349 return B_BAD_VALUE; 350 } 351 352 // Unlink 353 status_t 354 Volume::Unlink(Node* dir, const char* name) 355 { 356 return B_BAD_VALUE; 357 } 358 359 // Symlink 360 status_t 361 Volume::Symlink(Node* dir, const char* name, const char* target) 362 { 363 return B_BAD_VALUE; 364 } 365 366 // ReadLink 367 status_t 368 Volume::ReadLink(Node* node, char* buffer, size_t bufferSize, 369 size_t* bytesRead) 370 { 371 return B_BAD_VALUE; 372 } 373 374 // Rename 375 status_t 376 Volume::Rename(Node* oldDir, const char* oldName, Node* newDir, 377 const char* newName) 378 { 379 return B_BAD_VALUE; 380 } 381 382 383 // #pragma mark - 384 // #pragma mark ----- directories ----- 385 386 // MkDir 387 status_t 388 Volume::MkDir(Node* dir, const char* name, int mode) 389 { 390 return B_BAD_VALUE; 391 } 392 393 // RmDir 394 status_t 395 Volume::RmDir(Node* dir, const char* name) 396 { 397 return B_BAD_VALUE; 398 } 399 400 // OpenDir 401 status_t 402 Volume::OpenDir(Node* node, void** _cookie) 403 { 404 return B_BAD_VALUE; 405 } 406 407 // CloseDir 408 status_t 409 Volume::CloseDir(Node* node, void* cookie) 410 { 411 return B_BAD_VALUE; 412 } 413 414 // FreeDirCookie 415 status_t 416 Volume::FreeDirCookie(Node* node, void* _cookie) 417 { 418 return B_BAD_VALUE; 419 } 420 421 // ReadDir 422 status_t 423 Volume::ReadDir(Node* node, void* _cookie, struct dirent* buffer, 424 size_t bufferSize, int32 count, int32* countRead) 425 { 426 return B_BAD_VALUE; 427 } 428 429 // RewindDir 430 status_t 431 Volume::RewindDir(Node* node, void* _cookie) 432 { 433 return B_BAD_VALUE; 434 } 435 436 // Walk 437 status_t 438 Volume::Walk(Node* dir, const char* entryName, char** resolvedPath, 439 vnode_id* vnid) 440 { 441 return B_BAD_VALUE; 442 } 443 444 445 // #pragma mark - 446 // #pragma mark ----- attributes ----- 447 448 // OpenAttrDir 449 status_t 450 Volume::OpenAttrDir(Node* node, void** _cookie) 451 { 452 return B_BAD_VALUE; 453 } 454 455 // CloseAttrDir 456 status_t 457 Volume::CloseAttrDir(Node* node, void* cookie) 458 { 459 return B_BAD_VALUE; 460 } 461 462 // FreeAttrDirCookie 463 status_t 464 Volume::FreeAttrDirCookie(Node* node, void* _cookie) 465 { 466 return B_BAD_VALUE; 467 } 468 469 // ReadAttrDir 470 status_t 471 Volume::ReadAttrDir(Node* node, void* _cookie, struct dirent* buffer, 472 size_t bufferSize, int32 count, int32* countRead) 473 { 474 return B_BAD_VALUE; 475 } 476 477 // RewindAttrDir 478 status_t 479 Volume::RewindAttrDir(Node* node, void* _cookie) 480 { 481 return B_BAD_VALUE; 482 } 483 484 // ReadAttr 485 status_t 486 Volume::ReadAttr(Node* node, const char* name, int type, off_t pos, 487 void* _buffer, size_t bufferSize, size_t* _bytesRead) 488 { 489 return B_BAD_VALUE; 490 } 491 492 // WriteAttr 493 status_t 494 Volume::WriteAttr(Node* node, const char* name, int type, off_t pos, 495 const void* _buffer, size_t bufferSize, size_t* bytesWritten) 496 { 497 return B_BAD_VALUE; 498 } 499 500 // RemoveAttr 501 status_t 502 Volume::RemoveAttr(Node* node, const char* name) 503 { 504 return B_BAD_VALUE; 505 } 506 507 // RenameAttr 508 status_t 509 Volume::RenameAttr(Node* node, const char* oldName, const char* newName) 510 { 511 return B_BAD_VALUE; 512 } 513 514 // StatAttr 515 status_t 516 Volume::StatAttr(Node* node, const char* name, struct attr_info* attrInfo) 517 { 518 return B_BAD_VALUE; 519 } 520 521 522 // #pragma mark - 523 // #pragma mark ----- queries ----- 524 525 // OpenQuery 526 status_t 527 Volume::OpenQuery(const char* queryString, uint32 flags, port_id port, 528 int32 token, QueryIterator** iterator) 529 { 530 return B_BAD_VALUE; 531 } 532 533 // FreeQueryIterator 534 void 535 Volume::FreeQueryIterator(QueryIterator* iterator) 536 { 537 } 538 539 // ReadQuery 540 status_t 541 Volume::ReadQuery(QueryIterator* iterator, struct dirent* buffer, 542 size_t bufferSize, int32 count, int32* countRead) 543 { 544 return B_BAD_VALUE; 545 } 546 547