1 // Volume.cpp 2 3 #include "Volume.h" 4 5 #include <dirent.h> 6 #include <string.h> 7 #include <sys/stat.h> 8 9 #include "kernel_emu.h" 10 11 // constructor 12 Volume::Volume(FileSystem* fileSystem, mount_id id) 13 : fFileSystem(fileSystem), 14 fID(id) 15 { 16 } 17 18 // destructor 19 Volume::~Volume() 20 { 21 } 22 23 // GetFileSystem 24 UserlandFS::FileSystem* 25 Volume::GetFileSystem() const 26 { 27 return fFileSystem; 28 } 29 30 // GetID 31 mount_id 32 Volume::GetID() const 33 { 34 return fID; 35 } 36 37 38 // #pragma mark - FS 39 40 41 // Mount 42 status_t 43 Volume::Mount(const char* device, uint32 flags, const char* parameters, 44 vnode_id* rootID) 45 { 46 return B_BAD_VALUE; 47 } 48 49 // Unmount 50 status_t 51 Volume::Unmount() 52 { 53 return B_BAD_VALUE; 54 } 55 56 // Sync 57 status_t 58 Volume::Sync() 59 { 60 return B_BAD_VALUE; 61 } 62 63 // ReadFSInfo 64 status_t 65 Volume::ReadFSInfo(fs_info* info) 66 { 67 return B_BAD_VALUE; 68 } 69 70 // WriteFSInfo 71 status_t 72 Volume::WriteFSInfo(const struct fs_info* info, uint32 mask) 73 { 74 return B_BAD_VALUE; 75 } 76 77 78 // #pragma mark - vnodes 79 80 81 // Lookup 82 status_t 83 Volume::Lookup(fs_vnode dir, const char* entryName, vnode_id* vnid, int* type) 84 { 85 return B_BAD_VALUE; 86 } 87 88 // LookupNoType 89 status_t 90 Volume::LookupNoType(fs_vnode dir, const char* entryName, vnode_id* vnid) 91 { 92 int type; 93 return Lookup(dir, entryName, vnid, &type); 94 } 95 96 // GetVNodeName 97 status_t 98 Volume::GetVNodeName(fs_vnode node, char* buffer, size_t bufferSize) 99 { 100 // stat the node to get its ID 101 struct stat st; 102 status_t error = ReadStat(node, &st); 103 if (error != B_OK) 104 return error; 105 106 // look up the parent directory 107 vnode_id parentID; 108 error = LookupNoType(node, "..", &parentID); 109 if (error != B_OK) 110 return error; 111 112 // get the parent node handle 113 fs_vnode parentNode; 114 error = UserlandFS::KernelEmu::get_vnode(GetID(), parentID, &parentNode); 115 // Lookup() has already called get_vnode() for us, so we need to put it once 116 UserlandFS::KernelEmu::put_vnode(GetID(), parentID); 117 if (error != B_OK) 118 return error; 119 120 // open the parent dir 121 fs_cookie cookie; 122 error = OpenDir(parentNode, &cookie); 123 if (error == B_OK) { 124 125 while (true) { 126 // read an entry 127 char _entry[sizeof(struct dirent) + B_FILE_NAME_LENGTH]; 128 struct dirent* entry = (struct dirent*)_entry; 129 uint32 num; 130 131 error = ReadDir(parentNode, cookie, entry, sizeof(_entry), 1, &num); 132 133 if (error != B_OK) 134 break; 135 if (num == 0) { 136 error = B_ENTRY_NOT_FOUND; 137 break; 138 } 139 140 // found an entry for our node? 141 if (st.st_ino == entry->d_ino) { 142 // yep, copy the entry name 143 size_t nameLen = strnlen(entry->d_name, B_FILE_NAME_LENGTH); 144 if (nameLen < bufferSize) { 145 memcpy(buffer, entry->d_name, nameLen); 146 buffer[nameLen] = '\0'; 147 } else 148 error = B_BUFFER_OVERFLOW; 149 break; 150 } 151 } 152 153 // close the parent dir 154 CloseDir(parentNode, cookie); 155 FreeDirCookie(parentNode, cookie); 156 } 157 158 // put the parent node 159 UserlandFS::KernelEmu::put_vnode(GetID(), parentID); 160 161 return error; 162 } 163 164 // ReadVNode 165 status_t 166 Volume::ReadVNode(vnode_id vnid, bool reenter, fs_vnode* node) 167 { 168 return B_BAD_VALUE; 169 } 170 171 // WriteVNode 172 status_t 173 Volume::WriteVNode(fs_vnode node, bool reenter) 174 { 175 return B_BAD_VALUE; 176 } 177 178 // RemoveVNode 179 status_t 180 Volume::RemoveVNode(fs_vnode node, bool reenter) 181 { 182 return B_BAD_VALUE; 183 } 184 185 186 // #pragma mark - nodes 187 188 189 // IOCtl 190 status_t 191 Volume::IOCtl(fs_vnode node, fs_cookie cookie, uint32 command, void *buffer, 192 size_t size) 193 { 194 return B_BAD_VALUE; 195 } 196 197 // SetFlags 198 status_t 199 Volume::SetFlags(fs_vnode node, fs_cookie cookie, int flags) 200 { 201 return B_BAD_VALUE; 202 } 203 204 // Select 205 status_t 206 Volume::Select(fs_vnode node, fs_cookie cookie, uint8 event, uint32 ref, 207 selectsync* sync) 208 { 209 return B_BAD_VALUE; 210 } 211 212 // Deselect 213 status_t 214 Volume::Deselect(fs_vnode node, fs_cookie cookie, uint8 event, selectsync* sync) 215 { 216 return B_BAD_VALUE; 217 } 218 219 // FSync 220 status_t 221 Volume::FSync(fs_vnode node) 222 { 223 return B_BAD_VALUE; 224 } 225 226 // ReadSymlink 227 status_t 228 Volume::ReadSymlink(fs_vnode node, char* buffer, size_t bufferSize, 229 size_t* bytesRead) 230 { 231 return B_BAD_VALUE; 232 } 233 234 // CreateSymlink 235 status_t 236 Volume::CreateSymlink(fs_vnode dir, const char* name, const char* target, 237 int mode) 238 { 239 return B_BAD_VALUE; 240 } 241 242 // Link 243 status_t 244 Volume::Link(fs_vnode dir, const char* name, fs_vnode node) 245 { 246 return B_BAD_VALUE; 247 } 248 249 // Unlink 250 status_t 251 Volume::Unlink(fs_vnode dir, const char* name) 252 { 253 return B_BAD_VALUE; 254 } 255 256 // Rename 257 status_t 258 Volume::Rename(fs_vnode oldDir, const char* oldName, fs_vnode newDir, 259 const char* newName) 260 { 261 return B_BAD_VALUE; 262 } 263 264 // Access 265 status_t 266 Volume::Access(fs_vnode node, int mode) 267 { 268 return B_BAD_VALUE; 269 } 270 271 // ReadStat 272 status_t 273 Volume::ReadStat(fs_vnode node, struct stat* st) 274 { 275 return B_BAD_VALUE; 276 } 277 278 // WriteStat 279 status_t 280 Volume::WriteStat(fs_vnode node, const struct stat *st, uint32 mask) 281 { 282 return B_BAD_VALUE; 283 } 284 285 286 // #pragma mark - files 287 288 289 // Create 290 status_t 291 Volume::Create(fs_vnode dir, const char* name, int openMode, int mode, 292 fs_cookie* cookie, vnode_id* vnid) 293 { 294 return B_BAD_VALUE; 295 } 296 297 // Open 298 status_t 299 Volume::Open(fs_vnode node, int openMode, fs_cookie* cookie) 300 { 301 return B_BAD_VALUE; 302 } 303 304 // Close 305 status_t 306 Volume::Close(fs_vnode node, fs_cookie cookie) 307 { 308 return B_BAD_VALUE; 309 } 310 311 // FreeCookie 312 status_t 313 Volume::FreeCookie(fs_vnode node, fs_cookie cookie) 314 { 315 return B_BAD_VALUE; 316 } 317 318 // Read 319 status_t 320 Volume::Read(fs_vnode node, fs_cookie cookie, off_t pos, void* buffer, 321 size_t bufferSize, size_t* bytesRead) 322 { 323 return B_BAD_VALUE; 324 } 325 326 // Write 327 status_t 328 Volume::Write(fs_vnode node, fs_cookie cookie, off_t pos, const void* buffer, 329 size_t bufferSize, size_t* bytesWritten) 330 { 331 return B_BAD_VALUE; 332 } 333 334 335 // #pragma mark - directories 336 337 338 // CreateDir 339 status_t 340 Volume::CreateDir(fs_vnode dir, const char* name, int mode, vnode_id *newDir) 341 { 342 return B_BAD_VALUE; 343 } 344 345 // RemoveDir 346 status_t 347 Volume::RemoveDir(fs_vnode dir, const char* name) 348 { 349 return B_BAD_VALUE; 350 } 351 352 // OpenDir 353 status_t 354 Volume::OpenDir(fs_vnode node, fs_cookie* cookie) 355 { 356 return B_BAD_VALUE; 357 } 358 359 // CloseDir 360 status_t 361 Volume::CloseDir(fs_vnode node, fs_vnode cookie) 362 { 363 return B_BAD_VALUE; 364 } 365 366 // FreeDirCookie 367 status_t 368 Volume::FreeDirCookie(fs_vnode node, fs_vnode cookie) 369 { 370 return B_BAD_VALUE; 371 } 372 373 // ReadDir 374 status_t 375 Volume::ReadDir(fs_vnode node, fs_vnode cookie, void* buffer, size_t bufferSize, 376 uint32 count, uint32* countRead) 377 { 378 return B_BAD_VALUE; 379 } 380 381 // RewindDir 382 status_t 383 Volume::RewindDir(fs_vnode node, fs_vnode cookie) 384 { 385 return B_BAD_VALUE; 386 } 387 388 389 // #pragma mark - attribute directories 390 391 392 // OpenAttrDir 393 status_t 394 Volume::OpenAttrDir(fs_vnode node, fs_cookie *cookie) 395 { 396 return B_BAD_VALUE; 397 } 398 399 // CloseAttrDir 400 status_t 401 Volume::CloseAttrDir(fs_vnode node, fs_cookie cookie) 402 { 403 return B_BAD_VALUE; 404 } 405 406 // FreeAttrDirCookie 407 status_t 408 Volume::FreeAttrDirCookie(fs_vnode node, fs_cookie cookie) 409 { 410 return B_BAD_VALUE; 411 } 412 413 // ReadAttrDir 414 status_t 415 Volume::ReadAttrDir(fs_vnode node, fs_cookie cookie, void* buffer, 416 size_t bufferSize, uint32 count, uint32* countRead) 417 { 418 return B_BAD_VALUE; 419 } 420 421 // RewindAttrDir 422 status_t 423 Volume::RewindAttrDir(fs_vnode node, fs_cookie cookie) 424 { 425 return B_BAD_VALUE; 426 } 427 428 429 // #pragma mark - attributes 430 431 432 // CreateAttr 433 status_t 434 Volume::CreateAttr(fs_vnode node, const char* name, uint32 type, int openMode, 435 fs_cookie* cookie) 436 { 437 return B_BAD_VALUE; 438 } 439 440 // OpenAttr 441 status_t 442 Volume::OpenAttr(fs_vnode node, const char* name, int openMode, 443 fs_cookie* cookie) 444 { 445 return B_BAD_VALUE; 446 } 447 448 // CloseAttr 449 status_t 450 Volume::CloseAttr(fs_vnode node, fs_cookie cookie) 451 { 452 return B_BAD_VALUE; 453 } 454 455 // FreeAttrCookie 456 status_t 457 Volume::FreeAttrCookie(fs_vnode node, fs_cookie cookie) 458 { 459 return B_BAD_VALUE; 460 } 461 462 // ReadAttr 463 status_t 464 Volume::ReadAttr(fs_vnode node, fs_cookie cookie, off_t pos, void* buffer, 465 size_t bufferSize, size_t* bytesRead) 466 { 467 return B_BAD_VALUE; 468 } 469 470 // WriteAttr 471 status_t 472 Volume::WriteAttr(fs_vnode node, fs_cookie cookie, off_t pos, 473 const void* buffer, size_t bufferSize, size_t* bytesWritten) 474 { 475 return B_BAD_VALUE; 476 } 477 478 // ReadAttrStat 479 status_t 480 Volume::ReadAttrStat(fs_vnode node, fs_cookie cookie, struct stat *st) 481 { 482 return B_BAD_VALUE; 483 } 484 485 // WriteAttrStat 486 status_t 487 Volume::WriteAttrStat(fs_vnode node, fs_cookie cookie, const struct stat* st, 488 int statMask) 489 { 490 return B_BAD_VALUE; 491 } 492 493 // RenameAttr 494 status_t 495 Volume::RenameAttr(fs_vnode oldNode, const char* oldName, fs_vnode newNode, 496 const char* newName) 497 { 498 return B_BAD_VALUE; 499 } 500 501 // RemoveAttr 502 status_t 503 Volume::RemoveAttr(fs_vnode node, const char* name) 504 { 505 return B_BAD_VALUE; 506 } 507 508 509 // #pragma mark - indices 510 511 512 // OpenIndexDir 513 status_t 514 Volume::OpenIndexDir(fs_cookie *cookie) 515 { 516 return B_BAD_VALUE; 517 } 518 519 // CloseIndexDir 520 status_t 521 Volume::CloseIndexDir(fs_cookie cookie) 522 { 523 return B_BAD_VALUE; 524 } 525 526 // FreeIndexDirCookie 527 status_t 528 Volume::FreeIndexDirCookie(fs_cookie cookie) 529 { 530 return B_BAD_VALUE; 531 } 532 533 // ReadIndexDir 534 status_t 535 Volume::ReadIndexDir(fs_cookie cookie, void* buffer, size_t bufferSize, 536 uint32 count, uint32* countRead) 537 { 538 return B_BAD_VALUE; 539 } 540 541 // RewindIndexDir 542 status_t 543 Volume::RewindIndexDir(fs_cookie cookie) 544 { 545 return B_BAD_VALUE; 546 } 547 548 // CreateIndex 549 status_t 550 Volume::CreateIndex(const char* name, uint32 type, uint32 flags) 551 { 552 return B_BAD_VALUE; 553 } 554 555 // RemoveIndex 556 status_t 557 Volume::RemoveIndex(const char* name) 558 { 559 return B_BAD_VALUE; 560 } 561 562 // ReadIndexStat 563 status_t 564 Volume::ReadIndexStat(const char *name, struct stat *st) 565 { 566 return B_BAD_VALUE; 567 } 568 569 570 // #pragma mark - queries 571 572 573 // OpenQuery 574 status_t 575 Volume::OpenQuery(const char* queryString, uint32 flags, port_id port, 576 uint32 token, fs_cookie *cookie) 577 { 578 return B_BAD_VALUE; 579 } 580 581 // CloseQuery 582 status_t 583 Volume::CloseQuery(fs_cookie cookie) 584 { 585 return B_BAD_VALUE; 586 } 587 588 // FreeQueryCookie 589 status_t 590 Volume::FreeQueryCookie(fs_cookie cookie) 591 { 592 return B_BAD_VALUE; 593 } 594 595 // ReadQuery 596 status_t 597 Volume::ReadQuery(fs_cookie cookie, void* buffer, size_t bufferSize, 598 uint32 count, uint32* countRead) 599 { 600 return B_BAD_VALUE; 601 } 602 603 // RewindQuery 604 status_t 605 Volume::RewindQuery(fs_cookie cookie) 606 { 607 return B_BAD_VALUE; 608 } 609 610