10

USBデバイス用のIOKitドライバーをインストールするOS Xのインストーラーに取り組んでおり、最後に再起動する必要がないようにしようとしています。インストーラーはドライバーを正しくインストールし、kext キャッシュを再構築します。実行後、USB デバイスを取り外して再接続すると、新しいドライバーが正しく読み込まれ、すべて正常に動作します。

ただし、新しいドライバーをロードするために、ユーザーがデバイスを物理的に取り外す必要はありません。OS Xに新しいドライバーをプログラムでロードさせる方法が必要です-実際には、デバイスのプラグを抜いて再度差し込む、または同様のことをシミュレートします。どうすればこれを行うことができますか?これまでのところ、何時間もグーグルで検索しても何も見つかりませんでした。

4

2 に答える 2

3

IOUSBDeviceInterface187::USBDeviceReEnumerate() は、あなたが望むことを行います。唯一の問題は、関心のあるすべてのデバイスを見つけて、手動でこれを呼び出すことIOServiceGetMatchingServices()です。

/*!
@function USBDeviceReEnumerate
@abstract   Tells the IOUSBFamily to reenumerate the device.
@discussion This function will send a terminate message to all clients of the IOUSBDevice (such as 
            IOUSBInterfaces and their drivers, as well as the current User Client), emulating an unplug 
            of the device. The IOUSBFamily will then enumerate the device as if it had just 
            been plugged in. This call should be used by clients wishing to take advantage 
            of the Device Firmware Update Class specification.  The device must be open to use this function. 
@availability This function is only available with IOUSBDeviceInterface187 and above.
@param      self Pointer to the IOUSBDeviceInterface.
@param      options A UInt32 reserved for future use. Ignored in current implementation. Set to zero.
@result     Returns kIOReturnSuccess if successful, kIOReturnNoDevice if there is no connection to an IOService,
            or kIOReturnNotOpen if the device is not open for exclusive access.
*/

IOReturn (*USBDeviceReEnumerate)(void *self, UInt32 options);

IOKit/usb/IOUSBLib.h を見てください

于 2015-10-13T17:16:15.437 に答える
0

diskutil、特にmountunmountオプションを見てください。これらは、ソフトウェアでデバイスを取り出してマウントします。diskutil list現在マウントされているすべてのデバイスのリストを取得するために使用できます。diskutil に関する詳細情報が必要な場合は、man ページを参照してください。

于 2012-10-08T18:56:38.490 に答える