2004-11-25 20:59:13 +03:00
|
|
|
/*
|
2009-04-05 23:04:25 +04:00
|
|
|
* Copyright 2009, Olivier Coursière. All rights reserved.
|
2004-11-25 20:59:13 +03:00
|
|
|
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <kernel.h>
|
|
|
|
#include <syscalls.h>
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2007-05-23 23:56:40 +04:00
|
|
|
system_shutdown(bool reboot)
|
2004-11-25 20:59:13 +03:00
|
|
|
{
|
2009-04-05 23:04:25 +04:00
|
|
|
int32 cookie = 0;
|
|
|
|
team_info info;
|
|
|
|
|
|
|
|
// Now shutdown all system services!
|
|
|
|
// TODO: Once we are sure we can shutdown the system on all hardware
|
|
|
|
// checking reboot may not be necessary anymore.
|
|
|
|
if (reboot) {
|
|
|
|
while (get_next_team_info(&cookie, &info) == B_OK) {
|
|
|
|
if (info.team == B_SYSTEM_TEAM)
|
|
|
|
continue;
|
|
|
|
kill_team(info.team);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-25 20:59:13 +03:00
|
|
|
sync();
|
|
|
|
|
|
|
|
return arch_cpu_shutdown(reboot);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
_user_shutdown(bool reboot)
|
|
|
|
{
|
2004-11-29 02:13:22 +03:00
|
|
|
if (geteuid() != 0)
|
|
|
|
return B_NOT_ALLOWED;
|
2007-05-23 23:56:40 +04:00
|
|
|
return system_shutdown(reboot);
|
2004-11-25 20:59:13 +03:00
|
|
|
}
|
2004-11-29 02:13:22 +03:00
|
|
|
|