Revision
23073
Author
zarzycki@apple.com
Date
2007-02-15 14:18:08 -0800 (Thu, 15 Feb 2007)

Log Message

On second thought, let's call the poweroff() API "reboot2()" and just pass the reboot flags down opaquely.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/launchd/src/Makefile.am (23072 => 23073)


--- trunk/launchd/src/Makefile.am	2007-02-15 18:57:17 UTC (rev 23072)
+++ trunk/launchd/src/Makefile.am	2007-02-15 22:18:08 UTC (rev 23073)
@@ -89,7 +89,7 @@
 	mkdir -p $(DESTDIR)/usr/local/include
 	cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h
 	cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h
-	cp $(srcdir)/poweroff.h $(DESTDIR)/usr/local/include/poweroff.h
+	cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h
 	mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d
 	mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d
 	mkdir -p $(DESTDIR)/Library/LaunchDaemons

Modified: trunk/launchd/src/Makefile.in (23072 => 23073)


--- trunk/launchd/src/Makefile.in	2007-02-15 18:57:17 UTC (rev 23072)
+++ trunk/launchd/src/Makefile.in	2007-02-15 22:18:08 UTC (rev 23073)
@@ -1103,7 +1103,7 @@
 @LIBS_ONLY_FALSE@	mkdir -p $(DESTDIR)/usr/local/include
 @LIBS_ONLY_FALSE@	cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h
 @LIBS_ONLY_FALSE@	cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h
-@LIBS_ONLY_FALSE@	cp $(srcdir)/poweroff.h $(DESTDIR)/usr/local/include/poweroff.h
+@LIBS_ONLY_FALSE@	cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h
 @LIBS_ONLY_FALSE@	mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d
 @LIBS_ONLY_FALSE@	mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d
 @LIBS_ONLY_FALSE@	mkdir -p $(DESTDIR)/Library/LaunchDaemons

Modified: trunk/launchd/src/launchd_core_logic.c (23072 => 23073)


--- trunk/launchd/src/launchd_core_logic.c	2007-02-15 18:57:17 UTC (rev 23072)
+++ trunk/launchd/src/launchd_core_logic.c	2007-02-15 22:18:08 UTC (rev 23073)
@@ -80,7 +80,7 @@
 #include "libvproc_public.h"
 #include "libvproc_internal.h"
 
-#include "poweroff.h"
+#include "reboot2.h"
 
 #include "launchd.h"
 #include "launchd_runtime.h"
@@ -202,8 +202,9 @@
 	job_t anonj;
 	char *jm_stdout;
 	char *jm_stderr;
+	int reboot_flags;
 	unsigned int global_on_demand_cnt;
-	unsigned int transfer_bstrap:1, sent_stop_to_hopeful_jobs:1, shutting_down:1, power_cycle:1, ups_delay:1;
+	unsigned int transfer_bstrap:1, sent_stop_to_hopeful_jobs:1, shutting_down:1;
 	char name[0];
 };
 
@@ -588,16 +589,7 @@
 		SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle);
 		jobmgr_tickle(jm->parentmgr);
 	} else if (getpid() == 1) {
-		int flags = 0;
-
-		if (!jm->power_cycle) {
-			flags |= RB_HALT;
-		}
-		if (jm->ups_delay) {
-			flags |= RB_UPSDELAY;
-		}
-
-		jobmgr_assumes(jm,  reboot(flags) != -1);
+		jobmgr_assumes(jm,  reboot(jm->reboot_flags) != -1);
 	} else {
 		exit(EXIT_SUCCESS);
 	}
@@ -4122,7 +4114,7 @@
 }
 
 kern_return_t
-job_mig_poweroff(job_t j, uint64_t flags)
+job_mig_reboot2(job_t j, uint64_t flags)
 {
 	struct ldcred ldc;
 
@@ -4136,12 +4128,7 @@
 		return BOOTSTRAP_NOT_PRIVILEGED;
 	}
 
