Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Nov 2000 18:59:26 +0100
From:      Adrian Chadd <adrian@freebsd.org>
To:        jkh@freebsd.org
Cc:        freebsd-stable@freebsd.org
Subject:   [tanimura@r.dl.itc.u-tokyo.ac.jp: Re: savecore snafu, dirname vs dirname()]
Message-ID:  <20001115185926.B6612@roaming.cacheboy.net>

next in thread | raw e-mail | index | archive | help

Hrm. I should MFC this too, or savecore won't work in RELENG_4. :)

Mr jkh, can I unbreak RELENG_4 ?


Adrian

----- Forwarded message from Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp> -----

Date: Wed, 15 Nov 2000 21:04:00 +0900
From: Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp>
To: steve@megahack.com, Jesse <j@lumiere.net>,
   Adrian Chadd <adrian@FreeBSD.org>
Subject: Re: savecore snafu, dirname vs dirname()
Cc: Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp>
User-Agent: Wanderlust/1.1.1 (Purple Rain) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) MULE XEmacs/21.1 (patch 12) (Channel Islands) (i386--freebsd)

On Sun, 12 Nov 2000 20:56:08 -0600 (CST),
  Steven Farmer <steve@megahack.com> said:

Steven> Here's wierd one.  It seems to be a mixup between "char *dirname" in
Steven> savecore.c and dirname() in libc...

Steven> After today's cvsup/build/install, savecore dies during the reboot:

Steven>       pid 133 (savecore), uid 0: exited on signal 10 (core dumped)
(snip)
Steven> /usr/libexec/elf/ld: Warning: size of symbol `dirname' changed from 4 to 206 in dirname.o
Steven> /usr/libexec/elf/ld: Warning: type of symbol `dirname' changed from 1 to 2 in dirname.o


On Wed, 15 Nov 2000 03:28:21 -0800 (PST),
  Jesse <j@lumiere.net> said:

Jesse> I cvsup'd today to 4.2-BETA and did a make world and recompiled my kernel.
Jesse> Everything appears to be working fine, except for savecore.

Jesse> When savecore is run (either from rc or commandline) with a directory
Jesse> argument (required) it core dumps reporting a Bus Error.

Jesse> # savecore /var/crash
Jesse> Bus error (core dumped)

I have seen exactly the same problem in -current, which was fixed in
src/sbin/savecore/savecore.c rev 1.34. Attached is the patch to fix
the bug.


Index: savecore/savecore.c
===================================================================
RCS file: /home/ncvs/src/sbin/savecore/savecore.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- savecore/savecore.c	2000/05/09 22:20:14	1.33
+++ savecore/savecore.c	2000/09/03 07:02:00	1.34
@@ -42,7 +42,7 @@
 static char sccsid[] = "@(#)savecore.c	8.3 (Berkeley) 1/2/94";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: src/sbin/savecore/savecore.c,v 1.33 2000/05/09 22:20:14 ps Exp $";
+  "$FreeBSD: src/sbin/savecore/savecore.c,v 1.34 2000/09/03 07:02:00 peter Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -108,7 +108,7 @@
 int	dumpsize;			/* amount of memory dumped */
 
 char	*kernel;
-char	*dirname;			/* directory to save dumps in */
+char	*savedir;			/* directory to save dumps in */
 char	*ddname;			/* name of dump device */
 dev_t	dumpdev;			/* dump device */
 int	dumpfd;				/* read/write descriptor on char dev */
@@ -175,7 +175,7 @@
 	if (!clear) {
 		if (argc != 1 && argc != 2)
 			usage();
-		dirname = argv[0];
+		savedir = argv[0];
 	}
 	if (argc == 2)
 		kernel = argv[1];
@@ -348,7 +348,7 @@
 	 * Get the current number and update the bounds file.  Do the update
 	 * now, because may fail later and don't want to overwrite anything.
 	 */
-	(void)snprintf(path, sizeof(path), "%s/bounds", dirname);
+	(void)snprintf(path, sizeof(path), "%s/bounds", savedir);
 	if ((fp = fopen(path, "r")) == NULL)
 		goto err1;
 	if (fgets(buf, sizeof(buf), fp) == NULL) {
@@ -369,7 +369,7 @@
 	/* Create the core file. */
 	oumask = umask(S_IRWXG|S_IRWXO); /* Restrict access to the core file.*/
 	(void)snprintf(path, sizeof(path), "%s/vmcore.%d%s",
-	    dirname, bounds, compress ? ".Z" : "");
+	    savedir, bounds, compress ? ".Z" : "");
 	if (compress) {
 		if ((fp = zopen(path, "w", 0)) == NULL) {
 			syslog(LOG_ERR, "%s: %s", path, strerror(errno));
@@ -420,7 +420,7 @@
 	/* Copy the kernel. */
 	ifd = Open(kernel ? kernel : getbootfile(), O_RDONLY);
 	(void)snprintf(path, sizeof(path), "%s/kernel.%d%s",
-	    dirname, bounds, compress ? ".Z" : "");
+	    savedir, bounds, compress ? ".Z" : "");
 	if (compress) {
 		if ((fp = zopen(path, "w", 0)) == NULL) {
 			syslog(LOG_ERR, "%s: %s", path, strerror(errno));
@@ -541,14 +541,14 @@
 	}
 	kernelsize = st.st_blocks * S_BLKSIZE;
 
-	if (statfs(dirname, &fsbuf) < 0) {
-		syslog(LOG_ERR, "%s: %m", dirname);
+	if (statfs(savedir, &fsbuf) < 0) {
+		syslog(LOG_ERR, "%s: %m", savedir);
 		exit(1);
 	}
  	spacefree = ((off_t) fsbuf.f_bavail * fsbuf.f_bsize) / 1024;
 	totfree = ((off_t) fsbuf.f_bfree * fsbuf.f_bsize) / 1024;
 
-	(void)snprintf(path, sizeof(path), "%s/minfree", dirname);
+	(void)snprintf(path, sizeof(path), "%s/minfree", savedir);
 	if ((fp = fopen(path, "r")) == NULL)
 		minfree = 0;
 	else {



-- 
Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp> <tanimura@FreeBSD.org>


----- End forwarded message -----

-- 
Adrian Chadd			"Programming is like sex:
<adrian@freebsd.org>		   One mistake and you have to support for
				    a lifetime." -- rec.humor.funny



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001115185926.B6612>