VirtualBox

Changeset 75666 in vbox


Ignore:
Timestamp:
Nov 22, 2018 2:13:32 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126860
Message:

darwin/VBoxSF: updates

Location:
trunk/src/VBox/Additions/darwin/VBoxSF
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/darwin/VBoxSF/Info.plist

    r57063 r75666  
    44<dict>
    55    <key>CFBundleDevelopmentRegion</key>           <string>English</string>
    6     <key>CFBundleExecutable</key>                  <string>VBoxVFS</string>
     6    <key>CFBundleExecutable</key>                  <string>VBoxSF</string>
    77    <key>CFBundleIconFile</key>                    <string></string>
    8     <key>CFBundleIdentifier</key>                  <string>org.virtualbox.kext.VBoxVFS</string>
     8    <key>CFBundleIdentifier</key>                  <string>org.virtualbox.kext.VBoxSF</string>
    99    <key>CFBundleInfoDictionaryVersion</key>       <string>6.0</string>
    10     <key>CFBundleName</key>                        <string>VBoxVFS</string>
     10    <key>CFBundleName</key>                        <string>VBoxSF</string>
    1111    <key>CFBundlePackageType</key>                 <string>KEXT</string>
    1212    <key>CFBundleGetInfoString</key>               <string>@VBOX_PRODUCT@ @VBOX_VERSION_STRING@, © 2007-@VBOX_C_YEAR@ @VBOX_VENDOR@</string>
     
    1717
    1818    <dict>
    19         <key>VBoxVFS</key>
     19        <key>VBoxSF</key>
    2020        <dict>
    21             <key>IOMatchCategory</key>             <string>org_virtualbox_VBoxVFS</string>
    22             <key>IOClientClass</key>               <string>VBoxVFSClient</string>
    23             <key>IOClass</key>                     <string>org_virtualbox_VBoxVFS</string>
    24             <key>CFBundleIdentifier</key>          <string>org.virtualbox.kext.VBoxVFS</string>
     21            <key>IOMatchCategory</key>             <string>org_virtualbox_VBoxSF</string>
     22            <key>IOClientClass</key>               <string>VBoxSFClient</string>
     23            <key>IOClass</key>                     <string>org_virtualbox_VBoxSF</string>
     24            <key>CFBundleIdentifier</key>          <string>org.virtualbox.kext.VBoxSF</string>
    2525            <key>IOKitDebug</key>                  <integer>65535</integer>
    2626            <key>IOProviderClass</key>             <string>IOPCIDevice</string>
     
    2929    </dict>
    3030
    31     <key>NSHumanReadableCopyright</key>            <string>Copyright © 2013 Oracle Inc. All rights reserved.</string>
     31    <key>NSHumanReadableCopyright</key>            <string>Copyright © 2007-@VBOX_C_YEAR@ Oracle Inc. All rights reserved.</string>
    3232
    3333    <key>OSBundleLibraries</key>
  • trunk/src/VBox/Additions/darwin/VBoxSF/Makefile.kmk

    r75293 r75666  
    4646                $(PATH_SUB_CURRENT)/Info.plist \
    4747                $(VBOX_VERSION_MK) | $$(dir $$@)
    48          $(call MSG_GENERATE,VBoxSF,$@,$<)
    49          $(QUIET)$(RM) -f $@
    50          $(QUIET)$(SED) \
    51                  -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
    52                  -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
    53                  -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
    54                  -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
    55                  -e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
    56                  -e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
    57                  -e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
    58                  --output $@ \
    59                  $<
     48        $(call MSG_GENERATE,VBoxSF,$@,$<)
     49        $(QUIET)$(RM) -f $@
     50        $(QUIET)$(SED) \
     51                -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
     52                -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
     53                -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
     54                -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
     55                -e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
     56                -e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
     57                -e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
     58                --output $@ \
     59                $<
    6060
    6161#
  • trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-Utils.cpp

    r75293 r75666  
    7777            vnode_params.vnfs_dvp        = pParent;
    7878            vnode_params.vnfs_fsnode     = pVnodeData;  /** Private data attached per xnu's vnode object */
    79             vnode_params.vnfs_vops       = g_VBoxVFSVnodeDirOpsVector;
     79            vnode_params.vnfs_vops       = g_papfnVBoxVFSVnodeDirOpsVector;
    8080
    8181            vnode_params.vnfs_markroot   = fIsRoot;
     
    387387    parms.CreateFlags   = fFlags;
    388388
    389     rc = VbglR0SfCreate(&g_vboxSFClient, &pMount->pMap, pPath, &parms);
     389    rc = VbglR0SfCreate(&g_SfClient, &pMount->pMap, pPath, &parms);
    390390    if (RT_SUCCESS(rc))
    391391    {
     
    412412{
    413413    AssertReturn(pMount, EINVAL);
    414     return VbglR0SfClose(&g_vboxSFClient, &pMount->pMap, pHandle);
     414    return VbglR0SfClose(&g_SfClient, &pMount->pMap, pHandle);
    415415}
    416416
     
    442442    parms.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
    443443
    444     rc = VbglR0SfCreate(&g_vboxSFClient, &pMount->pMap, pSHFLDPath, &parms);
     444    rc = VbglR0SfCreate(&g_SfClient, &pMount->pMap, pSHFLDPath, &parms);
    445445    if (rc == 0)
    446446        *Info = parms.Info;
  • trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VNodeOps.cpp

    r75293 r75666  
    2828
    2929
    30 #define VNODEOPFUNC int(*)(void *)
    31 
    32 
    33 static int vboxvfs_dfl_error()
     30int vboxvfs_dfl_error(void)
    3431{
    3532    PDEBUG("vboxvfs_dfl_error is called");
     
    3835}
    3936
    40 static int
    41 vboxvfs_vnode_getattr(struct vnop_getattr_args *args)
     37int vboxvfs_vnode_getattr(struct vnop_getattr_args *args)
    4238{
    4339    vboxvfs_mount_t   *pMount;
     
    252248}
    253249
    254 static int
    255 vboxvfs_vnode_lookup(struct vnop_lookup_args *args)
     250int vboxvfs_vnode_lookup(struct vnop_lookup_args *args)
    256251{
    257252    int rc;
     
    340335}
    341336
    342 static int
    343 vboxvfs_vnode_open(struct vnop_open_args *args)
     337int vboxvfs_vnode_open(struct vnop_open_args *args)
    344338{
    345339    vnode_t           vnode;
     
    405399}
    406400
    407 static int
    408 vboxvfs_vnode_close(struct vnop_close_args *args)
     401int vboxvfs_vnode_close(struct vnop_close_args *args)
    409402{
    410403    vnode_t          vnode;
     
    509502}
    510503
    511 static int
    512 vboxvfs_vnode_readdir(struct vnop_readdir_args *args)
     504int vboxvfs_vnode_readdir(struct vnop_readdir_args *args)
    513505{
    514506    vboxvfs_mount_t *pMount;
     
    580572            uint32_t cbReturned = cbInfo;
    581573            //rc = VbglR0SfDirInfo(&g_vboxSFClient, &pMount->pMap, Handle, pMask, SHFL_LIST_RETURN_ONE, 0, &cbReturned, (PSHFLDIRINFO)Info, &cFiles);
    582             rc = VbglR0SfDirInfo(&g_vboxSFClient, &pMount->pMap, Handle, 0, SHFL_LIST_RETURN_ONE, 0,
     574            rc = VbglR0SfDirInfo(&g_SfClient, &pMount->pMap, Handle, 0, SHFL_LIST_RETURN_ONE, 0,
    583575                                 &cbReturned, (PSHFLDIRINFO)Info, &cFiles);
    584576
     
    631623}
    632624
    633 static int
    634 vboxvfs_vnode_access(struct vnop_access_args *args)
     625
     626int vboxvfs_vnode_access(struct vnop_access_args *args)
    635627{
    636628    PDEBUG("here");
     
    639631
    640632
    641 static int
    642 vboxvfs_vnode_readdirattr(struct vnop_readdirattr_args *args)
     633int vboxvfs_vnode_readdirattr(struct vnop_readdirattr_args *args)
    643634{
    644635    PDEBUG("here");
     
    646637}
    647638
    648 static int
    649 vboxvfs_vnode_pathconf(struct vnop_pathconf_args *args)
     639int vboxvfs_vnode_pathconf(struct vnop_pathconf_args *args)
    650640{
    651641    PDEBUG("here");
     
    662652 * @return 0 on success, BSD error code otherwise.
    663653 */
    664 static int
    665 vboxvfs_vnode_reclaim(struct vnop_reclaim_args *pArgs)
     654int vboxvfs_vnode_reclaim(struct vnop_reclaim_args *pArgs)
    666655{
    667656    PDEBUG("Releasing vnode resources...");
     
    701690}
    702691
    703 /* Directory vnode operations */
    704 static struct vnodeopv_entry_desc oVBoxVFSDirOpsDescList[] = {
     692
     693/**
     694 * Vnode operations.
     695 */
     696static struct vnodeopv_entry_desc g_VBoxSfDirOpsDescList[] =
     697{
     698#define VNODEOPFUNC int(*)(void *)
    705699    { &vnop_default_desc,     (VNODEOPFUNC)vboxvfs_dfl_error },
    706700    { &vnop_lookup_desc,      (VNODEOPFUNC)vboxvfs_vnode_lookup },
     
    748742    { &vnop_bwrite_desc,      (VNODEOPFUNC)vboxvfs_dfl_error },
    749743    { NULL,                   (VNODEOPFUNC)NULL              },
     744#undef VNODEOPFUNC
    750745};
    751746
    752 int (**g_VBoxVFSVnodeDirOpsVector)(void *);
    753 
    754 static struct vnodeopv_desc oVBoxVFSVnodeDirOps = {
    755     &g_VBoxVFSVnodeDirOpsVector,
    756     oVBoxVFSDirOpsDescList
     747/** ??? */
     748int (**g_papfnVBoxVFSVnodeDirOpsVector)(void *);
     749
     750/**
     751 * VNode operation descriptors.
     752 */
     753struct vnodeopv_desc g_VBoxSfVnodeOpvDesc =
     754{
     755    &g_papfnVBoxVFSVnodeDirOpsVector,
     756    g_VBoxSfDirOpsDescList
    757757};
    758758
    759 struct vnodeopv_desc *g_VBoxVFSVnodeOpvDescList[] = {
    760     &oVBoxVFSVnodeDirOps,
    761 };
    762 
    763 int g_cVBoxVFSVnodeOpvDescListSize =
    764     sizeof(**g_VBoxVFSVnodeOpvDescList) / sizeof(struct vnodeopv_desc);
  • trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VfsOps.cpp

    r75293 r75666  
    275275    if (pMount)
    276276    {
    277         rc = VbglR0SfMapFolder(&g_vboxSFClient, pMount->pShareName, &pMount->pMap);
     277        rc = VbglR0SfMapFolder(&g_SfClient, pMount->pShareName, &pMount->pMap);
    278278        if (RT_SUCCESS(rc))
    279279        {
     
    342342                vfs_setfsprivate(mp, NULL);
    343343
    344                 rc = VbglR0SfUnmapFolder(&g_vboxSFClient, &pMount->pMap);
     344                rc = VbglR0SfUnmapFolder(&g_SfClient, &pMount->pMap);
    345345                if (RT_SUCCESS(rc))
    346346                {
     
    504504    AssertReturn(pMount->pShareName, EINVAL);
    505505
    506     rc = VbglR0SfFsInfo(&g_vboxSFClient, &pMount->pMap, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME,
     506    rc = VbglR0SfFsInfo(&g_SfClient, &pMount->pMap, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME,
    507507                        &cbBuffer, (PSHFLDIRINFO)&SHFLVolumeInfo);
    508508    AssertReturn(rc == 0, EPROTO);
     
    553553}
    554554
    555 /* VFS options */
    556 struct vfsops g_oVBoxVFSOpts = {
     555/**
     556 * VFS operations
     557 */
     558struct vfsops g_VBoxSfVfsOps =
     559{
    557560    /* Standard operations */
    558561    &vboxvfs_mount,
  • trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF.cpp

    r75293 r75666  
    3333*********************************************************************************************************************************/
    3434/**
    35  * The service class for dealing with Share Folder filesystem.
    36  */
    37 class org_virtualbox_VBoxVFS : public IOService
    38 {
    39     OSDeclareDefaultStructors(org_virtualbox_VBoxVFS);
     35 * The service class for this driver.
     36 *
     37 * This has one purpose: Use waitForMatchingService() to find VBoxGuest.
     38 */
     39class org_virtualbox_VBoxSF : public IOService
     40{
     41    OSDeclareDefaultStructors(org_virtualbox_VBoxSF);
    4042
    4143private:
    42     IOService * waitForCoreService(void);
    43 
    44     IOService * coreService;
     44    IOService *waitForCoreService(void);
     45
     46    IOService *m_pCoreService;
    4547
    4648public:
     
    4951};
    5052
    51 OSDefineMetaClassAndStructors(org_virtualbox_VBoxVFS, IOService);
     53OSDefineMetaClassAndStructors(org_virtualbox_VBoxSF, IOService);
    5254
    5355
     
    5557*   Global Variables                                                                                                             *
    5658*********************************************************************************************************************************/
    57 
    5859/**
    5960 * Declare the module stuff.
    6061 */
    6162RT_C_DECLS_BEGIN
    62 static kern_return_t VBoxVFSModuleLoad(struct kmod_info *pKModInfo, void *pvData);
    63 static kern_return_t VBoxVFSModuleUnLoad(struct kmod_info *pKModInfo, void *pvData);
     63static kern_return_t VBoxSfModuleLoad(struct kmod_info *pKModInfo, void *pvData);
     64static kern_return_t VBoxSfModuleUnload(struct kmod_info *pKModInfo, void *pvData);
    6465extern kern_return_t _start(struct kmod_info *pKModInfo, void *pvData);
    6566extern kern_return_t _stop(struct kmod_info *pKModInfo, void *pvData);
    6667KMOD_EXPLICIT_DECL(VBoxVFS, VBOX_VERSION_STRING, _start, _stop)
    67 DECLHIDDEN(kmod_start_func_t *) _realmain      = VBoxVFSModuleLoad;
    68 DECLHIDDEN(kmod_stop_func_t *)  _antimain      = VBoxVFSModuleUnLoad;
     68DECLHIDDEN(kmod_start_func_t *) _realmain      = VBoxSfModuleLoad;
     69DECLHIDDEN(kmod_stop_func_t *)  _antimain      = VBoxSfModuleUnload;
    6970DECLHIDDEN(int)                 _kext_apple_cc = __APPLE_CC__;
    7071RT_C_DECLS_END
    7172
    72 /** The number of IOService class instances. */
    73 static bool volatile        g_fInstantiated = 0;
    74 /* Global connection to the host service */
    75 VBGLSFCLIENT                  g_vboxSFClient;
     73/** The org_virtualbox_VBoxSF instance.
     74 * Used for preventing multiple instantiations. */
     75static org_virtualbox_VBoxSF   *g_pService = NULL;
     76
     77/** The shared folder service client structure. */
     78VBGLSFCLIENT                    g_SfClient;
    7679/* VBoxVFS filesystem handle. Needed for FS unregistering. */
    77 static vfstable_t           g_oVBoxVFSHandle;
     80static vfstable_t               g_pVBoxSfVfsTableEntry;
     81
     82/** For vfs_fsentry. */
     83static struct vnodeopv_desc    *g_apVBoxSfVnodeOpDescList[] =
     84{
     85    &g_VBoxSfVnodeOpvDesc,
     86};
     87
     88
     89/** VFS registration structure. */
     90static struct vfs_fsentry g_VBoxSfFsEntry =
     91{
     92    .vfe_vfsops     = &g_VBoxSfVfsOps,
     93    .vfe_vopcnt     = RT_ELEMENTS(g_apVBoxSfVnodeOpDescList),
     94    .vfe_opvdescs   = g_apVBoxSfVnodeOpDescList,
     95    .vfe_fstypenum  = -1,
     96    .vfe_fsname     = VBOXSF_DARWIN_FS_NAME,
     97    .vfe_flags      = VFS_TBLTHREADSAFE     /* Required. */
     98                    | VFS_TBLFSNODELOCK     /* Required. */
     99                    | VFS_TBLNOTYPENUM      /* No historic file system number. */
     100                    | VFS_TBL64BITREADY,    /* Can handle 64-bit processes */
     101    /** @todo add VFS_TBLREADDIR_EXTENDED */
     102    .vfe_reserv     = { NULL, NULL },
     103};
    78104
    79105
     
    81107 * KEXT Module BSD entry point
    82108 */
    83 static kern_return_t VBoxVFSModuleLoad(struct kmod_info *pKModInfo, void *pvData)
    84 {
    85     int rc;
    86 
     109static kern_return_t VBoxSfModuleLoad(struct kmod_info *pKModInfo, void *pvData)
     110{
    87111    /* Initialize the R0 guest library. */
    88112#if 0
     
    102126 * KEXT Module BSD exit point
    103127 */
    104 static kern_return_t VBoxVFSModuleUnLoad(struct kmod_info *pKModInfo, void *pvData)
    105 {
    106     int rc;
    107 
     128static kern_return_t VBoxSfModuleUnload(struct kmod_info *pKModInfo, void *pvData)
     129{
    108130#if 0
    109131   VbglR0SfTerm();
     
    115137}
    116138
    117 
    118 /**
    119  * Register VBoxFS filesystem.
    120  *
    121  * @returns IPRT status code.
    122  */
    123 int VBoxVFSRegisterFilesystem(void)
    124 {
    125     struct vfs_fsentry oVFsEntry;
    126     int rc;
    127 
    128     memset(&oVFsEntry, 0, sizeof(oVFsEntry));
    129     /* Attach filesystem operations set */
    130     oVFsEntry.vfe_vfsops = &g_oVBoxVFSOpts;
    131     /* Attach vnode operations */
    132     oVFsEntry.vfe_vopcnt = g_cVBoxVFSVnodeOpvDescListSize;
    133     oVFsEntry.vfe_opvdescs = g_VBoxVFSVnodeOpvDescList;
    134     /* Set flags */
    135     oVFsEntry.vfe_flags =
    136 #if ARCH_BITS == 64
    137             VFS_TBL64BITREADY |
    138 #endif
    139             VFS_TBLTHREADSAFE |
    140             VFS_TBLFSNODELOCK |
    141             VFS_TBLNOTYPENUM;
    142 
    143     memcpy(oVFsEntry.vfe_fsname, VBOXSF_DARWIN_FS_NAME, MFSNAMELEN);
    144 
    145     rc = vfs_fsadd(&oVFsEntry, &g_oVBoxVFSHandle);
    146     if (rc)
    147     {
    148         PINFO("Unable to register VBoxVFS filesystem (%d)", rc);
    149         return VERR_GENERAL_FAILURE;
    150     }
    151 
    152     PINFO("VBoxVFS filesystem successfully registered");
    153     return VINF_SUCCESS;
    154 }
    155 
    156 /**
    157  * Unregister VBoxFS filesystem.
    158  *
    159  * @returns IPRT status code.
    160  */
    161 int VBoxVFSUnRegisterFilesystem(void)
    162 {
    163     int rc;
    164 
    165     if (g_oVBoxVFSHandle == 0)
    166         return VERR_INVALID_PARAMETER;
    167 
    168     rc = vfs_fsremove(g_oVBoxVFSHandle);
    169     if (rc)
    170     {
    171         PINFO("Unable to unregister VBoxVFS filesystem (%d)", rc);
    172         return VERR_GENERAL_FAILURE;
    173     }
    174 
    175     g_oVBoxVFSHandle = 0;
    176 
    177     PINFO("VBoxVFS filesystem successfully unregistered");
    178     return VINF_SUCCESS;
     139/**
     140 * Wait for VBoxGuest.kext to be started
     141 */
     142IOService *org_virtualbox_VBoxSF::waitForCoreService(void)
     143{
     144    OSDictionary *pServiceToMatach = serviceMatching("org_virtualbox_VBoxGuest");
     145    if (pServiceToMatach)
     146    {
     147        /* Wait 15 seconds for VBoxGuest to be started */
     148        IOService *pService = waitForMatchingService(pServiceToMatach, 15 * RT_NS_1SEC_64);
     149        pServiceToMatach->release();
     150        return pService;
     151    }
     152    PINFO("unable to create matching dictionary");
     153    return NULL;
    179154}
    180155
     
    183158 * Start this service.
    184159 */
    185 bool org_virtualbox_VBoxVFS::start(IOService *pProvider)
    186 {
    187     int rc;
    188 
    189     if (!IOService::start(pProvider))
     160bool org_virtualbox_VBoxSF::start(IOService *pProvider)
     161{
     162    if (g_pService == NULL)
     163        g_pService = this;
     164    else
     165    {
     166        printf("org_virtualbox_VBoxSF::start: g_pService=%p this=%p -> false\n", g_pService, this);
    190167        return false;
    191 
    192     /* Low level initialization should be performed only once */
    193     if (!ASMAtomicCmpXchgBool(&g_fInstantiated, true, false))
    194     {
    195         IOService::stop(pProvider);
    196         return false;
    197     }
    198 
    199     /* Wait for VBoxGuest to be started */
    200     coreService = waitForCoreService();
    201     if (coreService)
    202     {
    203         rc = VbglR0SfInit();
    204         if (RT_SUCCESS(rc))
     168    }
     169
     170    if (IOService::start(pProvider))
     171    {
     172        /*
     173         * Get hold of VBoxGuest.
     174         */
     175        m_pCoreService = waitForCoreService();
     176        if (m_pCoreService)
    205177        {
    206             /* Connect to the host service. */
    207             rc = VbglR0SfConnect(&g_vboxSFClient);
     178            int rc = VbglR0SfInit();
    208179            if (RT_SUCCESS(rc))
    209180            {
    210                 PINFO("VBox client connected");
    211                 rc = VbglR0SfSetUtf8(&g_vboxSFClient);
     181                /*
     182                 * Connect to the host service and set UTF-8 as the string encoding to use.
     183                 */
     184                rc = VbglR0SfConnect(&g_SfClient);
    212185                if (RT_SUCCESS(rc))
    213186                {
    214                     rc = VBoxVFSRegisterFilesystem();
     187                    rc = VbglR0SfSetUtf8(&g_SfClient);
    215188                    if (RT_SUCCESS(rc))
    216189                    {
    217                         registerService();
    218                         PINFO("Successfully started I/O kit class instance");
    219                         return true;
     190                        /*
     191                         * Register the file system.
     192                         */
     193                        rc = vfs_fsadd(&g_VBoxSfFsEntry, &g_pVBoxSfVfsTableEntry);
     194                        if (rc == 0)
     195                        {
     196                            registerService();
     197
     198                            LogRel(("VBoxSF: ready\n"));
     199                            return true;
     200                        }
     201
     202                        LogRel(("VBoxSF: vfs_fsadd failed: %d\n", rc));
    220203                    }
    221                     PERROR("Unable to register VBoxVFS filesystem");
     204                    else
     205                        LogRel(("VBoxSF: VbglR0SfSetUtf8 failed: %Rrc\n", rc));
     206                    VbglR0SfDisconnect(&g_SfClient);
    222207                }
    223208                else
    224                 {
    225                     PERROR("VbglR0SfSetUtf8 failed: rc=%d", rc);
    226                 }
    227                 VbglR0SfDisconnect(&g_vboxSFClient);
     209                    LogRel(("VBoxSF: VbglR0SfConnect failed: %Rrc\n", rc));
     210                VbglR0SfTerm();
     211            }
     212            else
     213                LogRel(("VBoxSF: VbglR0SfInit failed: %Rrc\n", rc));
     214            m_pCoreService->release();
     215        }
     216        else
     217            LogRel(("VBoxSF: Failed to find VBoxGuest!\n"));
     218
     219        IOService::stop(pProvider);
     220    }
     221    g_pService = NULL;
     222    return false;
     223}
     224
     225
     226/**
     227 * Stop this service.
     228 */
     229void org_virtualbox_VBoxSF::stop(IOService *pProvider)
     230{
     231    if (m_pCoreService == this)
     232    {
     233        /*
     234         * Unregister the filesystem.
     235         */
     236        if (g_pVBoxSfVfsTableEntry != NULL)
     237        {
     238            int rc = vfs_fsremove(g_pVBoxSfVfsTableEntry);
     239            if (rc == 0)
     240            {
     241                g_pVBoxSfVfsTableEntry = NULL;
     242                PINFO("VBoxVFS filesystem successfully unregistered");
    228243            }
    229244            else
    230245            {
    231                 PERROR("Failed to get connection to host: rc=%d", rc);
     246                PINFO("Unable to unregister the VBoxSF filesystem (%d)", rc);
     247                /** @todo how on earth do we deal with this...  Gues we shouldn't be using
     248                 *        IOService at all here. sigh.  */
    232249            }
    233             VbglR0SfTerm();
    234250        }
    235         else
    236         {
    237             PERROR("Failed to initialize low level library");
    238         }
    239         coreService->release();
    240     }
    241     else
    242     {
    243         PERROR("VBoxGuest KEXT not started");
    244     }
    245 
    246     ASMAtomicXchgBool(&g_fInstantiated, false);
     251        VbglR0SfDisconnect(&g_SfClient);
     252        VbglR0SfTerm();
     253        if (m_pCoreService)
     254            m_pCoreService->release();
     255
     256    }
    247257    IOService::stop(pProvider);
    248 
    249     return false;
    250 }
    251 
    252 
    253 /**
    254  * Stop this service.
    255  */
    256 void org_virtualbox_VBoxVFS::stop(IOService *pProvider)
    257 {
    258     int rc;
    259 
    260     AssertReturnVoid(ASMAtomicReadBool(&g_fInstantiated));
    261 
    262     rc = VBoxVFSUnRegisterFilesystem();
    263     if (RT_FAILURE(rc))
    264     {
    265         PERROR("VBoxVFS filesystem is busy. Make sure all "
    266                "shares are unmounted (%d)", rc);
    267     }
    268 
    269     VbglR0SfDisconnect(&g_vboxSFClient);
    270     PINFO("VBox client disconnected");
    271 
    272     VbglR0SfTerm();
    273     PINFO("Low level uninit done");
    274 
    275     coreService->release();
    276     PINFO("VBoxGuest service released");
    277 
    278     IOService::stop(pProvider);
    279 
    280     ASMAtomicWriteBool(&g_fInstantiated, false);
    281 
    282     PINFO("Successfully stopped I/O kit class instance");
    283 }
    284 
    285 
    286 /**
    287  * Wait for VBoxGuest.kext to be started
    288  */
    289 IOService * org_virtualbox_VBoxVFS::waitForCoreService(void)
    290 {
    291     IOService *service;
    292 
    293     OSDictionary *serviceToMatch = serviceMatching("org_virtualbox_VBoxGuest");
    294     if (!serviceToMatch)
    295     {
    296         PINFO("unable to create matching dictionary");
    297         return NULL;
    298     }
    299 
    300     /* Wait 10 seconds for VBoxGuest to be started */
    301     service = waitForMatchingService(serviceToMatch, 10ULL * 1000000000ULL);
    302     serviceToMatch->release();
    303 
    304     return service;
    305 }
     258}
     259
  • trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFInternal.h

    r75293 r75666  
    8282*   Global Variables                                                                                                             *
    8383*********************************************************************************************************************************/
    84 /** Global refernce to host service connection */
    85 extern VBGLSFCLIENT g_vboxSFClient;
    86 
    87 /* VFS options */
    88 extern struct vfsops g_oVBoxVFSOpts;
    89 
    90 extern int (**g_VBoxVFSVnodeDirOpsVector)(void *);
    91 extern int g_cVBoxVFSVnodeOpvDescListSize;
    92 extern struct vnodeopv_desc *g_VBoxVFSVnodeOpvDescList[];
     84extern VBGLSFCLIENT         g_SfClient;
     85extern struct vfsops        g_VBoxSfVfsOps;
     86extern struct vnodeopv_desc g_VBoxSfVnodeOpvDesc;
     87extern int (**g_papfnVBoxVFSVnodeDirOpsVector)(void *);
    9388
    9489
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