summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2016-10-26 11:09:04 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2016-10-26 11:09:04 +0000
commitded89250657ad19632743ae1db8aa88c1287fd90 (patch)
tree38b86735276ea4e0a1fdd60842cc73acf5d96c67
parent0c0abfeb229c72e424919a9c97af6c0fcbb0e958 (diff)
parent0e06cf66748977451504da1dae14c0975c3d331a (diff)
downloadillumos-joyent-ded89250657ad19632743ae1db8aa88c1287fd90.tar.gz
[illumos-gate merge]
commit 0e06cf66748977451504da1dae14c0975c3d331a 6017 savecore's messages about read errors are useless commit 222d1ab6ac935b870bc344025f6ac3e0613e2940 7475 savecore should not go further if there is no dumpfile
-rw-r--r--usr/src/cmd/savecore/savecore.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/usr/src/cmd/savecore/savecore.c b/usr/src/cmd/savecore/savecore.c
index 221005ca28..e1d3589acc 100644
--- a/usr/src/cmd/savecore/savecore.c
+++ b/usr/src/cmd/savecore/savecore.c
@@ -23,7 +23,7 @@
* Copyright 2016 Joyent, Inc.
*/
/*
- * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
*/
#include <stdio.h>
@@ -72,6 +72,7 @@ static char *dumpfile; /* source of raw crash dump */
static long bounds = -1; /* numeric suffix */
static long pagesize; /* dump pagesize */
static int dumpfd = -1; /* dumpfile descriptor */
+static boolean_t have_dumpfile = B_TRUE; /* dumpfile existence */
static dumphdr_t corehdr, dumphdr; /* initial and terminal dumphdrs */
static boolean_t dump_incomplete; /* dumphdr indicates incomplete */
static boolean_t fm_panic; /* dump is the result of fm_panic */
@@ -239,7 +240,7 @@ logprint(uint32_t flags, char *message, ...)
case SC_EXIT_ERR:
default:
- if (!mflag && logprint_raised++ == 0)
+ if (!mflag && logprint_raised++ == 0 && have_dumpfile)
raise_event(SC_EVENT_SAVECORE_FAILURE, buf);
code = 1;
break;
@@ -266,8 +267,8 @@ static void
Fread(void *buf, size_t size, FILE *f)
{
if (fread(buf, size, 1, f) != 1)
- logprint(SC_SL_ERR | SC_EXIT_ERR, "fread: ferror %d feof %d",
- ferror(f), feof(f));
+ logprint(SC_SL_ERR | SC_EXIT_ERR, "fread: %s",
+ strerror(errno));
}
static void
@@ -299,9 +300,11 @@ Fstat(int fd, Stat_t *sb, const char *fname)
static void
Stat(const char *fname, Stat_t *sb)
{
- if (stat64(fname, sb) != 0)
- logprint(SC_SL_ERR | SC_EXIT_ERR, "stat(\"%s\"): %s", fname,
- strerror(errno));
+ if (stat64(fname, sb) != 0) {
+ have_dumpfile = B_FALSE;
+ logprint(SC_SL_ERR | SC_EXIT_ERR, "failed to get status "
+ "of file %s", fname);
+ }
}
static void
@@ -1711,9 +1714,11 @@ main(int argc, char *argv[])
if (dumpfile == NULL) {
dumpfile = Zalloc(MAXPATHLEN);
- if (ioctl(dumpfd, DIOCGETDEV, dumpfile) == -1)
+ if (ioctl(dumpfd, DIOCGETDEV, dumpfile) == -1) {
+ have_dumpfile = B_FALSE;
logprint(SC_SL_NONE | SC_IF_ISATTY | SC_EXIT_ERR,
"no dump device configured");
+ }
}
if (mflag)