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 16Volume::Volume(VolumeManager* volumeManager) 17 : FSObject(), 18 fLock("volume"), 19 fVolumeManager(volumeManager), 20 fParentVolume(NULL), 21 fName(), 22 fUnmounting(false) 23{ 24} 25 26// destructor 27Volume::~Volume() 28{ 29} 30 31// GetVolumeManager 32VolumeManager* 33Volume::GetVolumeManager() const 34{ 35 return fVolumeManager; 36} 37 38// SetParentVolume 39void 40Volume::SetParentVolume(Volume* parent) 41{ 42 AutoLocker<Locker> _(fLock); 43 fParentVolume = parent; 44} 45 46// GetParentVolume 47Volume* 48Volume::GetParentVolume() const 49{ 50 return fParentVolume; 51} 52 53// PutVolume 54void 55Volume::PutVolume() 56{ 57 fVolumeManager->PutVolume(this); 58} 59 60// Init 61status_t 62Volume::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 74void 75Volume::Uninit() 76{ 77} 78 79// GetName 80const char* 81Volume::GetName() const 82{ 83 return fName.GetString(); 84} 85 86// GetRootID 87vnode_id 88Volume::GetRootID() const 89{ 90 return GetRootNode()->GetID(); 91} 92 93// SetUnmounting 94void 95Volume::SetUnmounting(bool unmounting) 96{ 97 fUnmounting = unmounting; 98} 99 100// IsUnmounting 101bool 102Volume::IsUnmounting() const 103{ 104 return fUnmounting; 105} 106 107// HandleEvent 108void 109Volume::HandleEvent(VolumeEvent* event) 110{ 111} 112 113// PrepareToUnmount 114void 115Volume::PrepareToUnmount() 116{ 117 fVolumeManager->GetQueryManager()->VolumeUnmounting(this); 118} 119 120 121// #pragma mark - 122// #pragma mark ----- client methods ----- 123 124// GetVNode 125status_t 126Volume::GetVNode(vnode_id vnid, Node** node) 127{ 128 return get_vnode(fVolumeManager->GetID(), vnid, (void**)node); 129} 130 131// PutVNode 132status_t 133Volume::PutVNode(vnode_id vnid) 134{ 135 return put_vnode(fVolumeManager->GetID(), vnid); 136} 137 138// NewVNode 139status_t 140Volume::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 149status_t 150Volume::RemoveVNode(vnode_id vnid) 151{ 152 return remove_vnode(fVolumeManager->GetID(), vnid); 153} 154 155// UnremoveVNode 156status_t 157Volume::UnremoveVNode(vnode_id vnid) 158{ 159 return unremove_vnode(fVolumeManager->GetID(), vnid); 160} 161 162// IsVNodeRemoved 163int 164Volume::IsVNodeRemoved(vnode_id vnid) 165{ 166 return is_vnode_removed(fVolumeManager->GetID(), vnid); 167} 168 169// SendNotification 170int 171Volume::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 184int 185Volume::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 196status_t 197Volume::Unmount() 198{ 199 return B_BAD_VALUE; 200} 201 202// Sync 203status_t 204Volume::Sync() 205{ 206 return B_BAD_VALUE; 207} 208 209// ReadFSStat 210status_t 211Volume::ReadFSStat(fs_info* info) 212{ 213 return B_BAD_VALUE; 214} 215 216// WriteFSStat 217status_t 218Volume::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 228status_t 229Volume::ReadVNode(vnode_id vnid, char reenter, Node** _node) 230{ 231 return B_BAD_VALUE; 232} 233 234// WriteVNode 235status_t 236Volume::WriteVNode(Node* node, char reenter) 237{ 238 return B_BAD_VALUE; 239} 240 241// RemoveVNode 242status_t 243Volume::RemoveVNode(Node* node, char reenter) 244{ 245 return B_BAD_VALUE; 246} 247 248 249// #pragma mark - 250// #pragma mark ----- nodes ----- 251 252// FSync 253status_t 254Volume::FSync(Node* node) 255{ 256 return B_BAD_VALUE; 257} 258 259// ReadStat 260status_t 261Volume::ReadStat(Node* node, struct stat* st) 262{ 263 return B_BAD_VALUE; 264} 265 266// WriteStat 267status_t 268Volume::WriteStat(Node* node, struct stat *st, uint32 mask) 269{ 270 return B_BAD_VALUE; 271} 272 273// Access 274status_t 275Volume::Access(Node* node, int mode) 276{ 277 return B_BAD_VALUE; 278} 279 280 281// #pragma mark - 282// #pragma mark ----- files ----- 283 284// Create 285status_t 286Volume::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 293status_t 294Volume::Open(Node* node, int openMode, void** cookie) 295{ 296 return B_BAD_VALUE; 297} 298 299// Close 300status_t 301Volume::Close(Node* node, void* cookie) 302{ 303 return B_BAD_VALUE; 304} 305 306// FreeCookie 307status_t 308Volume::FreeCookie(Node* node, void* cookie) 309{ 310 return B_BAD_VALUE; 311} 312 313// Read 314status_t 315Volume::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 322status_t 323Volume::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 330status_t 331Volume::IOCtl(Node* node, void* cookie, int cmd, void* buffer, 332 size_t bufferSize) 333{ 334 return B_DEV_INVALID_IOCTL; 335} 336 337// SetFlags 338status_t 339Volume::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 349status_t 350Volume::Link(Node* dir, const char* name, Node* node) 351{ 352 return B_BAD_VALUE; 353} 354 355// Unlink 356status_t 357Volume::Unlink(Node* dir, const char* name) 358{ 359 return B_BAD_VALUE; 360} 361 362// Symlink 363status_t 364Volume::Symlink(Node* dir, const char* name, const char* target) 365{ 366 return B_BAD_VALUE; 367} 368 369// ReadLink 370status_t 371Volume::ReadLink(Node* node, char* buffer, size_t bufferSize, 372 size_t* bytesRead) 373{ 374 return B_BAD_VALUE; 375} 376 377// Rename 378status_t 379Volume::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 390status_t 391Volume::MkDir(Node* dir, const char* name, int mode) 392{ 393 return B_BAD_VALUE; 394} 395 396// RmDir 397status_t 398Volume::RmDir(Node* dir, const char* name) 399{ 400 return B_BAD_VALUE; 401} 402 403// OpenDir 404status_t 405Volume::OpenDir(Node* node, void** _cookie) 406{ 407 return B_BAD_VALUE; 408} 409 410// CloseDir 411status_t 412Volume::CloseDir(Node* node, void* cookie) 413{ 414 return B_BAD_VALUE; 415} 416 417// FreeDirCookie 418status_t 419Volume::FreeDirCookie(Node* node, void* _cookie) 420{ 421 return B_BAD_VALUE; 422} 423 424// ReadDir 425status_t 426Volume::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 433status_t 434Volume::RewindDir(Node* node, void* _cookie) 435{ 436 return B_BAD_VALUE; 437} 438 439// Walk 440status_t 441Volume::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 452status_t 453Volume::OpenAttrDir(Node* node, void** _cookie) 454{ 455 return B_BAD_VALUE; 456} 457 458// CloseAttrDir 459status_t 460Volume::CloseAttrDir(Node* node, void* cookie) 461{ 462 return B_BAD_VALUE; 463} 464 465// FreeAttrDirCookie 466status_t 467Volume::FreeAttrDirCookie(Node* node, void* _cookie) 468{ 469 return B_BAD_VALUE; 470} 471 472// ReadAttrDir 473status_t 474Volume::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 481status_t 482Volume::RewindAttrDir(Node* node, void* _cookie) 483{ 484 return B_BAD_VALUE; 485} 486 487// ReadAttr 488status_t 489Volume::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 496status_t 497Volume::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 504status_t 505Volume::RemoveAttr(Node* node, const char* name) 506{ 507 return B_BAD_VALUE; 508} 509 510// RenameAttr 511status_t 512Volume::RenameAttr(Node* node, const char* oldName, const char* newName) 513{ 514 return B_BAD_VALUE; 515} 516 517// StatAttr 518status_t 519Volume::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 529status_t 530Volume::OpenQuery(const char* queryString, uint32 flags, port_id port, 531 int32 token, QueryIterator** iterator) 532{ 533 return B_BAD_VALUE; 534} 535 536// FreeQueryIterator 537void 538Volume::FreeQueryIterator(QueryIterator* iterator) 539{ 540} 541 542// ReadQuery 543status_t 544Volume::ReadQuery(QueryIterator* iterator, struct dirent* buffer, 545 size_t bufferSize, int32 count, int32* countRead) 546{ 547 return B_BAD_VALUE; 548} 549 550