From 9520784e294282bc42e22f8eeb4a55cfde656544 Mon Sep 17 00:00:00 2001 From: Doug White Date: Mon, 20 Jun 2005 20:01:29 +0000 Subject: [PATCH] Don't bump bounds every time savecore(8) is run. Submitted by: Ed Maste Approved by: re --- sbin/savecore/savecore.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index 88296956694a..33255c356777 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -145,35 +145,36 @@ getbounds(void) { if ((fp = fopen("bounds", "r")) == NULL) { syslog(LOG_WARNING, "unable to open bounds file, using 0"); - goto newfile; + return (ret); } if (fgets(buf, sizeof buf, fp) == NULL) { syslog(LOG_WARNING, "unable to read from bounds, using 0"); fclose(fp); - goto newfile; + return (ret); } errno = 0; ret = (int)strtol(buf, NULL, 10); if (ret == 0 && (errno == EINVAL || errno == ERANGE)) syslog(LOG_WARNING, "invalid value found in bounds, using 0"); + return (ret); +} -newfile: +static void +writebounds(int bounds) { + FILE *fp; if ((fp = fopen("bounds", "w")) == NULL) { syslog(LOG_WARNING, "unable to write to bounds file: %m"); - goto done; + return; } if (verbose) - printf("bounds number: %d\n", ret); + printf("bounds number: %d\n", bounds); - fprintf(fp, "%d\n", (ret + 1)); + fprintf(fp, "%d\n", bounds); fclose(fp); - -done: - return (ret); } /* @@ -373,6 +374,8 @@ DoFile(const char *savedir, const char *device) goto closefd; } + writebounds(bounds + 1); + sprintf(buf, "info.%d", bounds); /*