summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2012-12-16 23:09:27 +0000
committerpjd <pjd@FreeBSD.org>2012-12-16 23:09:27 +0000
commit81a7aa503ccef5a267f9644672eb54b5256125de (patch)
tree0e8df91004142cc87703b820d90e48dbb2502e4a
parentc5cbd42d14b9d344c2cfe474407c43ddfbc75995 (diff)
downloadFreeBSD-src-81a7aa503ccef5a267f9644672eb54b5256125de.zip
FreeBSD-src-81a7aa503ccef5a267f9644672eb54b5256125de.tar.gz
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
-rw-r--r--sbin/savecore/savecore.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index ca1cf13..bdbf7e3 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -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, off_t lasthd, char *buf,
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 *device)
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)
OpenPOWER on IntegriCloud