size_t len = sizeof(int);
int safeboot = 0;
int ret;
ret = sysctlbyname("kern.safeboot", &safeboot, &len, NULL, 0);
This code always seems to fail; I've tried UInt32 as well, it always returns an error code of 1. Is there a way to figure out if my kext is running in safeboot? I need it to behave differently.