Date: Wed, 27 Mar 1996 10:04:24 +0100 From: "Philippe Charnier" <charnier@lirmm.fr> To: current@freebsd.org Subject: savecore Message-ID: <199603270904.KAA06468@lirmm.lirmm.fr>
next in thread | raw e-mail | index | archive | help
Hi,
I submitted a patch one month ago to make savecore in a working state. It
was very buggy and I crashed my box about 10 times to test my changes. As
I have no FreeBSD box on the net, I can't use send-pr and I use
bugs@FreeBSD.org instead. I had no news about this patch: Is one of the
committers working on reviewing it or has it been discarded or simply
lost?
An answer like "Your mail is saved in my mailbox, I will review it/commit it
or reject it when I will get time" would be nice.
I added the patch at the end of the mail, please consider it.
Thanks
-------- --------
Philippe Charnier charnier@lirmm.fr
LIRMM, 161 rue Ada, 34392 Montpellier cedex 5 -- France
------------------------------------------------------------------------
You will find enclosed a patch for savecore that correct the following
bugs:
- dumpsize was used (in check_space) before being computed (in
save_core): dumpsize was always 0 in check_space. Compute
dumpsize before calling check_space which need it.
- convert all quantities required for free space computation to a
number of bytes (some of them were in Kbytes, others in bytes,
making result a little bit silly). Minfree is really take into
account now.
- cosmetics changes.
- only dump a core is minfree bytes are left on the disk after
the dump.
Index: sbin/savecore/./savecore.c
===================================================================
RCS file: /home2h/FreeBSD.cvsroot/src/sbin/savecore/savecore.c,v
retrieving revision 1.11
diff -u -r1.11 savecore.c
--- savecore.c 1995/12/13 11:36:20 1.11
+++ savecore.c 1996/03/02 14:09:22
@@ -290,6 +290,11 @@
*cp = getc(fp);
while (*cp++ && cp < &panic_mesg[sizeof(panic_mesg)]);
}
+ /* Read the dump size, and convert it to a number of bytes. */
+ (void)fseek(fp,
+ (off_t)(dumplo + ok(dump_nl[X_DUMPSIZE].n_value)), L_SET);
+ (void)fread(&dumpsize, sizeof(dumpsize), 1, fp);
+ dumpsize *= NBPG;
/* Don't fclose(fp), we use dumpfd later. */
}
@@ -369,15 +374,10 @@
ifd = dumpfd;
}
- /* Read the dump size. */
- Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_DUMPSIZE].n_value)), L_SET);
- (void)Read(dumpfd, &dumpsize, sizeof(dumpsize));
-
/* Seek to the start of the core. */
Lseek(ifd, (off_t)dumplo, L_SET);
/* Copy the core file. */
- dumpsize *= NBPG;
syslog(LOG_NOTICE, "writing %score to %s",
compress ? "compressed " : "", path);
for (; dumpsize > 0; dumpsize -= nr) {
@@ -547,28 +547,27 @@
syslog(LOG_ERR, "%s: %m", dirname);
exit(1);
}
- spacefree = (fsbuf.f_bavail * fsbuf.f_bsize) / 1024;
-
+ spacefree = fsbuf.f_bavail * fsbuf.f_bsize;
+ minfree = 0;
(void)snprintf(path, sizeof(path), "%s/minfree", dirname);
- if ((fp = fopen(path, "r")) == NULL)
- minfree = 0;
- else {
- if (fgets(buf, sizeof(buf), fp) == NULL)
- minfree = 0;
- else
- minfree = atoi(buf);
+ if ((fp = fopen(path, "r"))) {
+ if (fgets(buf, sizeof(buf), fp)) minfree = atoi(buf);
(void)fclose(fp);
}
-
- needed = (dumpsize + kernelsize) / 1024;
- if (minfree > 0 && spacefree - needed < minfree) {
- syslog(LOG_WARNING,
- "no dump, not enough free space on device");
+ /* dumpsize, kernelsize, minfree, and spacefree are in bytes */
+ needed = dumpsize + kernelsize; /* minfree? not yet */
+ if (verbose) {
+ syslog(LOG_INFO, "dumpsize: %d", dumpsize);
+ syslog(LOG_INFO, "kernelsize: %d", kernelsize);
+ syslog(LOG_INFO, "minfree: %d", minfree);
+ syslog(LOG_INFO, "spacefree: %d", spacefree);
+ syslog(LOG_INFO, "needed: %d", needed);
+ }
+ /* space left (after the dump) must be greater than minfree */
+ if (spacefree < needed + minfree) {
+ syslog(LOG_WARNING, "no dump, not enough free space on device");
return (0);
}
- if (spacefree - needed < minfree)
- syslog(LOG_WARNING,
- "dump performed, but free space threshold crossed");
return (1);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603270904.KAA06468>
