Unload kext that still has instances

I am updating the driver of one of my devices and want the kextunload old driver and the kextload new, so a reboot is no longer required.

After installation, I try:

sudo kextunload /System/Library/Extensions/Driver.kext 

The error that occurs looks like this:

(kernel) Unable to unload kext com.driver.Driver; classes have instances: (core) Kext com.driver.Driver class com_driver_Driver_USBAudioDevice has 1 instance. Failed to unload com.driver.Driver - (libkern / kext) kext is used or saved (cannot be unloaded).

The device is missing in ioreg. How can I find out that this instance prevents me from unloading the driver?

+4
source share
1 answer

If you call the kextstat command, it displays a list of all loaded kernel extensions with information like this: -

115 3 0xffffff7f814f4000 0x32000 0x32000 com.apple.iokit.IOAudioFamily (1.8.9fc11) <114 5 4 3 1>

The first number (115) is the kernel extension identifier.

At the end, the set of numbers <114 5 4 3 1> are the other kernel extension identifiers that this particular kext refers to.

If you match the identifier of your kext with any of those listed in another, then this is the link that kextunload refers to.

Also note that when writing any code in the kernel, the globals variables are global throughout the kernel, so if you declared that it might not be a unique name and is used by another kext, I found that it raises a similar question. The solution here is to add any global variables with the reverse company URI (e.g. com_apple_globalVarName).

+6
source

Source: https://habr.com/ru/post/1488504/


All Articles