savecore(8) increments /var/crash/bounds on each boot
Ed Maste
emaste at phaedrus.sandvine.ca
Wed Jun 15 14:14:57 GMT 2005
On Tue, Jun 14, 2005 at 07:36:00PM -0700, David O'Brien wrote:
> Do you understand the fix? How does lying in printheader() fix anything?
> Moving the call to getbounds() back to the original location is the "fix"
> but then it negates -vv. We shouldn't lie in printheader().
Fair enough, on dwhite's suggestion here's another try that splits the
increment-and-write out from getbounds() so that the bounds value can
be shown with -vv.
--
Ed Maste, Sandvine Incorporated
-------------- next part --------------
--- savecore.c.orig 2005-06-13 16:19:41.000000000 -0400
+++ savecore.c 2005-06-15 09:41:52.000000000 -0400
@@ -145,35 +145,36 @@
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 @@
goto closefd;
}
+ writebounds(bounds+1);
+
sprintf(buf, "info.%d", bounds);
/*
More information about the freebsd-current
mailing list