Changeset 6132 in vbox for trunk/src/VBox
- Timestamp:
- Dec 18, 2007 4:06:36 PM (17 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r6118 r6132 162 162 /** VMMDev Version. */ 163 163 uint32_t u32Version; 164 #ifndef USE_SESSION_HASH 165 /** Pointer to the session handle. */ 166 PVBOXGUESTSESSION pSession; 167 #endif 164 168 } VBoxAddDevState; 165 169 … … 174 178 /** Spinlock protecting g_apSessionHashTab. */ 175 179 static RTSPINLOCK g_Spinlock = NIL_RTSPINLOCK; 180 #ifdef USE_SESSION_HASH 176 181 /** Hash table */ 177 182 static PVBOXGUESTSESSION g_apSessionHashTab[19]; 178 183 /** Calculates the index into g_apSessionHashTab.*/ 179 184 #define SESSION_HASH(sfn) ((sfn) % RT_ELEMENTS(g_apSessionHashTab)) 185 #endif /* USE_SESSION_HASH */ 180 186 181 187 /** GCC C++ hack. */ … … 238 244 239 245 instance = ddi_get_instance(pDip); 246 #ifdef USE_SESSION_HASH 240 247 rc = ddi_soft_state_zalloc(g_pVBoxAddSolarisState, instance); 241 248 if (rc != DDI_SUCCESS) … … 252 259 return DDI_FAILURE; 253 260 } 261 #else 262 pState = RTMemAllocZ(sizeof(VBoxAddDevState)); 263 if (!pState) 264 { 265 VBA_LOGNOTE("RTMemAllocZ failed to allocate %d bytes\n", sizeof(VBoxAddDevState)); 266 return DDI_FAILURE; 267 } 268 #endif 254 269 255 270 /* … … 405 420 int rc; 406 421 int instance = ddi_get_instance(pDip); 422 #ifdef USE_SESSION_HASH 407 423 VBoxAddDevState *pState = ddi_get_soft_state(g_pVBoxAddSolarisState, instance); 424 #else 425 VBoxAddDevState *pState = ddi_get_driver_private(g_pDip); 426 #endif 408 427 if (pState) 409 428 { … … 412 431 ddi_regs_map_free(&pState->PciMMIOHandle); 413 432 ddi_remove_minor_node(pDip, NULL); 433 #ifdef USE_SESSION_HASH 414 434 ddi_soft_state_free(g_pVBoxAddSolarisState, instance); 435 #else 436 RTMemFree(pState); 437 #endif 415 438 416 439 rc = RTSpinlockDestroy(g_Spinlock); … … 480 503 VBA_LOGCONT("VBoxAddSolarisOpen\n"); 481 504 505 #ifndef USE_SESSION_HASH 506 VBoxAddDevState *pState = NULL; 507 unsigned iOpenInstance; 508 for (iOpenInstance = 0; iOpenInstance < 4096; iOpenInstance++) 509 { 510 if ( !ddi_get_soft_state(g_pVBoxAddSolarisState, iOpenInstance) /* faster */ 511 && ddi_soft_state_zalloc(g_pVBoxAddSolarisState, iOpenInstance) == DDI_SUCCESS) 512 { 513 pState = ddi_get_soft_state(g_pVBoxAddSolarisState, iOpenInstance); 514 break; 515 } 516 } 517 if (!pState) 518 { 519 VBA_LOGNOTE("VBoxAddSolarisOpen: too many open instances."); 520 return ENXIO; 521 } 522 523 /* 524 * Create a new session. 525 */ 526 rc = VBoxGuestCreateUserSession(&g_DevExt, &pSession); 527 if (RT_SUCCESS(rc)) 528 { 529 pState->pSession = pSession; 530 VBA_LOGCONT("VBoxAddSolarisOpen: pSession=%p pState=%p\n", pSession, pState); 531 return 0; 532 } 533 534 /* Failed, clean up. */ 535 ddi_soft_state_free(g_pVBoxAddSolarisState, iOpenInstance); 536 #else 482 537 /* 483 538 * Create a new session. … … 500 555 return 0; 501 556 } 557 #endif 502 558 LogRel(("VBoxAddSolarisOpen: VBoxGuestCreateUserSession failed. rc=%d\n", rc)); 503 559 return rc; … … 509 565 VBA_LOGCONT("VBoxAddSolarisClose pid=%d\n", (int)RTProcSelf()); 510 566 567 #ifdef USE_SESSION_HASH 511 568 /* 512 569 * Remove from the hash table. … … 551 608 return VERR_INVALID_PARAMETER; 552 609 } 610 #else 611 PVBOXGUESTSESSION pSession; 612 VBoxAddDevState *pState = ddi_get_soft_state(g_pVBoxAddSolarisState, getminor(Dev)); 613 if (!pState) 614 { 615 VBA_LOGNOTE("VBoxAddSolarisClose: failed to get pState.\n"); 616 return DDI_FAILURE; 617 } 618 619 pSession = pState->pSession; 620 pState->pSession = NULL; 621 ddi_soft_state_free(g_pVBoxAddSolarisState, getminor(Dev)); 622 if (!pSession) 623 { 624 VBA_LOGNOTE("VBoxAddSolarisClose: failed to get pSession.\n"); 625 return DDI_FAILURE; 626 } 627 #endif 553 628 554 629 /* … … 598 673 599 674 /** @todo use the faster way to find pSession (using the soft state) */ 675 #ifdef USE_SESSION_HASH 600 676 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 601 677 const RTPROCESS Process = RTProcSelf(); … … 620 696 return EINVAL; 621 697 } 698 #else 699 /* 700 * Get the session from the soft state item. 701 */ 702 VBoxAddDevState *pState = ddi_get_soft_state(g_pVBoxAddSolarisState, getminor(Dev)); 703 if (!pState) 704 { 705 VBA_LOGNOTE("VBoxAddSolarisIOCtl: no state data for %d\n", getminor(Dev)); 706 return EINVAL; 707 } 708 709 PVBOXGUESTSESSION pSession = pState->pSession; 710 if (!pSession) 711 { 712 VBA_LOGNOTE("VBoxAddSolarisIOCtl: no session data for %d\n", getminor(Dev)); 713 return DDI_SUCCESS; 714 } 715 #endif 622 716 623 717 /** @todo I'll remove this size check after testing. */ … … 691 785 #endif 692 786 693 cbBuf = IOCPARM_LEN(Cmd); 787 cbBuf = IOCPARM_LEN(Cmd); 694 788 void *pvBuf = RTMemTmpAlloc(cbBuf); 695 789 if (RT_UNLIKELY(!pvBuf)) -
trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk
r6118 r6132 39 39 $(VBOX_LIB_VBGL_R3) \ 40 40 $(VBOX_LIB_IPRT_GUEST_R3) 41 VBoxService_LIBS.solaris = daemon 41 42 42 43 include $(PATH_KBUILD)/subfooter.kmk -
trunk/src/VBox/Additions/common/VBoxService/VBoxService-solaris.cpp
r6121 r6132 26 26 #include <signal.h> 27 27 #include <fcntl.h> 28 #include <libdaemon/dfork.h> 29 #include <libdaemon/dsignal.h> 28 30 29 31 /** 30 * Solaris daemon() call . Probably might work for other Unix.32 * Solaris daemon() call uses libdaemon. 31 33 * 32 34 * @returns 0 on success … … 34 36 int daemon(int nochdir, int noclose) 35 37 { 38 pid_t pid = daemon_fork(); 39 if (pid < 0) 40 { 41 daemon_retval_done(); 42 return -1; 43 } 44 45 if (pid) 46 exit(0); 47 48 daemon_close_all(-1); 49 return 0; 50 #if 0 36 51 if (getppid() == 1) /* We already belong to init process */ 37 52 return -1; … … 52 67 int size = getdtablesize(); 53 68 if (size < 0) 54 size = 3;69 size = 2; 55 70 56 71 for (int i = size; i >= 0; i--) … … 74 89 } 75 90 return 0; 91 #endif 76 92 } 77 93
Note:
See TracChangeset
for help on using the changeset viewer.