git: 7e99c034f788 - main - Emit uprintf() output for initproc if there is no controlling terminal

Alex Richardson arichardson at FreeBSD.org
Wed Jan 20 10:37:44 UTC 2021


The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=7e99c034f788128c7d168eaf27af9a3acaa06163

commit 7e99c034f788128c7d168eaf27af9a3acaa06163
Author:     Alex Richardson <arichardson at FreeBSD.org>
AuthorDate: 2021-01-20 09:54:46 +0000
Commit:     Alex Richardson <arichardson at FreeBSD.org>
CommitDate: 2021-01-20 09:54:46 +0000

    Emit uprintf() output for initproc if there is no controlling terminal
    
    This patch helped me debug why /sbin/init was not being loaded after
    making changes to the image activator in CheriBSD.
    
    Reviewed By:    jhb (earlier version), kib
    Differential Revision: https://reviews.freebsd.org/D28121
---
 sys/kern/subr_prf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 31117c4e3415..b51213a25d0d 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -179,6 +179,14 @@ uprintf(const char *fmt, ...)
 	if (TD_IS_IDLETHREAD(td))
 		return (0);
 
+	if (td->td_proc == initproc) {
+		/* Produce output when we fail to load /sbin/init: */
+		va_start(ap, fmt);
+		retval = vprintf(fmt, ap);
+		va_end(ap);
+		return (retval);
+	}
+
 	sx_slock(&proctree_lock);
 	p = td->td_proc;
 	PROC_LOCK(p);


More information about the dev-commits-src-all mailing list