X-Git-Url: https://git.saurik.com/apple/system_cmds.git/blobdiff_plain/34d340d711a2b033f5da480ed7b5eb147679a588..ac27e6b4e9f2f269ad11856171ae8e1f51fa26f0:/reboot.tproj/reboot.c diff --git a/reboot.tproj/reboot.c b/reboot.tproj/reboot.c index 4282a1e..e9aa380 100644 --- a/reboot.tproj/reboot.c +++ b/reboot.tproj/reboot.c @@ -58,17 +58,23 @@ static const char rcsid[] = #include #ifdef __APPLE__ +#include +#if !TARGET_OS_EMBEDDED #include "kextmanager.h" #include +#endif #include // allocate #include // task_self, etc #include // bootstrap +#include #include +#include +#include #endif void usage(void); u_int get_pageins(void); -#ifdef __APPLE__ +#if defined(__APPLE__) && !TARGET_OS_EMBEDDED int reserve_reboot(void); #endif @@ -128,6 +134,7 @@ main(int argc, char *argv[]) break; case 'q': qflag = 1; + howto |= RB_QUICK; break; case '?': default: @@ -145,9 +152,9 @@ main(int argc, char *argv[]) err(1, NULL); } -#ifdef __APPLE__ - if (!lflag) { // shutdown(8) has already checked w/kextd - if ((errno = reserve_reboot()) && !qflag) +#if defined(__APPLE__) && !TARGET_OS_EMBEDDED + if (!qflag && !lflag) { // shutdown(8) has already checked w/kextd + if ((errno = reserve_reboot())) err(1, "couldn't lock for reboot"); } #endif @@ -184,7 +191,20 @@ main(int argc, char *argv[]) syslog(LOG_CRIT, "rebooted by %s", user); } } +#if defined(__APPLE__) + { + struct utmpx utx; + bzero(&utx, sizeof(utx)); + utx.ut_type = SHUTDOWN_TIME; + gettimeofday(&utx.ut_tv, NULL); + pututxline(&utx); + + int newvalue = 1; + sysctlbyname("kern.willshutdown", NULL, NULL, &newvalue, sizeof(newvalue)); + } +#else logwtmp("~", "shutdown", ""); +#endif /* * Do a sync early on, so disks start transfers while we're off @@ -282,7 +302,7 @@ get_pageins() return pageins; } -#ifdef __APPLE__ +#if defined(__APPLE__) && !TARGET_OS_EMBEDDED // XX this routine is also in shutdown.tproj; it would be nice to share #define WAITFORLOCK 1 @@ -298,7 +318,7 @@ reserve_reboot() int busyStatus = ELAST + 1; mountpoint_t busyVol; - macherr = bootstrap_look_up(bootstrap_port, KEXTD_SERVER_NAME, &kxport); + macherr = bootstrap_look_up2(bootstrap_port, KEXTD_SERVER_NAME, &kxport, 0, BOOTSTRAP_PRIVILEGED_SERVER); if (macherr) goto finish; // allocate a port to pass to kextd (in case we die)