- Timestamp:
- Sep 22, 2012 12:09:45 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 80890
- Location:
- trunk/src/VBox/Additions/haiku/SharedFolders
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.c
r43364 r43404 46 46 #include "vboxsf.h" 47 47 48 #define MODULE_NAME "file_systems/vboxsf" 49 #define FS_NAME "vboxsf" 48 #define MODULE_NAME "file_systems/vboxsf" 49 #define FS_NAME "vboxsf" 50 #define FS_PRETTY_NAME "VirtualBox Shared Folders" 50 51 51 52 VBSFCLIENT g_clientHandle; … … 55 56 status_t init_module(void) 56 57 { 58 #if 0 59 /* @todo enable this soon */ 60 int rc = get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest); 61 if (RT_LIKELY(rc == B_OK) 62 { 63 rc = vboxInit(); 64 if (RT_SUCCESS(rc)) 65 { 66 rc = vboxConnect(&g_clientHandle); 67 if (RT_SUCCESS(rc)) 68 { 69 rc = vboxCallSetUtf8(&g_clientHandle); 70 if (RT_SUCCESS(rc)) 71 { 72 rc = vboxCallSetSymlinks(&g_clientHandle); 73 if (RT_FAILURE(rc)) 74 LogRel((FS_NAME ":Warning! vboxCallSetSymlinks failed (rc=%d) - symlink will appear as copies.\n", rc)); 75 76 mutex_init(&g_vnodeCacheLock, "vboxsf vnode cache lock"); 77 Log((FS_NAME ":init_module succeeded.\n"); 78 return B_OK; 79 } 80 else 81 LogRel((FS_NAME ":vboxCallSetUtf8 failed. rc=%d\n", rc)); 82 } 83 else 84 LogRel((FS_NAME ":vboxConnect failed. rc=%d\n", rc)); 85 } 86 else 87 LogRel((FS_NAME ":vboxInit failed. rc=%d\n", rc)); 88 } 89 else 90 LogRel((FS_NAME ":get_module failed for '%s'. rc=%d\n", VBOXGUEST_MODULE_NAME, rc)); 91 92 return B_ERROR; 93 #endif 94 57 95 if (get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest) != B_OK) 58 96 { … … 157 195 PSHFLSTRING build_path(vboxsf_vnode* dir, const char* const name) 158 196 { 159 160 197 dprintf("*** build_path(%p, %p)\n", dir, name); 161 198 if (!dir || !name) … … 265 302 } 266 303 267 st->st_dev = 0;268 st->st_ino = vnode->vnode;269 st->st_mode = mode_from_fmode(params.Info.Attr.fMode);270 st->st_nlink = 1;271 st->st_uid = 0;272 st->st_gid = 0;273 st->st_rdev = 0;274 st->st_size = params.Info.cbObject;304 st->st_dev = 0; 305 st->st_ino = vnode->vnode; 306 st->st_mode = mode_from_fmode(params.Info.Attr.fMode); 307 st->st_nlink = 1; 308 st->st_uid = 0; 309 st->st_gid = 0; 310 st->st_rdev = 0; 311 st->st_size = params.Info.cbObject; 275 312 st->st_blksize = 1; 276 st->st_blocks = params.Info.cbAllocated;277 st->st_atime = RTTimeSpecGetSeconds(¶ms.Info.AccessTime);278 st->st_mtime = RTTimeSpecGetSeconds(¶ms.Info.ModificationTime);279 st->st_ctime = RTTimeSpecGetSeconds(¶ms.Info.BirthTime);313 st->st_blocks = params.Info.cbAllocated; 314 st->st_atime = RTTimeSpecGetSeconds(¶ms.Info.AccessTime); 315 st->st_mtime = RTTimeSpecGetSeconds(¶ms.Info.ModificationTime); 316 st->st_ctime = RTTimeSpecGetSeconds(¶ms.Info.BirthTime); 280 317 return B_OK; 281 318 } … … 290 327 RT_ZERO(params); 291 328 params.Handle = SHFL_HANDLE_NIL; 292 params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS 293 | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ; 329 params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ; 294 330 295 331 int rc = vboxCallCreate(&g_clientHandle, &volume->map, vnode->path, ¶ms); … … 332 368 cookie->buffer_start = cookie->buffer = malloc(cookie->buffer_length); 333 369 334 int rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path, 335 0, cookie->index,&cookie->buffer_length, cookie->buffer, &cookie->num_files);370 int rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path, 0, cookie->index, 371 &cookie->buffer_length, cookie->buffer, &cookie->num_files); 336 372 337 373 if (rc != 0 && rc != VERR_NO_MORE_FILES) … … 372 408 return rv; 373 409 } 410 374 411 buffer->d_dev = 0; 375 412 buffer->d_pdev = 0; … … 453 490 info->flags |= B_FS_IS_READONLY; 454 491 455 info->dev = 0;456 info->root = 1;457 info->block_size = volume_info.ulBytesPerAllocationUnit;458 info->io_size = volume_info.ulBytesPerAllocationUnit;492 info->dev = 0; 493 info->root = 1; 494 info->block_size = volume_info.ulBytesPerAllocationUnit; 495 info->io_size = volume_info.ulBytesPerAllocationUnit; 459 496 info->total_blocks = volume_info.ullTotalAllocationBytes / info->block_size; 460 info->free_blocks = volume_info.ullAvailableAllocationBytes / info->block_size;461 info->total_nodes = LONGLONG_MAX;462 info->free_nodes = LONGLONG_MAX;497 info->free_blocks = volume_info.ullAvailableAllocationBytes / info->block_size; 498 info->total_nodes = LONGLONG_MAX; 499 info->free_nodes = LONGLONG_MAX; 463 500 strcpy(info->volume_name, "VBox share"); 464 501 return B_OK; … … 730 767 731 768 uint32_t l = *length; 732 void* other_buffer = malloc(l); // TODO map the user memory into kernel space here for efficiency769 void* other_buffer = malloc(l); /* @todo map the user memory into kernel space here for efficiency */ 733 770 int rc = vboxCallRead(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false); 734 771 memcpy(buffer, other_buffer, l); … … 751 788 752 789 uint32_t l = *length; 753 void* other_buffer = malloc(l); // TODO map the user memory into kernel space here for efficiency790 void* other_buffer = malloc(l); /* @todo map the user memory into kernel space here for efficiency */ 754 791 memcpy(other_buffer, buffer, l); 755 792 int rc = vboxCallWrite(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false); … … 763 800 status_t vboxsf_write_stat(fs_volume *volume, fs_vnode *vnode, const struct stat *stat, uint32 statMask) 764 801 { 765 / / the host handles updating the stat info - in the guest, this is a no-op802 /* The host handles updating the stat info - in the guest, this is a no-op */ 766 803 return B_OK; 767 804 } … … 781 818 int rc = vboxCallCreate(&g_clientHandle, &volume->map, path, ¶ms); 782 819 free(path); 820 /** @todo r=ramshankar: we should perhaps also check rc here and change 821 * Handle initialization from 0 to SHFL_HANDLE_NIL. */ 783 822 if (params.Handle == SHFL_HANDLE_NIL) 784 823 return vbox_err_to_haiku_err(rc); … … 864 903 865 904 866 / / TODO move this into the runtime905 /* @todo move this into the runtime */ 867 906 status_t vbox_err_to_haiku_err(int rc) 868 907 { 869 switch (rc) {870 case VINF_SUCCESS: return B_OK;871 case V ERR_INVALID_POINTER: return B_BAD_ADDRESS;872 case VERR_INVALID_P ARAMETER: return B_BAD_VALUE;873 case VERR_ PERMISSION_DENIED: return B_PERMISSION_DENIED;874 case VERR_ NOT_IMPLEMENTED: return B_UNSUPPORTED;875 case VERR_ FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND;876 877 case SHFL_FILE_EXISTS: return B_FILE_EXISTS; 908 switch (rc) 909 { 910 case VINF_SUCCESS: return B_OK; 911 case VERR_INVALID_POINTER: return B_BAD_ADDRESS; 912 case VERR_INVALID_PARAMETER: return B_BAD_VALUE; 913 case VERR_PERMISSION_DENIED: return B_PERMISSION_DENIED; 914 case VERR_NOT_IMPLEMENTED: return B_UNSUPPORTED; 915 case VERR_FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND; 916 878 917 case SHFL_PATH_NOT_FOUND: 879 case SHFL_FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND; 880 881 default: return B_ERROR; 918 case SHFL_FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND; 919 case SHFL_FILE_EXISTS: return B_FILE_EXISTS; 920 921 default: 922 return B_ERROR; 882 923 } 883 924 } … … 904 945 { 905 946 unmount, 906 vboxsf_read_fs_info, // read_fs_info907 NULL, // write_fs_info908 NULL, // sync909 vboxsf_get_vnode, // get_vnode910 NULL, // open_index_dir911 NULL, // close_index_dir912 NULL, // free_index_dir_cookie913 NULL, // read_index_dir914 NULL, // rewind_index_dir915 NULL, // create_index916 NULL, // remove_index917 NULL, // read_index_stat918 NULL, // open_query919 NULL, // close_query920 NULL, // free_query_cookie921 NULL, // read_query922 NULL, // rewind_query923 NULL, // all_layers_mounted924 NULL, // create_sub_vnode925 NULL, // delete_sub_vnode947 vboxsf_read_fs_info, 948 NULL, /* write_fs_info */ 949 NULL, /* sync */ 950 vboxsf_get_vnode, 951 NULL, /* open_index_dir */ 952 NULL, /* close_index_dir */ 953 NULL, /* free_index_dir_cookie */ 954 NULL, /* read_index_dir */ 955 NULL, /* rewind_index_dir */ 956 NULL, /* create_index */ 957 NULL, /* remove_index */ 958 NULL, /* read_index_stat */ 959 NULL, /* open_query */ 960 NULL, /* close_query */ 961 NULL, /* free_query_cookie */ 962 NULL, /* read_query */ 963 NULL, /* rewind_query */ 964 NULL, /* all_layers_mounted */ 965 NULL, /* create_sub_vnode */ 966 NULL, /* delete_sub_vnode */ 926 967 }; 927 968 928 969 static fs_vnode_ops vboxsf_vnode_ops = 929 970 { 930 vboxsf_lookup, // lookup931 NULL, // get_vnode_name932 vboxsf_put_vnode, // put_vnode933 NULL, // remove_vnode934 NULL, // can_page935 NULL, // read_pages936 NULL, // write_pages937 NULL, // io938 NULL, // cancel_io939 NULL, // get_file_map940 NULL, // ioctl941 NULL, // set_flags942 NULL, // select943 NULL, // deselect944 NULL, // fsync945 vboxsf_read_symlink, // read_symlink946 vboxsf_create_symlink, // create_symlink947 vboxsf_link, // link948 vboxsf_unlink, // unlink949 vboxsf_rename, // rename950 NULL, // access951 vboxsf_read_stat, // read_stat952 vboxsf_write_stat , // write_stat953 NULL, // preallocate954 vboxsf_create, // create955 vboxsf_open, // open956 vboxsf_close, // close957 vboxsf_free_cookie, // free_cookie958 vboxsf_read, // read959 vboxsf_write, // write960 vboxsf_create_dir, // create_dir961 vboxsf_remove_dir, // remove_dir962 vboxsf_open_dir, // open_dir963 vboxsf_close_dir, // close_dir964 vboxsf_free_dir_cookie, // free_dir_cookie965 vboxsf_read_dir, // read_dir966 vboxsf_rewind_dir, // rewind_dir967 NULL, // open_attr_dir968 NULL, // close_attr_dir969 NULL, // free_attr_dir_cookie970 NULL, // read_attr_dir971 NULL, // rewind_attr_dir972 NULL, // create_attr973 NULL, // open_attr974 NULL, // close_attr975 NULL, // free_attr_cookie976 NULL, // read_attr977 NULL, // write_attr978 NULL, // read_attr_stat979 NULL, // write_attr_stat980 NULL, // rename_attr981 NULL, // remove_attr982 NULL, // create_special_node983 NULL, // get_super_vnode971 vboxsf_lookup, 972 NULL, /* get_vnode_name */ 973 vboxsf_put_vnode, 974 NULL, /* remove_vnode */ 975 NULL, /* can_page */ 976 NULL, /* read_pages */ 977 NULL, /* write_pages */ 978 NULL, /* io */ 979 NULL, /* cancel_io */ 980 NULL, /* get_file_map */ 981 NULL, /* ioctl */ 982 NULL, /* set_flags */ 983 NULL, /* select */ 984 NULL, /* deselect */ 985 NULL, /* fsync */ 986 vboxsf_read_symlink, 987 vboxsf_create_symlink, 988 vboxsf_link, 989 vboxsf_unlink, 990 vboxsf_rename, 991 NULL, /* access */ 992 vboxsf_read_stat, 993 vboxsf_write_stat 994 NULL, /* preallocate */ 995 vboxsf_create, 996 vboxsf_open, 997 vboxsf_close, 998 vboxsf_free_cookie, 999 vboxsf_read, 1000 vboxsf_write, 1001 vboxsf_create_dir, 1002 vboxsf_remove_dir, 1003 vboxsf_open_dir, 1004 vboxsf_close_dir, 1005 vboxsf_free_dir_cookie, 1006 vboxsf_read_dir, 1007 vboxsf_rewind_dir, 1008 NULL, /* open_attr_dir */ 1009 NULL, /* close_attr_dir */ 1010 NULL, /* free_attr_dir_cookie */ 1011 NULL, /* read_attr_dir */ 1012 NULL, /* rewind_attr_dir */ 1013 NULL, /* create_attr */ 1014 NULL, /* open_attr */ 1015 NULL, /* close_attr */ 1016 NULL, /* free_attr_cookie */ 1017 NULL, /* read_attr */ 1018 NULL, /* write_attr */ 1019 NULL, /* read_attr_stat */ 1020 NULL, /* write_attr_stat */ 1021 NULL, /* rename_attr */ 1022 NULL, /* remove_attr */ 1023 NULL, /* create_special_node */ 1024 NULL, /* get_super_vnode */ 984 1025 }; 985 1026 … … 991 1032 std_ops, 992 1033 }, 993 FS_NAME, // short_name 994 "VirtualBox shared folders", // pretty_name 995 0, //B_DISK_SYSTEM_SUPPORTS_WRITING, // DDM flags 996 // scanning 997 NULL, // identify_partition 998 NULL, // scan_partition 999 NULL, // free_identify_partition_cookie 1000 NULL, // free_partition_content_cookie() 1034 FS_NAME, 1035 FS_PRETTY_NAME, 1036 0, /* DDM flags */ 1037 NULL, /* identify_partition */ 1038 NULL, /* scan_partition */ 1039 NULL, /* free_identify_partition_cookie */ 1040 NULL, /* free_partition_content_cookie */ 1001 1041 mount, 1002 1042 }; -
trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.h
r43364 r43404 91 91 extern "C" { 92 92 #endif 93 93 94 status_t vboxsf_new_vnode(PVBSFMAP map, PSHFLSTRING path, PSHFLSTRING name, vboxsf_vnode** p); 94 95 status_t vboxsf_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode, int* _type, uint32* _flags, bool reenter); … … 98 99 status_t vbox_err_to_haiku_err(int rc); 99 100 extern mutex g_vnodeCacheLock; 101 100 102 #ifdef __cplusplus 101 103 } 102 104 #endif 103 105 104 #endif 106 #endif /* ___vboxsf_h */ 105 107 -
trunk/src/VBox/Additions/haiku/SharedFolders/vnode_cache.cpp
r43364 r43404 49 49 struct HashTableDefinition 50 50 { 51 typedef uint32 KeyType;52 typedef 51 typedef uint32 KeyType; 52 typedef vboxsf_vnode ValueType; 53 53 54 54 size_t HashKey(uint32 key) const … … 116 116 117 117 extern "C" status_t vboxsf_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode, 118 int* _type, uint32* _flags, bool reenter)118 int* _type, uint32* _flags, bool reenter) 119 119 { 120 120 vboxsf_vnode* vn = g_cache.Lookup(id);
Note:
See TracChangeset
for help on using the changeset viewer.