Ticket #2089: iso9660.newvfs.diff
File iso9660.newvfs.diff, 13.5 KB (added by , 17 years ago) |
---|
-
build/jam/HaikuImage
134 134 BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)ps2 $(X86_ONLY)isa ide scsi 135 135 config_manager agp_gart usb firewire 136 136 ; 137 BEOS_ADD_ONS_FILE_SYSTEMS = bfs fat ;138 #cdda googlefs iso9660nfs $(GPL_ONLY)ntfs ;137 BEOS_ADD_ONS_FILE_SYSTEMS = bfs fat iso9660 ; 138 #cdda googlefs nfs $(GPL_ONLY)ntfs ; 139 139 140 140 141 141 # modules -
src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp
97 97 98 98 99 99 static status_t 100 fs_mount( dev_t mountID, const char *device, uint32 flags,101 const char *args, void **_volume,ino_t *_rootID)100 fs_mount(fs_volume *_volume, const char *device, uint32 flags, 101 const char *args, ino_t *_rootID) 102 102 { 103 103 bool allowJoliet = true; 104 104 nspace *volume; … … 127 127 status_t result = ISOMount(device, O_RDONLY, &volume, allowJoliet); 128 128 if (result == B_OK) { 129 129 *_rootID = ISO_ROOTNODE_ID; 130 *_volume = volume;131 130 132 volume->id = mountID; 131 _volume->private_volume = volume; 132 _volume->ops = &sISO9660VolumeOps; 133 volume->volume = _volume; 134 volume->id = _volume->id; 133 135 134 result = publish_vnode(mountID, *_rootID, &volume->rootDirRec); 136 result = publish_vnode(_volume, *_rootID, &volume->rootDirRec, 137 &sISO9660VnodeOps, volume->rootDirRec.attr.stat[FS_DATA_FORMAT].st_mode, 0); 135 138 if (result != B_OK) { 136 139 block_cache_delete(volume->fBlockCache, false); 137 140 free(volume); … … 143 146 144 147 145 148 static status_t 146 fs_unmount( void *_ns)149 fs_unmount(fs_volume *_vol) 147 150 { 148 151 status_t result = B_NO_ERROR; 149 nspace *ns = (nspace *)_ ns;152 nspace *ns = (nspace *)_vol->private_volume; 150 153 151 154 TRACE(("fs_unmount - ENTER\n")); 152 155 153 156 // Unlike in BeOS, we need to put the reference to our root node ourselves 154 put_vnode( ns->id, ISO_ROOTNODE_ID);157 put_vnode(_vol, ISO_ROOTNODE_ID); 155 158 156 159 block_cache_delete(ns->fBlockCache, false); 157 160 close(ns->fdOfSession); … … 165 168 166 169 167 170 static status_t 168 fs_read_fs_stat( void *_ns, struct fs_info *fss)171 fs_read_fs_stat(fs_volume *_vol, struct fs_info *fss) 169 172 { 170 nspace *ns = (nspace *)_ ns;173 nspace *ns = (nspace *)_vol->private_volume; 171 174 int i; 172 175 173 176 fss->flags = B_FS_IS_PERSISTENT | B_FS_IS_READONLY; … … 195 198 196 199 197 200 static status_t 198 fs_get_vnode_name( void *ns, void*_node, char *buffer, size_t bufferSize)201 fs_get_vnode_name(fs_volume *_vol, fs_vnode *_node, char *buffer, size_t bufferSize) 199 202 { 200 vnode *node = (vnode*)_node ;203 vnode *node = (vnode*)_node->private_node; 201 204 202 205 strlcpy(buffer, node->fileIDString, bufferSize); 203 206 return B_OK; … … 205 208 206 209 207 210 static status_t 208 fs_walk( void *_ns, void *base, const char *file, ino_t *_vnodeID, int *_type)211 fs_walk(fs_volume *_vol, fs_vnode *_base, const char *file, ino_t *_vnodeID) 209 212 { 210 nspace *ns = (nspace *)_ ns;211 vnode *baseNode = (vnode*) base;213 nspace *ns = (nspace *)_vol->private_volume; 214 vnode *baseNode = (vnode*)_base->private_node; 212 215 vnode *newNode = NULL; 213 216 214 217 TRACE(("fs_walk - looking for %s in dir file of length %d\n", file, … … 218 221 // base directory 219 222 TRACE(("fs_walk - found \".\" file.\n")); 220 223 *_vnodeID = baseNode->id; 221 *_type = S_IFDIR; 222 return get_vnode(ns->id, *_vnodeID, (void **)&newNode); 224 return get_vnode(_vol, *_vnodeID, (void **)&newNode); 223 225 } else if (strcmp(file, "..") == 0) { 224 226 // parent directory 225 227 TRACE(("fs_walk - found \"..\" file.\n")); 226 228 *_vnodeID = baseNode->parID; 227 *_type = S_IFDIR; 228 return get_vnode(ns->id, *_vnodeID, (void **)&newNode); 229 return get_vnode(_vol, *_vnodeID, (void **)&newNode); 229 230 } 230 231 231 232 // look up file in the directory … … 269 270 + (blockBytesRead & 0xffffffff); 270 271 TRACE(("fs_walk - New vnode id is %Ld\n", *_vnodeID)); 271 272 272 result = get_vnode( ns->id, *_vnodeID,273 result = get_vnode(_vol, *_vnodeID, 273 274 (void **)&newNode); 274 275 if (result == B_OK) { 275 276 newNode->parID = baseNode->id; … … 302 303 done = TRUE; 303 304 } 304 305 305 if (newNode)306 *_type = newNode->attr.stat[FS_DATA_FORMAT].st_mode;307 308 306 TRACE(("fs_walk - EXIT, result is %s, vnid is %Lu\n", 309 307 strerror(result), *_vnodeID)); 310 308 return result; … … 312 310 313 311 314 312 static status_t 315 fs_read_vnode(void *_ns, ino_t vnodeID, void **_node, bool reenter) 313 fs_read_vnode(fs_volume *_vol, ino_t vnodeID, fs_vnode *_node, 314 int *_type, uint32 *_flags, bool reenter) 316 315 { 317 nspace *ns = (nspace*)_ ns;316 nspace *ns = (nspace*)_vol->private_volume; 318 317 319 318 vnode *newNode = (vnode*)calloc(sizeof(vnode), 1); 320 319 if (newNode == NULL) … … 345 344 } 346 345 347 346 newNode->id = vnodeID; 348 *_node = (void *)newNode; 347 _node->private_node = newNode; 348 _node->ops = &sISO9660VnodeOps; 349 *_type = newNode->attr.stat[FS_DATA_FORMAT].st_mode & ~(S_IWUSR | S_IWGRP | S_IWOTH); 350 *_flags = 0; 349 351 350 352 if ((newNode->flags & ISO_ISDIR) == 0) { 351 353 newNode->cache = file_cache_create(ns->id, vnodeID, … … 357 359 358 360 359 361 static status_t 360 fs_release_vnode( void *ns, void*_node, bool reenter)362 fs_release_vnode(fs_volume *_vol, fs_vnode *_node, bool reenter) 361 363 { 362 364 status_t result = B_NO_ERROR; 363 vnode *node = (vnode*)_node ;365 vnode *node = (vnode*)_node->private_node; 364 366 365 (void) ns;367 (void)_vol; 366 368 (void)reenter; 367 369 368 370 TRACE(("fs_release_vnode - ENTER (0x%x)\n", node)); … … 386 388 387 389 388 390 static status_t 389 fs_read_pages(fs_volume _fs, fs_vnode _node, fs_cookie_cookie, off_t pos,391 fs_read_pages(fs_volume *_vol, fs_vnode *_node, void * _cookie, off_t pos, 390 392 const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) 391 393 { 392 nspace *ns = (nspace *)_ fs;393 vnode *node = (vnode *)_node ;394 nspace *ns = (nspace *)_vol->private_volume; 395 vnode *node = (vnode *)_node->private_node; 394 396 395 397 uint32 fileSize = node->dataLen[FS_DATA_FORMAT]; 396 398 size_t bytesLeft = *_numBytes; … … 417 419 418 420 419 421 static status_t 420 fs_read_stat( void *_ns, void*_node, struct stat *st)422 fs_read_stat(fs_volume *_vol, fs_vnode *_node, struct stat *st) 421 423 { 422 nspace *ns = (nspace*)_ ns;423 vnode *node = (vnode*)_node ;424 nspace *ns = (nspace*)_vol->private_volume; 425 vnode *node = (vnode*)_node->private_node; 424 426 status_t result = B_NO_ERROR; 425 427 time_t time; 426 428 … … 446 448 447 449 448 450 static status_t 449 fs_open( void *_ns, void*_node, int omode, void **cookie)451 fs_open(fs_volume *_vol, fs_vnode *_node, int omode, void **cookie) 450 452 { 451 453 status_t result = B_NO_ERROR; 452 454 453 (void)_ ns;455 (void)_vol; 454 456 (void)cookie; 455 457 456 458 // Do not allow any of the write-like open modes to get by … … 464 466 465 467 466 468 static status_t 467 fs_read( void *_ns, void*_node, void *cookie, off_t pos, void *buffer,469 fs_read(fs_volume *_vol, fs_vnode *_node, void *cookie, off_t pos, void *buffer, 468 470 size_t *_length) 469 471 { 470 vnode *node = (vnode *)_node ;472 vnode *node = (vnode *)_node->private_node; 471 473 472 474 if (node->flags & ISO_ISDIR) 473 475 return EISDIR; … … 487 489 488 490 489 491 static status_t 490 fs_close( void *ns, void *node, void *cookie)492 fs_close(fs_volume *_vol, fs_vnode *_node, void *cookie) 491 493 { 492 (void) ns;493 (void) node;494 (void)_vol; 495 (void)_node; 494 496 (void)cookie; 495 497 496 498 return B_OK; … … 498 500 499 501 500 502 static status_t 501 fs_free_cookie( void *ns, void *node, void *cookie)503 fs_free_cookie(fs_volume *_vol, fs_vnode *_node, void *cookie) 502 504 { 503 (void) ns;504 (void) node;505 (void)_vol; 506 (void)_node; 505 507 (void)cookie; 506 508 507 509 return B_OK; … … 509 511 510 512 511 513 static status_t 512 fs_access( void *ns, void *node, int mode)514 fs_access(fs_volume *_vol, fs_vnode *_node, int mode) 513 515 { 514 (void) ns;515 (void) node;516 (void)_vol; 517 (void)_node; 516 518 (void)mode; 517 519 518 520 return B_OK; … … 520 522 521 523 522 524 static status_t 523 fs_read_link( void */*_volume*/, void*_node, char *buffer, size_t *_bufferSize)525 fs_read_link(fs_volume *_vol, fs_vnode *_node, char *buffer, size_t *_bufferSize) 524 526 { 525 vnode *node = (vnode *)_node ;527 vnode *node = (vnode *)_node->private_node; 526 528 527 529 if (!S_ISLNK(node->attr.stat[FS_DATA_FORMAT].st_mode)) 528 530 return B_BAD_VALUE; … … 540 542 541 543 542 544 static status_t 543 fs_open_dir( void *_ns, void*_node, void **cookie)545 fs_open_dir(fs_volume *_vol, fs_vnode *_node, void **cookie) 544 546 { 545 vnode *node = (vnode *)_node ;547 vnode *node = (vnode *)_node->private_node; 546 548 547 549 TRACE(("fs_open_dir - node is 0x%x\n", _node)); 548 550 … … 565 567 566 568 567 569 static status_t 568 fs_read_dir( void *_ns, void*_node, void *_cookie, struct dirent *buffer,570 fs_read_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buffer, 569 571 size_t bufferSize, uint32 *num) 570 572 { 571 nspace *ns = (nspace *)_ ns;573 nspace *ns = (nspace *)_vol->private_volume; 572 574 dircookie *dirCookie = (dircookie *)_cookie; 573 575 574 576 TRACE(("fs_read_dir - ENTER\n")); … … 593 595 594 596 595 597 static status_t 596 fs_rewind_dir( void *ns, void *node, void* _cookie)598 fs_rewind_dir(fs_volume *_vol, fs_vnode *_node, void* _cookie) 597 599 { 598 600 dircookie *cookie = (dircookie*)_cookie; 599 601 … … 604 606 605 607 606 608 static status_t 607 fs_close_dir( void *ns, void *node, void *cookie)609 fs_close_dir(fs_volume *_vol, fs_vnode *_node, void *cookie) 608 610 { 609 611 return B_OK; 610 612 } 611 613 612 614 613 615 static status_t 614 fs_free_dir_cookie( void *ns, void *node, void *cookie)616 fs_free_dir_cookie(fs_volume *_vol, fs_vnode *_node, void *cookie) 615 617 { 616 618 free(cookie); 617 619 return B_OK; … … 634 636 } 635 637 636 638 637 static file_system_module_info sISO660FileSystem= {638 {639 "file_systems/iso9660" B_CURRENT_FS_API_VERSION,640 0,641 iso_std_ops,642 },639 fs_volume_ops sISO9660VolumeOps = { 640 &fs_unmount, 641 &fs_read_fs_stat, 642 NULL, 643 NULL, 644 &fs_read_vnode, 643 645 644 "ISO9660 File System", 645 0, // DDM flags 646 /* index and index directory ops */ 647 NULL, 648 NULL, 649 NULL, 650 NULL, 651 NULL, 652 NULL, 653 NULL, 654 NULL, 646 655 647 // scanning 648 fs_identify_partition, 649 fs_scan_partition, 650 fs_free_identify_partition_cookie, 651 NULL, // free_partition_content_cookie() 656 /* query ops */ 657 NULL, 658 NULL, 659 NULL, 660 NULL, 661 NULL, 652 662 653 &fs_mount, 654 &fs_unmount, 655 &fs_read_fs_stat, 663 /* FS layer ops */ 656 664 NULL, 657 665 NULL, 666 }; 658 667 659 /* vnode operations */ 668 fs_vnode_ops sISO9660VnodeOps = { 660 669 &fs_walk, 661 670 &fs_get_vnode_name, 662 &fs_read_vnode,663 671 &fs_release_vnode, 664 NULL, // fs_remove_vnode()672 NULL, 665 673 666 /* VM file access */667 NULL, // fs_can_page674 /* vm-related ops */ 675 NULL, 668 676 &fs_read_pages, 669 NULL, // fs_write_pages677 NULL, 670 678 671 NULL, // fs_get_file_map 679 /* cache file access */ 680 NULL, 672 681 673 NULL, // fs_ioctl674 NULL, // fs_set_flags675 NULL, // fs_select676 NULL, // fs_deselect677 NULL, // fs_fsync678 682 /* common */ 683 NULL, 684 NULL, 685 NULL, 686 NULL, 687 NULL, 679 688 &fs_read_link, 680 NULL, // fs_create_symlink 681 682 NULL, // fs_link, 683 NULL, // fs_unlink 684 NULL, // fs_rename 685 689 NULL, 690 NULL, 691 NULL, 692 NULL, 686 693 &fs_access, 687 694 &fs_read_stat, 688 NULL, // fs_write_stat695 NULL, 689 696 690 /* file operations*/691 NULL, // fs_create697 /* file */ 698 NULL, 692 699 &fs_open, 693 700 &fs_close, 694 701 &fs_free_cookie, 695 702 &fs_read, 696 NULL, // fs_write703 NULL, 697 704 698 /* dir ectory operations*/699 NULL, // fs_create_dir700 NULL, // fs_remove_dir705 /* dir */ 706 NULL, 707 NULL, 701 708 &fs_open_dir, 702 709 &fs_close_dir, 703 710 &fs_free_dir_cookie, 704 711 &fs_read_dir, 705 712 &fs_rewind_dir, 706 707 /* attribute directory operations */708 NULL, // fs_open_attr_dir709 NULL, // fs_close_attr_dir710 NULL, // fs_free_attr_dir_cookie711 NULL, // fs_read_attr_dir712 NULL, // fs_rewind_attr_dir713 713 714 /* attribute operations */ 715 NULL, // fs_create_attr 716 NULL, // fs_open_attr 717 NULL, // fs_close_attr 718 NULL, // fs_free_attr_cookie 719 NULL, // fs_read_attr 720 NULL, // fs_write_attr 714 /* attribute directory ops */ 715 NULL, 716 NULL, 717 NULL, 718 NULL, 719 NULL, 721 720 722 NULL, // fs_read_attr_stat 723 NULL, // fs_write_attr_stat 724 NULL, // fs_rename_attr 725 NULL, // fs_remove_attr 721 /* attribute ops */ 722 NULL, 723 NULL, 724 NULL, 725 NULL, 726 NULL, 727 NULL, 728 NULL, 729 NULL, 730 NULL, 731 NULL, 726 732 727 /* index directory & index operations */ 728 NULL, // fs_open_index_dir 729 NULL, // fs_close_index_dir 730 NULL, // fs_free_index_dir_cookie 731 NULL, // fs_read_index_dir 732 NULL, // fs_rewind_index_dir 733 /* node and FS layer support */ 734 NULL, 735 NULL, 736 }; 733 737 734 NULL, // fs_create_index 735 NULL, // fs_remove_index 736 NULL, // fs_stat_index 738 static file_system_module_info sISO660FileSystem = { 739 { 740 "file_systems/iso9660" B_CURRENT_FS_API_VERSION, 741 0, 742 iso_std_ops, 743 }, 737 744 738 /* query operations */ 739 NULL, // fs_open_query 740 NULL, // fs_close_query 741 NULL, // fs_free_query_cookie 742 NULL, // fs_read_query 743 NULL, // fs_rewind_query 745 "ISO9660 File System", 746 0, // DDM flags 747 748 // scanning 749 fs_identify_partition, 750 fs_scan_partition, 751 fs_free_identify_partition_cookie, 752 NULL, // free_partition_content_cookie() 753 754 &fs_mount, 755 756 /* capability querying */ 757 NULL, 758 NULL, 759 NULL, 760 NULL, 761 NULL, 762 NULL, 763 764 /* shadow partition modifications */ 765 NULL, 766 767 /* writing */ 768 NULL, 769 NULL, 770 NULL, 771 NULL, 772 NULL, 773 NULL, 774 NULL, 744 775 }; 745 776 746 777 module_info *modules[] = { -
src/add-ons/kernel/file_systems/iso9660/iso9660.h
165 165 166 166 typedef struct nspace { 167 167 // Start of members other drivers will definitely want. 168 dev_t id; // ID passed in to fs_mount 168 fs_volume *volume; // volume passed fo fs_mount 169 dev_t id; 169 170 int fd; // File descriptor 170 171 int fdOfSession; // File descriptor of the (mounted) session 171 172 //unsigned int blockSize; // usually need this, but it's part of ISO … … 220 221 uint8 fileStructVers; // File structure version byte882 221 222 } nspace; 222 223 224 extern fs_volume_ops sISO9660VolumeOps; 225 extern fs_vnode_ops sISO9660VnodeOps; 226 223 227 #ifdef __cplusplus 224 228 extern "C" { 225 229 #endif