From owner-freebsd-current@FreeBSD.ORG Wed Jun 15 14:14:57 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9DC2616A41F for ; Wed, 15 Jun 2005 14:14:57 +0000 (GMT) (envelope-from emaste@phaedrus.sandvine.ca) Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id A678643D48 for ; Wed, 15 Jun 2005 14:14:53 +0000 (GMT) (envelope-from emaste@phaedrus.sandvine.ca) Received: from labgw2.phaedrus.sandvine.com ([192.168.3.11]) by mailserver.sandvine.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 15 Jun 2005 10:14:47 -0400 Received: by labgw2.phaedrus.sandvine.com (Postfix, from userid 12627) id CAEC613631; Wed, 15 Jun 2005 10:14:47 -0400 (EDT) Date: Wed, 15 Jun 2005 10:14:47 -0400 From: Ed Maste To: freebsd-current@freebsd.org Message-ID: <20050615141447.GD95217@sandvine.com> References: <20050613192308.GA87640@sandvine.com> <20050614082039.GA2038@dragon.NUXI.org> <20050614224704.Y75797@mp2.macomnet.net> <20050614190854.GA12928@dragon.NUXI.org> <20050614235132.L76669@mp2.macomnet.net> <20050615023600.GA20721@dragon.NUXI.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="NDin8bjvE/0mNLFQ" Content-Disposition: inline In-Reply-To: <20050615023600.GA20721@dragon.NUXI.org> User-Agent: Mutt/1.4.2.1i X-OriginalArrivalTime: 15 Jun 2005 14:14:48.0058 (UTC) FILETIME=[965BD5A0:01C571B4] Subject: Re: savecore(8) increments /var/crash/bounds on each boot X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2005 14:14:57 -0000 --NDin8bjvE/0mNLFQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --NDin8bjvE/0mNLFQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="savecore.patch" --- 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); /* --NDin8bjvE/0mNLFQ--