1 /* 2 * Copyright 2009, Olivier Coursière. All rights reserved. 3 * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 7 8 #include <kernel.h> 9 #include <syscalls.h> 10 11 12 status_t 13 system_shutdown(bool reboot) 14 { 15 int32 cookie = 0; 16 team_info info; 17 18 gKernelShutdown = true; 19 20 // Now shutdown all system services! 21 // TODO: Once we are sure we can shutdown the system on all hardware 22 // checking reboot may not be necessary anymore. 23 if (reboot) { 24 while (get_next_team_info(&cookie, &info) == B_OK) { 25 if (info.team == B_SYSTEM_TEAM) 26 continue; 27 kill_team(info.team); 28 } 29 } 30 31 sync(); 32 33 return arch_cpu_shutdown(reboot); 34 } 35 36 37 // #pragma mark - 38 39 40 status_t 41 _user_shutdown(bool reboot) 42 { 43 if (geteuid() != 0) 44 return B_NOT_ALLOWED; 45 return system_shutdown(reboot); 46 } 47 48