Changeset 10140 in vbox
- Timestamp:
- Jul 3, 2008 8:45:37 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/solaris/SharedFolders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs.h
r10067 r10140 64 64 vnode_t *pVNodeDev; 65 65 vboxvfs_vnode_t *pVNodeRoot; 66 kmutex_t MtxFS; 66 67 } vboxvfs_globinfo_t; 67 68 -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vfsops.c
r10067 r10140 111 111 NULL /* terminate array of linkage structures */ 112 112 }; 113 114 /**115 * state info. for vboxvfs116 */117 typedef struct118 {119 /** Device Info handle. */120 dev_info_t *pDip;121 /** Driver Mutex. */122 kmutex_t Mtx;123 } vboxvfs_state_t;124 113 125 114 … … 146 135 LogFlow((DEVICE_NAME ":_init\n")); 147 136 148 int rc = ddi_soft_state_init(&g_pVBoxVFSState, sizeof(vboxvfs_state_t), 1); 149 if (!rc) 150 { 151 rc = mod_install(&g_VBoxVFSModLinkage); 152 if (rc) 153 ddi_soft_state_fini(&g_pVBoxVFSState); 154 } 155 return rc; 137 return mod_install(&g_VBoxVFSModLinkage);; 156 138 } 157 139 … … 162 144 163 145 int rc = mod_remove(&g_VBoxVFSModLinkage); 164 if (!rc) 165 ddi_soft_state_fini(&g_pVBoxVFSState); 166 return rc; 146 if (rc) 147 return rc; 148 149 /* Blow away the operation vectors*/ 150 vfs_freevfsops_by_type(g_VBoxVFSType); 151 vn_freevnodeops(g_pVBoxVFS_vnodeops); 167 152 } 168 153 … … 181 166 182 167 LogFlow((DEVICE_NAME ":VBoxVFS_Init\n")); 168 169 g_VBoxVFSType = fType; 183 170 184 171 /* Initialize the R0 guest library. */ … … 213 200 if (!rc) 214 201 { 215 g_VBoxVFSType = fType;216 202 LogFlow((DEVICE_NAME ":Successfully loaded vboxvfs.\n")); 217 203 return 0; … … 262 248 vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = NULL; 263 249 int AddrSpace = (pMount->flags & MS_SYSSPACE) ? UIO_SYSSPACE : UIO_USERSPACE; 264 #if 0265 caddr_t pData;266 size_t cbData;267 vboxvfs_mountinfo_t Args;268 #endif269 250 270 251 LogFlow((DEVICE_NAME ":VBoxVFS_Mount\n")); … … 304 285 return EINVAL; 305 286 } 306 307 /* Will be removed eventually... */308 #if 0309 /* Retreive arguments. */310 bzero(&Args, sizeof(Args));311 cbData = pMount->datalen;312 pData = pMount->data;313 if ( (pMount->flags & MS_DATA)314 && pData != NULL315 && cbData > 0)316 {317 if (cbData > sizeof(Args))318 {319 LogRel((DEVICE_NAME: "VBoxVFS_Mount: argument length too long. expected=%d. received=%d\n", sizeof(Args), cbData));320 return EINVAL;321 }322 323 /* Copy arguments; they can be in kernel or user space. */324 rc = ddi_copyin(pData, &Args, cbData, (pMount->flags & MS_SYSSPACE) ? FKIOCTL : 0);325 if (rc)326 {327 LogRel((DEVICE_NAME: "VBoxVFS_Mount: ddi_copyin failed to copy arguments.rc=%d\n", rc));328 return EFAULT;329 }330 }331 else332 {333 cbData = 0;334 pData = NULL;335 }336 #endif337 287 338 288 /* Get UID argument (optional). */ … … 412 362 /* Allocate the global info. structure. */ 413 363 pVBoxVFSGlobalInfo = RTMemAlloc(sizeof(*pVBoxVFSGlobalInfo)); 414 if (!pVBoxVFSGlobalInfo) 364 if (pVBoxVFSGlobalInfo) 365 { 366 cbShflShareName = offsetof(SHFLSTRING, String.utf8) + cbShare + 1; 367 pShflShareName = RTMemAllocZ(cbShflShareName); 368 if (pShflShareName) 369 { 370 pShflShareName->u16Length = cbShflShareName; 371 pShflShareName->u16Size = cbShflShareName + 1; 372 memcpy (pShflShareName->String.utf8, pszShare, cbShare + 1); 373 374 rc = vboxCallMapFolder(&g_VBoxVFSClient, pShflShareName, &pVBoxVFSGlobalInfo->Map); 375 RTMemFree(pShflShareName); 376 if (VBOX_SUCCESS(rc)) 377 rc = 0; 378 else 379 { 380 LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxCallMapFolder failed rc=%d\n", rc)); 381 rc = EPROTO; 382 } 383 } 384 else 385 { 386 LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for ShFlShareName.\n", cbShflShareName)); 387 rc = ENOMEM; 388 } 389 RTMemFree(pVBoxVFSGlobalInfo); 390 } 391 else 415 392 { 416 393 LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for global struct.\n", sizeof(*pVBoxVFSGlobalInfo))); 417 return ENOMEM; 418 } 419 420 cbShflShareName = offsetof(SHFLSTRING, String.utf8) + cbShare + 1; 421 pShflShareName = RTMemAllocZ(cbShflShareName); 422 if (!pShflShareName) 423 { 424 RTMemFree(pVBoxVFSGlobalInfo); 425 LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for ShFlShareName.\n", cbShflShareName)); 426 return ENOMEM; 427 } 428 429 pShflShareName->u16Length = cbShflShareName; 430 pShflShareName->u16Size = cbShflShareName + 1; 431 memcpy (pShflShareName->String.utf8, pszShare, cbShare + 1); 432 433 rc = vboxCallMapFolder(&g_VBoxVFSClient, pShflShareName, &pVBoxVFSGlobalInfo->Map); 434 RTMemFree(pShflShareName); 435 if (VBOX_FAILURE (rc)) 436 { 437 RTMemFree(pVBoxVFSGlobalInfo); 438 LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxCallMapFolder failed rc=%d\n", rc)); 439 return EPROTO; 440 } 441 442 /* @todo mutex for protecting the structure. */ 394 rc = ENOMEM; 395 } 396 397 /* Undo work on failure. */ 398 if (rc) 399 goto mntError1; 400 401 /* Initialize the per-filesystem mutex */ 402 mutex_init(&pVBoxVFSGlobalInfo->MtxFS, "VBoxVFS_FSMtx", MUTEX_DEFAULT, NULL); 403 443 404 pVBoxVFSGlobalInfo->Uid = Uid; 444 405 pVBoxVFSGlobalInfo->Gid = Gid; … … 452 413 /* Allocate root vboxvfs_vnode_t object */ 453 414 pVNodeRoot = RTMemAlloc(sizeof(*pVNodeRoot)); 454 if (!pVNodeRoot) 455 { 456 LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for root node.\n", sizeof(*pVNodeRoot))); 457 return ENOMEM; 458 } 459 460 /* Initialize the mutex */ 461 mutex_init(&pVNodeRoot->MtxContents, "VNodeMtx", MUTEX_DEFAULT, NULL); 462 463 /* Allocate root path */ 464 pVNodeRoot->pPath = RTMemAllocZ(sizeof(SHFLSTRING) + 1); 465 if (!pVNodeRoot->pPath) 466 { 467 LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for root path.\n", sizeof(SHFLSTRING) + 1)); 468 return ENOMEM; 469 } 470 471 /* Initialize root path */ 472 pVNodeRoot->pPath->u16Length = 1; 473 pVNodeRoot->pPath->u16Size = 2; 474 pVNodeRoot->pPath->String.utf8[0] = '/'; 475 pVNodeRoot->pPath->String.utf8[1] = '\0'; 476 477 /* Stat root node info from host */ 478 rc = vboxvfs_Stat(__func__, pVBoxVFSGlobalInfo, pVNodeRoot->pPath, &FSInfo, B_FALSE); 479 if (rc) 480 { 481 LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxvfs_Stat failed rc(errno)=%d\n", rc)); 482 return rc; 483 } 484 485 /* Initialize the root vboxvfs_node_t object */ 486 vboxvfs_InitVNode(pVBoxVFSGlobalInfo, pVNodeRoot, &FSInfo); 487 488 return 0; 415 if (pVNodeRoot) 416 { 417 /* Initialize vnode protection mutex */ 418 mutex_init(&pVNodeRoot->MtxContents, "VBoxVFS_VNodeMtx", MUTEX_DEFAULT, NULL); 419 420 pVBoxVFSGlobalInfo->pVNodeRoot = pVNodeRoot; 421 422 /* Allocate root path */ 423 pVNodeRoot->pPath = RTMemAllocZ(sizeof(SHFLSTRING) + 1); 424 if (pVNodeRoot->pPath) 425 { 426 /* Initialize root path */ 427 pVNodeRoot->pPath->u16Length = 1; 428 pVNodeRoot->pPath->u16Size = 2; 429 pVNodeRoot->pPath->String.utf8[0] = '/'; 430 pVNodeRoot->pPath->String.utf8[1] = '\0'; 431 432 /* Stat root node info from host */ 433 rc = vboxvfs_Stat(__func__, pVBoxVFSGlobalInfo, pVNodeRoot->pPath, &FSInfo, B_FALSE); 434 if (!rc) 435 { 436 /* Initialize the root vboxvfs_node_t object */ 437 vboxvfs_InitVNode(pVBoxVFSGlobalInfo, pVNodeRoot, &FSInfo); 438 439 /* Success! */ 440 return 0; 441 } 442 else 443 LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxvfs_Stat failed rc(errno)=%d\n", rc)); 444 RTMemFree(pVNodeRoot->pPath); 445 } 446 else 447 { 448 LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to alloc memory for root node path.\n")); 449 rc = ENOMEM; 450 } 451 RTMemFree(pVNodeRoot); 452 } 453 else 454 { 455 LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to alloc memory for root node.\n")); 456 rc = ENOMEM; 457 } 458 459 /* Undo work in reverse. */ 460 mntError1: 461 /* Just release the mount location. */ 462 VOP_CLOSE(pVNodeDev, (pVFS->vfs_flag & VFS_RDONLY) ? FREAD : FREAD | FWRITE, 1, (offset_t)0, pCred, NULL); 463 VN_RELE(pVNodeDev); 464 return rc; 489 465 } 490 466 … … 504 480 } 505 481 482 /* @todo -XXX - Not sure of supporting force unmounts. What this means is that a failed force mount could bring down 483 * the entire system as hanging about vnode releases would no longer be valid after unloading ourselves... 484 */ 506 485 if (fUnmount & MS_FORCE) 507 486 pVFS->vfs_flag |= VFS_UNMOUNTED; … … 517 496 VN_RELE(VBOXVN_TO_VN(pVBoxVFSGlobalInfo->pVNodeRoot)); 518 497 498 RTMemFree(pVBoxVFSGlobalInfo->pVNodeRoot->pPath); 499 RTMemFree(pVBoxVFSGlobalInfo->pVNodeRoot); 519 500 RTMemFree(pVBoxVFSGlobalInfo); 501 pVBoxVFSGlobalInfo = NULL; 520 502 pVFS->vfs_data = NULL; 521 503
Note:
See TracChangeset
for help on using the changeset viewer.