[launchd-changes] [22939] trunk/launchd/src

source_changes at macosforge.org source_changes at macosforge.org
Thu Nov 9 08:13:53 PST 2006


Revision: 22939
          http://trac.macosforge.org/projects/launchd/changeset/22939
Author:   zarzycki at apple.com
Date:     2006-11-09 08:13:53 -0800 (Thu, 09 Nov 2006)

Log Message:
-----------
<rdar://problem/4537339> BootRoot: launchd needs to call kextd early if is_bootrooted()

Modified Paths:
--------------
    trunk/launchd/src/Makefile.am
    trunk/launchd/src/Makefile.in
    trunk/launchd/src/launchctl.c

Modified: trunk/launchd/src/Makefile.am
===================================================================
--- trunk/launchd/src/Makefile.am	2006-11-07 01:31:33 UTC (rev 22938)
+++ trunk/launchd/src/Makefile.am	2006-11-09 16:13:53 UTC (rev 22939)
@@ -37,7 +37,7 @@
 sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown
 
 launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders
-launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib
+launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -weak_library /usr/lib/libedit.dylib
 
 SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS)
 SystemStarter_LDFLAGS = -framework CoreFoundation

Modified: trunk/launchd/src/Makefile.in
===================================================================
--- trunk/launchd/src/Makefile.in	2006-11-07 01:31:33 UTC (rev 22938)
+++ trunk/launchd/src/Makefile.in	2006-11-09 16:13:53 UTC (rev 22939)
@@ -238,7 +238,7 @@
 @LIBS_ONLY_FALSE at sbin_SCRIPTS = service
 @LIBS_ONLY_FALSE at sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown
 @LIBS_ONLY_FALSE at launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders
- at LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib
+ at LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -weak_library /usr/lib/libedit.dylib
 @LIBS_ONLY_FALSE at SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS)
 @LIBS_ONLY_FALSE at SystemStarter_LDFLAGS = -framework CoreFoundation
 @LIBS_ONLY_FALSE at SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c

Modified: trunk/launchd/src/launchctl.c
===================================================================
--- trunk/launchd/src/launchctl.c	2006-11-07 01:31:33 UTC (rev 22938)
+++ trunk/launchd/src/launchctl.c	2006-11-09 16:13:53 UTC (rev 22939)
@@ -22,6 +22,7 @@
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <CoreFoundation/CFPriv.h>
+#include <IOKit/IOKitLib.h>
 #include <NSSystemDirectories.h>
 #include <mach/mach.h>
 #include <sys/types.h>
@@ -58,6 +59,8 @@
 #include <paths.h>
 #include <utmp.h>
 #include <utmpx.h>
+#include <bootfiles.h>
+#include <sysexits.h>
 
 #include "libbootstrap_public.h"
 #include "libvproc_internal.h"
@@ -133,6 +136,7 @@
 static void workaround4465949(void);
 static void do_application_firewall_magic(int sfd, launch_data_t thejob);
 static void preheat_page_cache_hack(void);
+static void do_bootroot_magic(void);
 
 static int bootstrap_cmd(int argc, char *const argv[]);
 static int load_and_unload_cmd(int argc, char *const argv[]);
@@ -1202,6 +1206,8 @@
 		do_potential_fsck();
 	}
 
+	do_bootroot_magic();
+
 	if (path_check("/var/account/acct")) {
 		assumes(acct("/var/account/acct") != -1);
 	}
@@ -2762,3 +2768,42 @@
 
 	closedir(thedir);
 }
+
+
+void
+do_bootroot_magic(void)
+{
+	const char *kextcache_tool[] = { "kextcache", "-U", "/", NULL };
+	CFTypeRef bootrootProp;
+	io_service_t chosen;
+	int wstatus;
+	pid_t p;
+	
+	chosen = IORegistryEntryFromPath(kIOMasterPortDefault, "IODeviceTree:/chosen");
+
+	if (!assumes(chosen)) {
+		return;
+	}
+
+	bootrootProp = IORegistryEntryCreateCFProperty(chosen, CFSTR(kBootRootActiveKey), kCFAllocatorDefault, 0);
+
+	IOObjectRelease(chosen);
+
+	if (!bootrootProp) {
+		return;
+	}
+
+	CFRelease(bootrootProp);
+
+	if (!assumes((p = fwexec(kextcache_tool, false)) != -1)) {
+		return;
+	}
+
+	if (!assumes(waitpid(p, &wstatus, 0) != -1)) {
+		return;
+	}
+
+	if (!WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == EX_OSFILE) {
+		assumes(reboot(RB_AUTOBOOT) != -1);
+	}
+}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061109/3f5cb47d/attachment.html


More information about the launchd-changes mailing list