From owner-freebsd-stable Wed Nov 15 4: 4:15 2000 Delivered-To: freebsd-stable@freebsd.org Received: from rina.r.dl.itc.u-tokyo.ac.jp (rina.r.dl.itc.u-tokyo.ac.jp [133.11.199.247]) by hub.freebsd.org (Postfix) with ESMTP id 5DFDC37B479; Wed, 15 Nov 2000 04:04:09 -0800 (PST) Received: from rina.r.dl.itc.u-tokyo.ac.jp (localhost [127.0.0.1]) by rina.r.dl.itc.u-tokyo.ac.jp (8.11.1+3.4Wpre/3.7W-rina.r-0.1-11.01.2000) with ESMTP id eAFC40J95501; Wed, 15 Nov 2000 21:04:02 +0900 (JST) Date: Wed, 15 Nov 2000 21:04:00 +0900 Message-ID: From: Seigo Tanimura To: steve@megahack.com, Jesse , Adrian Chadd Cc: freebsd-stable@freebsd.org Subject: Re: savecore snafu, dirname vs dirname() In-Reply-To: In your message of "Sun, 12 Nov 2000 20:56:08 -0600 (CST)" <14863.22600.507386.659982@catbert.megahack.com> References: <14863.22600.507386.659982@catbert.megahack.com> Cc: Seigo Tanimura 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) Organization: Digital Library Research Division, Information Techinology Centre, The University of Tokyo MIME-Version: 1.0 (generated by SEMI 1.13.7 - "Awazu") Content-Type: multipart/mixed; boundary="Multipart_Wed_Nov_15_21:04:00_2000-1" Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Multipart_Wed_Nov_15_21:04:00_2000-1 Content-Type: text/plain; charset=US-ASCII On Sun, 12 Nov 2000 20:56:08 -0600 (CST), Steven Farmer 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 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. --Multipart_Wed_Nov_15_21:04:00_2000-1 Content-Type: text/plain; type=patch; charset=US-ASCII Content-Disposition: attachment; filename="savecore.c.diff" Content-Transfer-Encoding: 7bit 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 @@ -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 { --Multipart_Wed_Nov_15_21:04:00_2000-1 Content-Type: text/plain; charset=US-ASCII -- Seigo Tanimura --Multipart_Wed_Nov_15_21:04:00_2000-1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message