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