VirtualBox

Changeset 51163 in vbox


Ignore:
Timestamp:
Apr 29, 2014 12:47:21 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
93512
Message:

Mac OS X host: Host USB: improve checking if storage device is currently mounted.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/darwin/iokit.cpp

    r51159 r51163  
    3939# include <IOKit/usb/IOUSBLib.h>
    4040# include <IOKit/IOCFPlugIn.h>
     41# include <IOKit/storage/IOMedia.h>
    4142#endif
    4243
     
    737738static bool darwinIsMassStorageInterfaceInUse(io_object_t MSDObj, io_name_t pszNameBuf)
    738739{
    739     io_object_t MediaObj = darwinFindObjectByClass(MSDObj, "IOMedia", pszNameBuf);
     740    io_object_t MediaObj = darwinFindObjectByClass(MSDObj, kIOMediaClass, pszNameBuf);
    740741    if (MediaObj)
    741742    {
     743        CFMutableDictionaryRef pProperties;
     744        kern_return_t krc;
     745        bool fInUse = true;
     746
     747        krc = IORegistryEntryCreateCFProperties(MediaObj, &pProperties, kCFAllocatorDefault, kNilOptions);
     748        if (krc == KERN_SUCCESS)
     749        {
     750            CFBooleanRef pBoolValue = (CFBooleanRef)CFDictionaryGetValue(pProperties, CFSTR(kIOMediaOpenKey));
     751            if (pBoolValue)
     752                fInUse = CFBooleanGetValue(pBoolValue);
     753
     754            CFRelease(pProperties);
     755        }
     756
    742757        /* more checks? */
    743758        IOObjectRelease(MediaObj);
    744         return true;
    745     }
     759        return fInUse;
     760    }
     761
    746762    return false;
    747763}
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