Skip to content

XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)

C

xnu.ko: console output without a trailing newline (a prompt) is shown at the end of the write

Heyang Zhou33f24d04363f
diff --git a/xnu-ko/xnu_main.c b/xnu-ko/xnu_main.c
index ef6cd3c..801507d 100644
--- a/xnu-ko/xnu_main.c
+++ b/xnu-ko/xnu_main.c
@@ -272,6 +272,14 @@ static long xnu_hook_body(unsigned long stage, unsigned long a1, unsigned long a
logs(m);
}
}
+ if (n) { /* a write without a newline (a prompt): show it now */
+ char m[220]; unsigned j = 0, k;
+ const char *p = "darwin console: ";
+ while (*p) m[j++] = *p++;
+ for (k = 0; k < n; k++) m[j++] = line[k];
+ m[j] = 0; n = 0;
+ logs(m);
+ }
return 0;
}
if (stage == 998) { /* XNU kprintf */