Search code examples
macoslaunchdkernel-extensionxnu

Invalidate kextcache after removing driver launchd plist file


I've created uninstaller for my driver, that remove its matching plist file from /Library/LaunchDaemons so that it won't be loaded again by launchd on the next boot cycle. However, it doesn't seems to take any effect on my driver that is still being loaded normally after booting the machine.

After doing some research in this matter, I've found out that the kextcache is the reason for this behaviour, and in order clean/invalidate it, I need to touch the folder where the installation target volume. however, it haven't had any effect.

My question is how to properly invalidate the kext cache so that launchd won't load the kext after it's corresponding plist file was removed.

Thanks to the answer below, I invalidated kext cache. However, I'd like to have the equivalent for access existing folder in objective-c which my uninstaller helper is based on.

To be precise, here's the code I'd like to convert to objective-C:

sudo touch /System/Library/Extensions; sudo touch /Library/Extensions


Solution

  • The proper way to invalidate the kext caches is

    sudo touch /System/Library/Extensions
    

    or in OS versions that support loading extensions from /Library:

    sudo touch /Library/Extensions
    

    As soon as you do this, the kext caches are automatically regenerated.