I’m not sure of the API for loading kexts (I’d imagine
there is one, somewhere), but I’ve always just used fork/exec.
Something along the lines of:
int
load_kext(const char *path_to_kext) {
pid_t pid;
int status;
if((pid = fork()) == 0) {
status =
execl("/sbin/kextload", "/sbin/kextload", path_to_kext, 0);
exit(status);
}
if(waitpid(pid, &status, 0) == pid
&& WIFEXITED(status)) {
return
WEXITSTATUS(status);
}
return -1;
}
The downside is that kextload must be run by root.
- Mike
From:
darwin-kernel-bounces+mwelch=email@hidden
[mailto:darwin-kernel-bounces+mwelch=email@hidden] On Behalf Of RajaGovarthanan Velusamy
Sent: Thursday, August 10, 2006
2:11 AM
To: email@hidden
Subject: Loading KEXT dynamicaly
for a USB MassStorage Drive
Hi All,
I am
working on to load\unload the KEXT dynamically from my application.
The
current scenario is like this,
1) I have
a KEXT file which has the IOKitPersonalities matching my USB device.
2) After copying this driver with the ROOT/WHEEL rights and restarting the
system the KEXT is loaded for my device.
3) My application is able to communicate with this KEXT to send commands to the
device. The aim of the application is to pass the scsi commands to the device.
I want to
eliminate the step 2. Ie.. My KEXT should not be loaded each time my machine
restarts. Instead when the application starts it should load the KEXT which is
used to issue the commands to my USB device.
Is there
any API that I can use to do this dynamically? Please help me with a sample or
link.
Regards,
V.Rajagovarthanan