git: 2aee804c9ef0 - main - kerneldump: Add flag to indicate kernel core was successfully dumped

From: Stephen J. Kiernan <stevek_at_FreeBSD.org>
Date: Thu, 28 Mar 2024 18:13:12 UTC
The branch main has been updated by stevek:

URL: https://cgit.FreeBSD.org/src/commit/?id=2aee804c9ef02b2ffa3e35037ea45f43e1709d2f

commit 2aee804c9ef02b2ffa3e35037ea45f43e1709d2f
Author:     Stephen J. Kiernan <stevek@FreeBSD.org>
AuthorDate: 2024-03-27 22:55:21 +0000
Commit:     Stephen J. Kiernan <stevek@FreeBSD.org>
CommitDate: 2024-03-28 18:11:16 +0000

    kerneldump: Add flag to indicate kernel core was successfully dumped
    
    This allows for shutdown_final EVENTHANDLERs to know that a core dump
    successfully occurred. Embedded systems may want to record this fact
    or act on it.
    
    Obtained from:  Juniper Networks, Inc.
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D44542
---
 sys/kern/kern_shutdown.c | 5 ++++-
 sys/sys/conf.h           | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index f49e315a503d..b0a3c3fa9e91 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -229,6 +229,7 @@ bool scheduler_stopped __read_frequently;
 
 int dumping __read_mostly;		/* system is dumping */
 int rebooting __read_mostly;		/* system is rebooting */
+bool dumped_core __read_mostly;		/* system successfully dumped core */
 /*
  * Used to serialize between sysctl kern.shutdown.dumpdevname and list
  * modifications via ioctl.
@@ -415,8 +416,10 @@ doadump(boolean_t textdump)
 
 		TAILQ_FOREACH(di, &dumper_configs, di_next) {
 			error = dumpsys(di);
-			if (error == 0)
+			if (error == 0) {
+				dumped_core = true;
 				break;
+			}
 		}
 	}
 
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index f34fd43cfe24..8470f53e0408 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -358,6 +358,7 @@ struct dumperinfo {
 };
 
 extern int dumping;		/* system is dumping */
+extern bool dumped_core;	/* system successfully dumped kernel core */
 
 /*
  * Save registers for later extraction from a kernel dump.