2 #include <CoreFoundation/CoreFoundation.h>
5 #define TIMER_PERIOD_S 10
6 #define DEFAULT_SEARCH_PATH "/System/Library/Extensions/"
8 static const char * arg0
= NULL
;
10 static void usage(void)
12 printf("usage: %s [-v] [-d] [-x] [-j] [-b bootlevel] [-f dirpath]\n", arg0
);
16 int main (int argc
, const char *argv
[])
20 KEXTBootlevel bootlevel
;
23 CFMutableArrayRef array
;
33 period
= TIMER_PERIOD_S
;
39 bootlevel
= kKEXTBootlevelNormal
;
41 url
= CFURLCreateWithFileSystemPath(NULL
, CFSTR(DEFAULT_SEARCH_PATH
), kCFURLPOSIXPathStyle
, true);
43 printf("Error opening: %s.\n", DEFAULT_SEARCH_PATH
);
46 array
= CFArrayCreateMutable(NULL
, 0, &kCFTypeArrayCallBacks
);
47 CFArrayAppendValue(array
, url
);
50 while ( (c
= getopt(argc
, (char **)argv
, "xvdjb:f:")) != -1 ) {
68 period
= strtoul(optarg
, NULL
, 0);
79 bootlevel
= strtoul(optarg
, NULL
, 0);
80 if ( bootlevel
> 0x1f ) {
93 str
= CFStringCreateWithCString(NULL
, optarg
, kCFStringEncodingNonLossyASCII
);
95 url
= CFURLCreateWithFileSystemPath(NULL
, str
, kCFURLPOSIXPathStyle
, true);
99 printf("Error opening: %s.\n", optarg
);
101 CFArrayAppendValue(array
, url
);
117 kextd
= KEXTDCreate(array
, &error
);
120 KEXTError(error
, CFSTR("Error creating kextd"));
124 KEXTDRegisterHelperCallbacks(kextd
, NULL
);
126 error
= KEXTDStartMain(kextd
, beVerbose
, safeBoot
, debug
, enableTimer
, period
, bootlevel
, cdMKextBoot
);
128 error
= KEXTDStartMain(kextd
, beVerbose
, safeBoot
, debug
, bootlevel
, cdMKextBoot
);
130 if ( error
!= kKEXTReturnSuccess
) {
132 KEXTError(error
, CFSTR("Error starting kextd"));