VirtualBox

Changeset 38827 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Sep 22, 2011 3:42:33 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74122
Message:

Additions/solaris: Fix panic while mounting shared folders when no previous userland connections to VBoxGuest is alive.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c

    r36408 r38827  
    2929#include <sys/sunddi.h>
    3030#include <sys/open.h>
     31#include <sys/sunldi.h>
     32#include <sys/file.h>
    3133#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
    3234
     
    173175/** The IRQ Mutex */
    174176static kmutex_t             g_IrqMtx;
     177/** Layered device handle for kernel keep-attached opens */
     178static ldi_handle_t         g_LdiHandle = NULL;
     179/** Ref counting for IDCOpen calls */
     180static uint64_t             g_cLdiOpens = 0;
     181/** The Mutex protecting the LDI handle in IDC opens */
     182static kmutex_t             g_LdiMtx;
    175183
    176184/**
     
    195203            cmn_err(CE_NOTE, "failed to initialize driver logging rc=%d!\n", rc);
    196204
     205        mutex_init(&g_LdiMtx, NULL, MUTEX_DRIVER, NULL);
     206
    197207        /*
    198208         * Prevent module autounloading.
     
    231241    RTLogDestroy(RTLogRelSetDefaultInstance(NULL));
    232242    RTLogDestroy(RTLogSetDefaultInstance(NULL));
     243
     244    mutex_destroy(&g_LdiMtx);
    233245
    234246    RTR0Term();
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestIDC-unix.c.h

    r33595 r38827  
    4040
    4141    AssertPtrReturn(pu32Version, NULL);
     42
     43#ifdef RT_OS_SOLARIS
     44    mutex_enter(&g_LdiMtx);
     45    if (!g_LdiHandle)
     46    {
     47        ldi_ident_t DevIdent = ldi_ident_from_anon();
     48        rc = ldi_open_by_name(VBOXGUEST_DEVICE_NAME, FREAD, kcred, &g_LdiHandle, DevIdent);
     49        ldi_ident_release(DevIdent);
     50        if (rc)
     51        {
     52            LogRel(("VBoxGuestIDCOpen: ldi_open_by_name failed. rc=%d\n", rc));
     53            mutex_exit(&g_LdiMtx);
     54            return NULL;
     55        }
     56    }
     57    ++g_cLdiOpens;
     58    mutex_exit(&g_LdiMtx);
     59#endif
     60
    4261    rc = VBoxGuestCreateKernelSession(&g_DevExt, &pSession);
    4362    if (RT_SUCCESS(rc))
     
    4665        return pSession;
    4766    }
     67
     68#ifdef RT_OS_SOLARIS
     69    mutex_enter(&g_LdiMtx);
     70    if (g_cLdiOpens > 0)
     71        --g_cLdiOpens;
     72    if (   g_cLdiOpens == 0
     73        && g_LdiHandle)
     74    {
     75        ldi_close(g_LdiHandle, FREAD, kcred);
     76        g_LdiHandle = NULL;
     77    }
     78    mutex_exit(&g_LdiMtx);
     79#endif
     80
    4881    LogRel(("VBoxGuestIDCOpen: VBoxGuestCreateKernelSession failed. rc=%d\n", rc));
    4982    return NULL;
     
    6497    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
    6598    VBoxGuestCloseSession(&g_DevExt, pSession);
     99
     100#ifdef RT_OS_SOLARIS
     101    mutex_enter(&g_LdiMtx);
     102    if (g_cLdiOpens > 0)
     103        --g_cLdiOpens;
     104    if (   g_cLdiOpens == 0
     105        && g_LdiHandle)
     106    {
     107        ldi_close(g_LdiHandle, FREAD, kcred);
     108        g_LdiHandle = NULL;
     109    }
     110    mutex_exit(&g_LdiMtx);
     111#endif
     112
    66113    return VINF_SUCCESS;
    67114}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette