Date: Sun, 5 May 2002 14:37:02 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 10846 for review Message-ID: <200205052137.g45Lb2V08325@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=10846 Change 10846 by peter@peter_daintree on 2002/05/05 14:36:14 IFC @10845 (pick up savecore changes etc) Affected files ... ... //depot/projects/ia64/bin/ps/fmt.c#4 integrate ... //depot/projects/ia64/etc/periodic/security/100.chksetuid#2 integrate ... //depot/projects/ia64/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml#24 integrate ... //depot/projects/ia64/sbin/mount_std/mount_std.c#5 integrate ... //depot/projects/ia64/sbin/savecore/Makefile#4 integrate ... //depot/projects/ia64/sbin/savecore/savecore.8#2 integrate ... //depot/projects/ia64/sbin/savecore/savecore.c#12 integrate ... //depot/projects/ia64/share/mk/bsd.kern.mk#2 integrate ... //depot/projects/ia64/sys/dev/sound/pci/ich.c#6 integrate ... //depot/projects/ia64/sys/i386/i386/i386dump.c#2 integrate ... //depot/projects/ia64/sys/i386/isa/ipl.s#3 integrate ... //depot/projects/ia64/sys/ia64/ia64/sal.c#6 integrate ... //depot/projects/ia64/sys/ia64/ia64/vm_machdep.c#8 integrate ... //depot/projects/ia64/sys/ia64/include/mca.h#3 integrate ... //depot/projects/ia64/sys/ia64/include/md_var.h#3 integrate ... //depot/projects/ia64/sys/kern/kern_clock.c#8 integrate ... //depot/projects/ia64/sys/kern/kern_sig.c#13 integrate ... //depot/projects/ia64/sys/kern/vfs_bio.c#13 integrate ... //depot/projects/ia64/sys/kern/vfs_subr.c#10 integrate ... //depot/projects/ia64/sys/kern/vfs_syscalls.c#15 integrate ... //depot/projects/ia64/sys/netinet/ip_dummynet.h#3 integrate ... //depot/projects/ia64/sys/sys/buf.h#7 integrate ... //depot/projects/ia64/sys/sys/kerneldump.h#2 integrate ... //depot/projects/ia64/sys/sys/time.h#8 integrate ... //depot/projects/ia64/sys/ufs/ufs/ufs_extern.h#4 integrate ... //depot/projects/ia64/sys/vm/uma_core.c#14 integrate ... //depot/projects/ia64/sys/vm/vm_map.c#15 integrate ... //depot/projects/ia64/sys/vm/vm_object.c#9 integrate ... //depot/projects/ia64/sys/vm/vm_object.h#3 integrate ... //depot/projects/ia64/sys/vm/vm_swap.c#7 integrate ... //depot/projects/ia64/tools/regression/usr.bin/make/Makefile#3 integrate ... //depot/projects/ia64/tools/regression/usr.bin/make/regress.sysvmatch.out#1 branch ... //depot/projects/ia64/usr.bin/make/str.c#4 integrate ... //depot/projects/ia64/usr.bin/xargs/xargs.1#4 integrate ... //depot/projects/ia64/usr.bin/xargs/xargs.c#10 integrate ... //depot/projects/ia64/usr.sbin/mergemaster/mergemaster.8#4 integrate ... //depot/projects/ia64/usr.sbin/mergemaster/mergemaster.sh#4 integrate ... //depot/projects/ia64/usr.sbin/pkg_install/create/perform.c#6 integrate ... //depot/projects/ia64/usr.sbin/pkg_install/info/main.c#5 integrate ... //depot/projects/ia64/usr.sbin/pkg_install/info/pkg_info.1#3 integrate ... //depot/projects/ia64/usr.sbin/pkg_install/info/show.c#5 integrate ... //depot/projects/ia64/usr.sbin/pkg_install/lib/plist.c#4 integrate ... //depot/projects/ia64/usr.sbin/ppp/bundle.c#5 integrate ... //depot/projects/ia64/usr.sbin/ppp/command.c#7 integrate Differences ... ==== //depot/projects/ia64/bin/ps/fmt.c#4 (text+ko) ==== @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/bin/ps/fmt.c,v 1.18 2002/05/02 05:46:37 jmallett Exp $"); +__FBSDID("$FreeBSD: src/bin/ps/fmt.c,v 1.19 2002/05/05 04:42:50 jmallett Exp $"); #if 0 #ifndef lint @@ -46,6 +46,7 @@ #include <sys/resource.h> #include <err.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -64,7 +65,8 @@ static char * shquote(char **argv) { - static long arg_max = -1; + long arg_max; + static size_t buf_size; size_t len; char **p, *dst, *src; static char *buf = NULL; @@ -72,8 +74,11 @@ if (buf == NULL) { if ((arg_max = sysconf(_SC_ARG_MAX)) == -1) errx(1, "sysconf _SC_ARG_MAX failed"); - if ((buf = malloc((size_t)(4 * arg_max) + 1)) == NULL) - err(1, "malloc"); + if (arg_max >= LONG_MAX / 4 || 4 * arg_max + 1 > SIZE_MAX) + errx(1, "sysconf _SC_ARG_MAX preposterously large"); + buf_size = 4 * arg_max + 1; + if ((buf = malloc(buf_size)) == NULL) + errx(1, "malloc failed"); } if (*argv == 0) { @@ -84,12 +89,12 @@ for (p = argv; (src = *p++) != 0; ) { if (*src == 0) continue; - len = (size_t)(4 * arg_max - (dst - buf)) / 4; + len = (buf_size - 1 - (dst - buf)) / 4; strvisx(dst, src, strlen(src) < len ? strlen(src) : len, VIS_NL | VIS_CSTYLE); while (*dst) dst++; - if ((4 * arg_max - (dst - buf)) / 4 > 0) + if ((buf_size - 1 - (dst - buf)) / 4 > 0) *dst++ = ' '; } /* Chop off trailing space */ ==== //depot/projects/ia64/etc/periodic/security/100.chksetuid#2 (text+ko) ==== @@ -24,7 +24,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/periodic/security/100.chksetuid,v 1.1 2001/12/07 23:57:38 cjc Exp $ +# $FreeBSD: src/etc/periodic/security/100.chksetuid,v 1.2 2002/05/05 00:59:37 cjc Exp $ # # If there is a global system configuration file, suck it in. @@ -52,7 +52,7 @@ find $mount -xdev -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ \( -perm -u+s -or -perm -g+s \) -print0 - done | xargs -0 -n 20 ls -liTd | sort +10 > ${TMP} + done | xargs -0 -n 20 ls -liTd | sed 's/^ *//' | sort +10 > ${TMP} if [ ! -f ${LOG}/setuid.today ]; then rc=1 @@ -64,7 +64,7 @@ then [ $rc -lt 1 ] && rc=1 echo "${host} setuid diffs:" - diff -w ${LOG}/setuid.today ${TMP} + diff -b ${LOG}/setuid.today ${TMP} mv ${LOG}/setuid.today ${LOG}/setuid.yesterday || rc=3 mv ${TMP} ${LOG}/setuid.today || rc=3 fi ==== //depot/projects/ia64/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml#24 (text+ko) ==== @@ -3,7 +3,7 @@ <corpauthor>The FreeBSD Project</corpauthor> - <pubdate>$FreeBSD: src/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml,v 1.338 2002/05/03 22:18:30 bmah Exp $</pubdate> + <pubdate>$FreeBSD: src/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml,v 1.339 2002/05/05 12:05:08 ue Exp $</pubdate> <copyright> <year>2000</year> @@ -802,7 +802,7 @@ <varname>kern.polling.user_frac</varname> sysctl indicating the percentage of CPU time to be reserved for userland. The devices initially supporting polling are &man.dc.4;, - &man.fxp.4;, &man.rl.4, and &man.sis.4;. More details can be found in + &man.fxp.4;, &man.rl.4;, and &man.sis.4;. More details can be found in the &man.polling.4; manual page. &merged;</para> <para arch="i386">The packet-forwarding performance of certain ==== //depot/projects/ia64/sbin/mount_std/mount_std.c#5 (text+ko) ==== @@ -43,7 +43,7 @@ #ifndef lint static const char rcsid[] = - "$FreeBSD: src/sbin/mount_std/mount_std.c,v 1.14 2002/05/02 20:52:04 mux Exp $"; + "$FreeBSD: src/sbin/mount_std/mount_std.c,v 1.15 2002/05/05 10:08:04 mux Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -53,6 +53,7 @@ #include <err.h> #include <errno.h> #include <stdio.h> +#include <signal.h> #include <stdlib.h> #include <string.h> #include <sysexits.h> @@ -65,9 +66,17 @@ { NULL } }; -static void usage(void) __dead2; static const char *fsname; +static volatile sig_atomic_t caughtsig; + +static void usage(void) __dead2; +static void +catchsig(int s) +{ + caughtsig = 1; +} + int main(argc, argv) int argc; @@ -132,14 +141,26 @@ iov[2].iov_len = sizeof("fstype"); iov[3].iov_base = mntpath; iov[3].iov_len = strlen(mntpath) + 1; + + /* + * nmount(2) would kill us with SIGSYS if the kernel doesn't have it. + * This design bug is inconvenient. We must catch the signal and not + * just ignore it because of a plain bug: nmount(2) would return + * EINVAL instead of the correct ENOSYS if the kernel doesn't have it + * and we don't let the signal kill us. EINVAL is too ambiguous. + * This bug in 4.4BSD-Lite1 was fixed in 4.4BSD-Lite2 but is still in + * FreeBSD-5.0. + */ + signal(SIGSYS, catchsig); error = nmount(iov, 4, mntflags); + signal(SIGSYS, SIG_DFL); /* * Try with the old mount syscall in the case * this filesystem has not been converted yet, * or the user didn't recompile his kernel. */ - if (error && errno == EOPNOTSUPP) + if (error && (errno == EOPNOTSUPP || errno == ENOSYS || caughtsig)) error = mount(vfc.vfc_name, mntpath, mntflags, NULL); if (error) ==== //depot/projects/ia64/sbin/savecore/Makefile#4 (text+ko) ==== @@ -1,7 +1,8 @@ -# $FreeBSD: src/sbin/savecore/Makefile,v 1.9 2002/04/01 08:27:19 phk Exp $ +# $FreeBSD: src/sbin/savecore/Makefile,v 1.10 2002/05/05 01:04:00 fenner Exp $ PROG= savecore WARNS= 4 -NOMAN= sorry, not yet. -LDADD= -lmd +MAN8= savecore.8 +DPADD+= ${LIBZ} +LDADD+= -lz .include <bsd.prog.mk> ==== //depot/projects/ia64/sbin/savecore/savecore.8#2 (text+ko) ==== @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" From: @(#)savecore.8 8.1 (Berkeley) 6/5/93 -.\" $FreeBSD: src/sbin/savecore/savecore.8,v 1.15 2001/10/28 16:41:56 n_hibma Exp $ +.\" $FreeBSD: src/sbin/savecore/savecore.8,v 1.16 2002/05/05 01:04:00 fenner Exp $ .\" .Dd September 23, 1994 .Dt SAVECORE 8 @@ -43,12 +43,14 @@ .Fl c .Nm .Op Fl fkvz -.Op Fl N Ar system -.Ar directory +.Op Ar directory Op Ar device ... .Sh DESCRIPTION .Nm Savecore -copies the currently running kernel and its associated core dump into +copies a core dump into .Fa directory , +or the current working directory if no +.Fa directory +argument is given, and enters a reboot message and information about the core dump into the system log. .Pp @@ -59,15 +61,9 @@ .Nm will ignore it. .It Fl f -Force a dump to be taken even if the dump doesn't appear correct or there -is insufficient disk space. +Force a dump to be taken even if the dump was cleared. .It Fl k Do not clear the dump after saving it. -.It Fl N -Use -.Ar system -as the kernel instead of the running kernel (as determined from -.Xr getbootfile 3 ) . .It Fl v Print out some additional debugging information. .It Fl z @@ -76,12 +72,17 @@ .El .Pp .Nm Savecore -checks the core dump in various ways to make sure that it is current and -that it corresponds to the currently running system. +looks for dumps on each device specified by the +.Ar device +argument(s), or on each device in +.Pa /etc/fstab +marked as "dump" or "swap". +.Nm Savecore +checks the core dump in various ways to make sure that it is complete. If it passes these checks, it saves the core image in .Ar directory Ns Pa /vmcore.# -and the system in -.Ar directory Ns Pa /kernel.# +and information about the core in +.Ar directory Ns Pa /info.# The ``#'' is the number from the first line of the file .Ar directory Ns Pa /bounds , and it is incremented and stored back into the file each time @@ -111,7 +112,7 @@ (see .Xr rc 8 ) . .Sh BUGS -The minfree code does not consider the effect of compression. +The minfree code does not consider the effect of compression or sparse files. .Sh SEE ALSO .Xr gzip 1 , .Xr getbootfile 3 , ==== //depot/projects/ia64/sbin/savecore/savecore.c#12 (text+ko) ==== @@ -31,35 +31,68 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * Copyright (c) 1986, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sbin/savecore/savecore.c,v 1.58 2002/05/04 10:36:35 mux Exp $"); +__FBSDID("$FreeBSD: src/sbin/savecore/savecore.c,v 1.59 2002/05/05 01:04:00 fenner Exp $"); -#include <sys/types.h> +#include <sys/param.h> #include <sys/disk.h> #include <sys/kerneldump.h> #include <sys/param.h> #include <sys/mount.h> #include <sys/stat.h> -#include <err.h> #include <errno.h> #include <fcntl.h> #include <fstab.h> -#include <md5.h> #include <paths.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <syslog.h> #include <time.h> #include <unistd.h> -int clear, force, keep, verbose; /* flags */ -int nfound, nsaved, nerr; /* statistics */ +int compress, clear, force, keep, verbose; /* flags */ +int nfound, nsaved, nerr; /* statistics */ + +extern FILE *zopen(const char *, const char *); static void printheader(FILE *f, const struct kerneldumpheader *h, const char *device, - const char *md5) + int bounds) { uint64_t dumplen; time_t t; @@ -77,10 +110,51 @@ fprintf(f, " Hostname: %s\n", h->hostname); fprintf(f, " Versionstring: %s", h->versionstring); fprintf(f, " Panicstring: %s\n", h->panicstring); - fprintf(f, " MD5: %s\n", md5); + fprintf(f, " Bounds: %d\n", bounds); fflush(f); } +static int +getbounds(void) { + FILE *fp; + char buf[6]; + int ret; + + ret = 0; + + if ((fp = fopen("bounds", "r")) == NULL) { + syslog(LOG_WARNING, "unable to open bounds file, using 0"); + goto newfile; + } + + if (fgets(buf, sizeof buf, fp) == NULL) { + syslog(LOG_WARNING, "unable to read from bounds, using 0"); + fclose(fp); + goto newfile; + } + + 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"); + +newfile: + + if ((fp = fopen("bounds", "w")) == NULL) { + syslog(LOG_WARNING, "unable to write to bounds file: %m"); + goto done; + } + + if (verbose) + printf("bounds number: %d\n", ret); + + fprintf(fp, "%d\n", (ret + 1)); + fclose(fp); + +done: + return (ret); +} + /* * Check that sufficient space is available on the disk that holds the * save directory. @@ -89,19 +163,14 @@ check_space(char *savedir, off_t dumpsize) { FILE *fp; - const char *tkernel; - off_t minfree, spacefree, totfree, kernelsize, needed; - struct stat st; + off_t minfree, spacefree, totfree, needed; struct statfs fsbuf; char buf[100], path[MAXPATHLEN]; - tkernel = getbootfile(); - if (stat(tkernel, &st) < 0) - err(1, "%s", tkernel); - kernelsize = st.st_blocks * S_BLKSIZE; - - if (statfs(savedir, &fsbuf) < 0) - err(1, "%s", savedir); + 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; @@ -116,71 +185,92 @@ (void)fclose(fp); } - needed = (dumpsize + kernelsize) / 1024; + needed = dumpsize / 1024 + 2; /* 2 for info file */ if (((minfree > 0) ? spacefree : totfree) - needed < minfree) { - warnx("no dump, not enough free space on device" - " (%lld available, need %lld)", + syslog(LOG_WARNING, + "no dump, not enough free space on device (%lld available, need %lld)", (long long)(minfree > 0 ? spacefree : totfree), (long long)needed); return (0); } if (spacefree - needed < 0) - warnx("dump performed, but free space threshold crossed"); + syslog(LOG_WARNING, + "dump performed, but free space threshold crossed"); return (1); } - +#define BLOCKSIZE (1<<12) +#define BLOCKMASK (~(BLOCKSIZE-1)) static void DoFile(char *savedir, const char *device) { struct kerneldumpheader kdhf, kdhl; - char buf[BUFSIZ]; - struct stat sb; - off_t mediasize, dumpsize, firsthd, lasthd; - char *md5; - FILE *info; - int fd, fdcore, fdinfo, error, wl; + char buf[1024 * 1024]; + off_t mediasize, dumpsize, firsthd, lasthd, dmpcnt; + FILE *info, *fp; + int fd, fdinfo, error, wl; + int nr, nw, hs, he; + int bounds; u_int sectorsize; + mode_t oumask; + dmpcnt = 0; + mediasize = 0; + if (verbose) - printf("Checking for kernel dump on device %s\n", device); + printf("checking for kernel dump on device %s\n", device); - mediasize = 0; fd = open(device, O_RDWR); if (fd < 0) { - warn("%s", device); + syslog(LOG_ERR, "%s: %m", device); return; } error = ioctl(fd, DIOCGMEDIASIZE, &mediasize); if (!error) error = ioctl(fd, DIOCGSECTORSIZE, §orsize); if (error) { - warn("couldn't find media and/or sector size of %s", device); + syslog(LOG_ERR, + "couldn't find media and/or sector size of %s: %m", device); goto closefd; } if (verbose) { - printf("Mediasize = %lld\n", (long long)mediasize); - printf("Sectorsize = %u\n", sectorsize); + printf("mediasize = %lld\n", (long long)mediasize); + printf("sectorsize = %u\n", sectorsize); } lasthd = mediasize - sectorsize; lseek(fd, lasthd, SEEK_SET); error = read(fd, &kdhl, sizeof kdhl); if (error != sizeof kdhl) { - warn("error reading last dump header at offset %lld in %s", + syslog(LOG_ERR, + "error reading last dump header at offset %lld in %s: %m", (long long)lasthd, device); goto closefd; } if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic)) { if (verbose) - warnx("magic mismatch on last dump header on %s", + printf("magic mismatch on last dump header on %s\n", device); - goto closefd; + + if (force == 0) + goto closefd; + + if (memcmp(kdhl.magic, KERNELDUMPMAGIC_CLEARED, + sizeof kdhl.magic) == 0) { + if (verbose) + printf("forcing magic on %s\n", device); + memcpy(kdhl.magic, KERNELDUMPMAGIC, + sizeof kdhl.magic); + } else { + syslog(LOG_ERR, "unable to force dump - bad magic"); + goto closefd; + } } if (dtoh32(kdhl.version) != KERNELDUMPVERSION) { - warnx("unknown version (%d) in last dump header on %s", + syslog(LOG_ERR, + "unknown version (%d) in last dump header on %s", dtoh32(kdhl.version), device); goto closefd; } @@ -190,7 +280,8 @@ goto nuke; if (kerneldump_parity(&kdhl)) { - warnx("parity error on last dump header on %s", device); + syslog(LOG_ERR, + "parity error on last dump header on %s", device); nerr++; goto closefd; } @@ -199,109 +290,170 @@ lseek(fd, firsthd, SEEK_SET); error = read(fd, &kdhf, sizeof kdhf); if (error != sizeof kdhf) { - warn("error reading first dump header at offset %lld in %s", + syslog(LOG_ERR, + "error reading first dump header at offset %lld in %s: %m", (long long)firsthd, device); nerr++; goto closefd; } if (memcmp(&kdhl, &kdhf, sizeof kdhl)) { - warn("first and last dump headers disagree on %s", device); + syslog(LOG_ERR, + "first and last dump headers disagree on %s", device); nerr++; goto closefd; } - md5 = MD5Data((unsigned char *)&kdhl, sizeof kdhl, NULL); - sprintf(buf, "%s.info", md5); - /* - * See if the dump has been saved already. Don't save the dump - * again, unless 'force' is in effect. - */ - if (stat(buf, &sb) == 0) { - if (!force) { - if (verbose) - printf("Dump on device %s already saved\n", - device); - goto closefd; - } - } else if (errno != ENOENT) { - warn("error while checking for pre-saved core file"); - nerr++; - goto closefd; - } + if (kdhl.panicstring[0]) + syslog(LOG_ALERT, "reboot after panic: %s", kdhl.panicstring); + else + syslog(LOG_ALERT, "reboot"); + if (verbose) + printf("Checking for available free space\n"); if (!check_space(savedir, dumpsize)) { nerr++; goto closefd; } + + bounds = getbounds(); + + sprintf(buf, "info.%d", bounds); + /* * Create or overwrite any existing files. */ fdinfo = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fdinfo < 0) { - warn("%s", buf); + syslog(LOG_ERR, "%s: %m", buf); nerr++; goto closefd; } - sprintf(buf, "%s.core", md5); - fdcore = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0600); - if (fdcore < 0) { - warn("%s", buf); + oumask = umask(S_IRWXG|S_IRWXO); /* Restrict access to the core file.*/ + if (compress) { + sprintf(buf, "vmcore.%d.gz", bounds); + fp = zopen(buf, "w"); + } else { + sprintf(buf, "vmcore.%d", bounds); + fp = fopen(buf, "w"); + } + if (fp == NULL) { + syslog(LOG_ERR, "%s: %m", buf); close(fdinfo); nerr++; goto closefd; } + (void)umask(oumask); + info = fdopen(fdinfo, "w"); if (verbose) - printheader(stdout, &kdhl, device, md5); + printheader(stdout, &kdhl, device, bounds); - printf("Saving dump to file %s\n", buf); + printheader(info, &kdhl, device, bounds); + fclose(info); - printheader(info, &kdhl, device, md5); + syslog(LOG_NOTICE, "writing %score to %s", + compress ? "compressed " : "", buf); while (dumpsize > 0) { wl = sizeof(buf); if (wl > dumpsize) wl = dumpsize; - error = read(fd, buf, wl); - if (error != wl) { - warn("read error on %s", device); + nr = read(fd, buf, wl); + if (nr != wl) { + if (nr == 0) + syslog(LOG_WARNING, + "WARNING: EOF on dump device"); + else + syslog(LOG_ERR, "read error on %s: %m", device); nerr++; goto closeall; } - error = write(fdcore, buf, wl); - if (error != wl) { - warn("write error on %s.core file", md5); + if (compress) { + nw = fwrite(buf, 1, wl, fp); + } else { + for (nw = 0; nw < nr; nw = he) { + /* find a contiguous block of zeroes */ + for (hs = nw; hs < nr; hs += BLOCKSIZE) { + for (he = hs; he < nr && buf[he] == 0; ++he) + /* nothing */ ; + /* is the hole long enough to matter? */ + if (he >= hs + BLOCKSIZE) + break; + } + + /* back down to a block boundary */ + he &= BLOCKMASK; + + /* + * 1) Don't go beyond the end of the buffer. + * 2) If the end of the buffer is less than + * BLOCKSIZE bytes away, we're at the end + * of the file, so just grab what's left. + */ + if (hs + BLOCKSIZE > nr) + hs = he = nr; + + /* + * At this point, we have a partial ordering: + * nw <= hs <= he <= nr + * If hs > nw, buf[nw..hs] contains non-zero data. + * If he > hs, buf[hs..he] is all zeroes. + */ + if (hs > nw) + if (fwrite(buf + nw, hs - nw, 1, fp) != 1) + break; + if (he > hs) + if (fseek(fp, he - hs, SEEK_CUR) == -1) + break; + } + } + if (nw != wl) { + syslog(LOG_ERR, + "write error on vmcore.%d file: %m", bounds); + syslog(LOG_WARNING, + "WARNING: vmcore may be incomplete"); nerr++; goto closeall; } + if (verbose) { + dmpcnt += wl; + printf("%llu\r", dmpcnt); + fflush(stdout); + } dumpsize -= wl; } + if (verbose) + printf("\n"); + + if (fclose(fp) < 0) { + syslog(LOG_ERR, "error on vmcore.%d: %m", bounds); + nerr++; + goto closeall; + } nsaved++; - close(fdinfo); - close(fdcore); if (verbose) - printf("Dump saved\n"); + printf("dump saved\n"); - nuke: +nuke: if (clear || !keep) { if (verbose) - printf("Clearing dump header\n"); - memset(&kdhl, 0, sizeof kdhl); + printf("clearing dump header\n"); + memcpy(kdhl.magic, KERNELDUMPMAGIC_CLEARED, sizeof kdhl.magic); lseek(fd, lasthd, SEEK_SET); error = write(fd, &kdhl, sizeof kdhl); if (error != sizeof kdhl) - warn("error while clearing the dump header"); + syslog(LOG_ERR, + "error while clearing the dump header: %m"); } close(fd); return; - closeall: - close(fdinfo); - close(fdcore); +closeall: + fclose(fp); - closefd: +closefd: close(fd); } @@ -319,9 +471,13 @@ struct fstab *fsp; char *savedir; + openlog("savecore", LOG_PERROR, LOG_DAEMON); + savedir = strdup("."); - if (savedir == NULL) - errx(1, "Cannot allocate memory"); + if (savedir == NULL) { + syslog(LOG_ERR, "Cannot allocate memory"); + exit(1); + } while ((ch = getopt(argc, argv, "cdfkN:vz")) != -1) switch(ch) { case 'c': @@ -336,9 +492,11 @@ case 'f': force = 1; break; + case 'z': + compress = 1; + break; case 'd': /* Obsolete */ case 'N': - case 'z': case '?': default: usage(); @@ -347,8 +505,10 @@ argv += optind; if (argc >= 1) { error = chdir(argv[0]); - if (error) - err(1, "chdir(%s)", argv[0]); + if (error) { + syslog(LOG_ERR, "chdir(%s): %m", argv[0]); + exit(1); + } savedir = argv[0]; argc--; argv++; @@ -370,12 +530,12 @@ /* Emit minimal output. */ if (nfound == 0) - printf("No dumps found\n"); + syslog(LOG_WARNING, "no dumps found"); else if (nsaved == 0) { if (nerr != 0) - printf("Unsaved dumps found but not saved\n"); + syslog(LOG_WARNING, "unsaved dumps found but not saved"); else - printf("No unsaved dumps found\n"); + syslog(LOG_WARNING, "no unsaved dumps found"); } return (0); ==== //depot/projects/ia64/share/mk/bsd.kern.mk#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/share/mk/bsd.kern.mk,v 1.24 2001/09/10 06:23:33 peter Exp $ +# $FreeBSD: src/share/mk/bsd.kern.mk,v 1.25 2002/05/04 20:07:33 obrien Exp $ # # Warning flags for compiling the kernel and components of the kernel. @@ -59,6 +59,4 @@ # GCC 3.0 and above like to do certain optimizations based on the # assumption that the program is linked against libc. Stop this. # -.ifdef GCC3 CFLAGS+= -ffreestanding -.endif ==== //depot/projects/ia64/sys/dev/sound/pci/ich.c#6 (text+ko) ==== @@ -32,7 +32,7 @@ #include <pci/pcireg.h> #include <pci/pcivar.h> -SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/ich.c,v 1.20 2002/04/15 20:42:40 jhb Exp $"); +SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/ich.c,v 1.21 2002/05/05 15:37:09 orion Exp $"); /* -------------------------------------------------------------------- */ @@ -762,9 +762,6 @@ ichchan_trigger(0, &sc->ch[i], PCMTRIG_ABORT); } } - - /* ACLINK shut off */ - ich_wr(sc,ICH_REG_GLOB_CNT, ICH_GLOB_CTL_SHUT, 4); return 0; } ==== //depot/projects/ia64/sys/i386/i386/i386dump.c#2 (text+ko) ==== @@ -32,12 +32,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/i386/i386dump.c,v 1.2 2002/04/03 07:24:07 marcel Exp $ + * $FreeBSD: src/sys/i386/i386/i386dump.c,v 1.3 2002/05/04 17:45:48 fenner Exp $ */ #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> +#include <sys/cons.h> #include <sys/kernel.h> #include <sys/kerneldump.h> #include <vm/vm.h> @@ -56,6 +57,7 @@ u_int count, left, u; void *va; int i, mb; + int c; printf("Dumping %u MB\n", Maxmem / (1024*1024 / PAGE_SIZE)); @@ -104,6 +106,11 @@ count += left; dumplo += left * PAGE_SIZE; addr += left * PAGE_SIZE; + if ((c = cncheckc()) == 0x03) { + printf("\nDump aborted.\n"); + return; + } else if (c != -1) + printf("[CTRL-C to abort] "); } if (i) printf("\nDump failed writing data (%d)\n", i); ==== //depot/projects/ia64/sys/i386/isa/ipl.s#3 (text+ko) ==== @@ -36,7 +36,7 @@ * * @(#)ipl.s * - * $FreeBSD: src/sys/i386/isa/ipl.s,v 1.53 2002/03/29 16:35:25 jake Exp $ + * $FreeBSD: src/sys/i386/isa/ipl.s,v 1.54 2002/05/05 03:19:48 bde Exp $ */ @@ -57,13 +57,19 @@ doreti: FAKE_MCOUNT(bintr) /* init "from" bintr -> doreti */ doreti_next: - /* Check if ASTs can be handled now. */ + /* + * Check if ASTs can be handled now. PSL_VM must be checked first + * since segment registers only have an RPL in non-VM86 mode. + */ + testl $PSL_VM,TF_EFLAGS(%esp) /* are we in vm86 mode? */ + jz doreti_notvm86 + cmpl $1,in_vm86call /* are we in a vm86 call? */ + jne doreti_ast /* can handle ASTs now if not */ + jmp doreti_exit + +doreti_notvm86: testb $SEL_RPL_MASK,TF_CS(%esp) /* are we in user mode? */ - jne doreti_ast /* yes, do it now. */ - testl $PSL_VM,TF_EFLAGS(%esp) /* kernel mode */ - je doreti_exit /* and not VM86 mode, defer */ - cmpl $1,in_vm86call /* are we in a VM86 call? */ - je doreti_exit /* no, defer */ + jz doreti_exit /* can't handle ASTs now if not */ doreti_ast: /* ==== //depot/projects/ia64/sys/ia64/ia64/sal.c#6 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/ia64/ia64/sal.c,v 1.8 2002/04/26 19:33:20 marcel Exp $ + * $FreeBSD: src/sys/ia64/ia64/sal.c,v 1.9 2002/05/05 08:18:42 marcel Exp $ >>> TRUNCATED FOR MAIL (1000 lines) <<< To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205052137.g45Lb2V08325>