xref: /haiku/src/system/kernel/shutdown.cpp (revision 45bd7bb3db9d9e4dcb02b89a3e7c2bf382c0a88c)
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 	// Now shutdown all system services!
19 	// TODO: Once we are sure we can shutdown the system on all hardware
20 	// checking reboot may not be necessary anymore.
21 	if (reboot) {
22 		while (get_next_team_info(&cookie, &info) == B_OK) {
23 			if (info.team == B_SYSTEM_TEAM)
24 				continue;
25 			kill_team(info.team);
26 		}
27 	}
28 
29 	sync();
30 
31 	return arch_cpu_shutdown(reboot);
32 }
33 
34 
35 //	#pragma mark -
36 
37 
38 status_t
39 _user_shutdown(bool reboot)
40 {
41 	if (geteuid() != 0)
42 		return B_NOT_ALLOWED;
43 	return system_shutdown(reboot);
44 }
45 
46