From 2ca7877009986198e0b32487e3222c876e4ce25a Mon Sep 17 00:00:00 2001 From: dwhite Date: Mon, 20 Jun 2005 20:01:29 +0000 Subject: 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 8829695..33255c3 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); /* -- cgit v1.1