[launchd-changes] [23464] trunk/launchd/src/launchd_core_logic.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 12 13:12:29 PST 2007


Revision: 23464
          http://trac.macosforge.org/projects/launchd/changeset/23464
Author:   zarzycki at apple.com
Date:     2007-12-12 13:12:28 -0800 (Wed, 12 Dec 2007)

Log Message:
-----------
Let's do some more stuff in user-land so that we can benchmark it.

Modified Paths:
--------------
    trunk/launchd/src/launchd_core_logic.c

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2007-12-12 20:32:53 UTC (rev 23463)
+++ trunk/launchd/src/launchd_core_logic.c	2007-12-12 21:12:28 UTC (rev 23464)
@@ -453,6 +453,7 @@
 static void extract_rcsid_substr(const char *i, char *o, size_t osz);
 static void do_first_per_user_launchd_hack(void);
 static void do_file_init(void) __attribute__((constructor));
+static void do_unmounts(void);
 
 /* file local globals */
 static size_t total_children;
@@ -754,6 +755,8 @@
 	} else if (getpid() == 1) {
 		jobmgr_log(jm, LOG_DEBUG, "About to call: sync()");
 		sync(); /* We're are going to rely on log timestamps to benchmark this call */
+		jobmgr_log(jm, LOG_DEBUG, "Unmounting all filesystems except / and /dev");
+		do_unmounts();
 		launchd_log_vm_stats();
 		jobmgr_log(jm, LOG_DEBUG, "About to call: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags));
 		runtime_closelog();
@@ -6694,3 +6697,32 @@
 	launchd_assert(mach_timebase_info(&tbi) == 0);
 
 }
+
+void
+do_unmounts(void)
+{
+	struct statfs buf[100];
+	int i, found, returned;
+
+	do {
+		returned = getfsstat(buf, sizeof(buf), MNT_NOWAIT);
+		found = 0;
+
+		if (!launchd_assumes(returned != -1)) {
+			return;
+		}
+
+		for (i = 0; i < returned; i++) {
+			if (strcmp(buf[i].f_mntonname, "/") == 0) {
+				continue;
+			} else if (strncmp(buf[i].f_mntonname, "/dev", strlen("/dev")) == 0) {
+				continue;
+			}
+
+			runtime_syslog(LOG_DEBUG, "About to unmount: %s", buf[i].f_mntonname);
+			if (launchd_assumes(unmount(buf[i].f_mntonname, 0) != -1)) {
+				found++;
+			}
+		}
+	} while ((returned == (sizeof(buf) / sizeof(buf[0]))) && (found > 0));
+}

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


More information about the launchd-changes mailing list