Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Dec 2012 23:09:27 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244321 - head/sbin/savecore
Message-ID:  <201212162309.qBGN9RoU069781@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sun Dec 16 23:09:27 2012
New Revision: 244321
URL: http://svnweb.freebsd.org/changeset/base/244321

Log:
  With rotating kernel dumps the higest dump number is not necessarily the
  last one. To make it easier to find the last one create symlinks with 'last'
  suffix that will point to the files of the last coredump, eg.:
  
  	info.last -> info.5
  	textdump.tar.last.gz -> textdump.tar.5.gz
  
  Reviewed by:	avg
  Obtained from:	WHEEL Systems

Modified:
  head/sbin/savecore/savecore.c

Modified: head/sbin/savecore/savecore.c
==============================================================================
--- head/sbin/savecore/savecore.c	Sun Dec 16 23:06:12 2012	(r244320)
+++ head/sbin/savecore/savecore.c	Sun Dec 16 23:09:27 2012	(r244321)
@@ -229,6 +229,17 @@ saved_dump_remove(int bounds)
 	(void)unlink(path);
 }
 
+static void
+symlinks_remove(void)
+{
+
+	(void)unlink("info.last");
+	(void)unlink("vmcore.last");
+	(void)unlink("vmcore.last.gz");
+	(void)unlink("textdump.tar.last");
+	(void)unlink("textdump.tar.last.gz");
+}
+
 /*
  * Check that sufficient space is available on the disk that holds the
  * save directory.
@@ -419,7 +430,7 @@ DoTextdumpFile(int fd, off_t dumpsize, o
 static void
 DoFile(const char *savedir, const char *device)
 {
-	static char infoname[PATH_MAX], corename[PATH_MAX];
+	static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX];
 	static char *buf = NULL;
 	struct kerneldumpheader kdhf, kdhl;
 	off_t mediasize, dumpsize, firsthd, lasthd;
@@ -664,6 +675,23 @@ DoFile(const char *savedir, const char *
 		goto closeall;
 	}
 
+	symlinks_remove();
+	if (symlink(infoname, "info.last") == -1) {
+		syslog(LOG_WARNING, "unable to create symlink %s/%s: %m",
+		    savedir, "info.last");
+	}
+	if (compress) {
+		snprintf(linkname, sizeof(linkname), "%s.last.gz",
+		    istextdump ? "textdump.tar" : "vmcore");
+	} else {
+		snprintf(linkname, sizeof(linkname), "%s.last",
+		    istextdump ? "textdump.tar" : "vmcore");
+	}
+	if (symlink(corename, linkname) == -1) {
+		syslog(LOG_WARNING, "unable to create symlink %s/%s: %m",
+		    savedir, linkname);
+	}
+
 	nsaved++;
 
 	if (verbose)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212162309.qBGN9RoU069781>