git: 4dfc78e0e3bb - main - crashinfo: Create core.txt.last symlink

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 28 May 2026 16:21:27 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=4dfc78e0e3bb096514455e9bb6cf63e46e84db13

commit 4dfc78e0e3bb096514455e9bb6cf63e46e84db13
Author:     Ricardo Branco <rbranco@suse.de>
AuthorDate: 2026-05-15 14:58:41 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-05-28 16:20:30 +0000

    crashinfo: Create core.txt.last symlink
    
    When saving a coredump, savecore(8) maintains .last symlinks for the
    info and vmcore artifacts, but not for the crashinfo text report.
    
    Make crashinfo(8) create the link, pointing at the current
    core.txt.<bounds> file.
    
    This makes /var/crash/core.txt.last track the same core dump as
    info.last and vmcore.last.
    
    [mhorne: I tweaked the submission, such that the link will be created as
    soon as the core.txt.X file is generated; not only after a successful
    report has been written.]
    
    Signed-off-by:  Ricardo Branco <rbranco@suse.de>
    Reviewed by:    mhorne
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2199
---
 usr.sbin/crashinfo/crashinfo.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/usr.sbin/crashinfo/crashinfo.sh b/usr.sbin/crashinfo/crashinfo.sh
index 68115f09f9d4..87e5565b98e3 100755
--- a/usr.sbin/crashinfo/crashinfo.sh
+++ b/usr.sbin/crashinfo/crashinfo.sh
@@ -149,11 +149,13 @@ fi
 VMCORE=$CRASHDIR/vmcore.$DUMPNR
 INFO=$CRASHDIR/info.$DUMPNR
 FILE=$CRASHDIR/core.txt.$DUMPNR
+LINK=$CRASHDIR/core.txt.last
 HOSTNAME=`hostname`
 
 if $BATCH; then
 	echo "Writing crash summary to $FILE."
 	exec > $FILE 2>&1
+	ln -sf $FILE $LINK
 fi
 
 GDB=/usr/local/bin/gdb
@@ -204,6 +206,7 @@ machine=$(gdb_command $KERNEL 'printf "%s", machine')
 if ! $BATCH; then
 	echo "Writing crash summary to $FILE."
 	exec > $FILE 2>&1
+	ln -sf $FILE $LINK
 fi
 
 echo "$HOSTNAME dumped core - see $VMCORE"