aboutsummaryrefslogtreecommitdiff
path: root/sbin/savecore/savecore.c
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2012-12-16 23:09:27 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2012-12-16 23:09:27 +0000
commit165557e269ea03cbcd001a340122dac6b173a820 (patch)
tree0e8df91004142cc87703b820d90e48dbb2502e4a /sbin/savecore/savecore.c
parenteeff0b1b27b01cdde0e95df5ef87f0efd9b7f30a (diff)
downloadsrc-165557e269ea03cbcd001a340122dac6b173a820.tar.gz
src-165557e269ea03cbcd001a340122dac6b173a820.zip
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
Notes
Notes: svn path=/head/; revision=244321
Diffstat (limited to 'sbin/savecore/savecore.c')
-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 ca1cf1321aad..bdbf7e384f39 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)