-	if (flags & POWEROFF_RESET) {
-		root_jobmgr->power_cycle = true;
-	}
-	if (flags & POWEROFF_UPSDELAY) {
-		root_jobmgr->ups_delay = true;
-	}
+	root_jobmgr->reboot_flags = (int)flags;
 
 	launchd_shutdown();
 

Modified: trunk/launchd/src/libvproc.c (23072 => 23073)


--- trunk/launchd/src/libvproc.c	2007-02-15 18:57:17 UTC (rev 23072)
+++ trunk/launchd/src/libvproc.c	2007-02-15 22:18:08 UTC (rev 23073)
@@ -36,7 +36,7 @@
 
 #include "protocol_vproc.h"
 
-#include "poweroff.h"
+#include "reboot2.h"
 
 kern_return_t
 _vproc_grab_subset(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright,
@@ -220,7 +220,7 @@
 }
 
 void *
-poweroff(uint64_t flags)
+reboot2(uint64_t flags)
 {
 	mach_port_t parent_port = 0;
 	mach_port_t previous_port = 0;
@@ -239,12 +239,12 @@
 
 	} while (parent_port != previous_port);
 
-	if (vproc_mig_poweroff(parent_port, flags) == 0) {
+	if (vproc_mig_reboot2(parent_port, flags) == 0) {
 		return NULL;
 	}
 
 out_bad:
-	return poweroff;
+	return reboot2;
 }
 
 vproc_err_t

Deleted: trunk/launchd/src/poweroff.h (23072 => 23073)


--- trunk/launchd/src/poweroff.h	2007-02-15 18:57:17 UTC (rev 23072)
+++ trunk/launchd/src/poweroff.h	2007-02-15 22:18:08 UTC (rev 23073)
@@ -1,37 +0,0 @@
-#ifndef _POWEROFF_H_
-#define _POWEROFF_H_
-/*
- * Copyright (c) 2007 Apple Inc. All rights reserved.
- *
- * @APPLE_APACHE_LICENSE_HEADER_START@
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- * @APPLE_APACHE_LICENSE_HEADER_END@
- */
-
-#include <sys/cdefs.h>
-#include <stdint.h>
-
-__BEGIN_DECLS
-
-#define POWEROFF_RESET	1
-#define POWEROFF_UPSDELAY	2
-
-/* Returns NULL on success. Not NULL on failure */
-
-__attribute__((visibility("default"))) void *poweroff(uint64_t flags);
-
-__END_DECLS
-
-#endif

Modified: trunk/launchd/src/protocol_job.defs (23072 => 23073)


--- trunk/launchd/src/protocol_job.defs	2007-02-15 18:57:17 UTC (rev 23072)
+++ trunk/launchd/src/protocol_job.defs	2007-02-15 22:18:08 UTC (rev 23073)
@@ -41,7 +41,7 @@
 		__on_demand	: boolean_t;
 	out	__server_port	: mach_port_make_send_t);
 
-routine poweroff(
+routine reboot2(
 		__bs_port	: job_t;
 		__flags		: uint64_t);
 

Copied: trunk/launchd/src/reboot2.h (from rev 23071, trunk/launchd/src/poweroff.h) (0 => 23073)


--- trunk/launchd/src/reboot2.h	                        (rev 0)
+++ trunk/launchd/src/reboot2.h	2007-02-15 22:18:08 UTC (rev 23073)
@@ -0,0 +1,35 @@
+#ifndef _REBOOT2_H_
+#define _REBOOT2_H_
+/*
+ * Copyright (c) 2007 Apple Inc. All rights reserved.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_START@
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @APPLE_APACHE_LICENSE_HEADER_END@
+ */
+
+#include <sys/cdefs.h>
+#include <sys/reboot.h>
+#include <stdint.h>
+
+__BEGIN_DECLS
+
+/* Returns NULL on success. Not NULL on failure */
+
+__attribute__((visibility("default"))) void *reboot2(uint64_t flags);
+
+__END_DECLS
+
+#endif