2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2002 Poul-Henning Kamp
5 * Copyright (c) 2002 Networks Associates Technology, Inc.
8 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
9 * and NAI Labs, the Security Research Division of Network Associates, Inc.
10 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
11 * DARPA CHATS research program.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. The names of the authors may not be used to endorse or promote
22 * products derived from this software without specific prior written
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * Copyright (c) 1986, 1992, 1993
38 * The Regents of the University of California. All rights reserved.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 #include <sys/cdefs.h>
66 __FBSDID("$FreeBSD$");
68 #include <sys/param.h>
70 #include <sys/kerneldump.h>
71 #include <sys/mount.h>
89 /* The size of the buffer used for I/O. */
90 #define BUFFERSIZE (1024*1024)
94 #define STATUS_UNKNOWN 2
96 static int checkfor, compress, clear, force, keep, verbose; /* flags */
97 static int nfound, nsaved, nerr; /* statistics */
100 extern FILE *zopen(const char *, const char *);
102 static sig_atomic_t got_siginfo;
103 static void infohandler(int);
106 printheader(xo_handle_t *xo, const struct kerneldumpheader *h,
107 const char *device, int bounds, const int status)
111 const char *stat_str;
112 const char *comp_str;
115 xo_emit_h(xo, "{Lwc:Dump header from device}{:dump_device/%s}\n",
117 xo_emit_h(xo, "{P: }{Lwc:Architecture}{:architecture/%s}\n",
120 "{P: }{Lwc:Architecture Version}{:architecture_version/%u}\n",
121 dtoh32(h->architectureversion));
122 dumplen = dtoh64(h->dumplength);
123 xo_emit_h(xo, "{P: }{Lwc:Dump Length}{:dump_length_bytes/%lld}\n",
125 xo_emit_h(xo, "{P: }{Lwc:Blocksize}{:blocksize/%d}\n",
126 dtoh32(h->blocksize));
127 switch (h->compression) {
128 case KERNELDUMP_COMP_NONE:
131 case KERNELDUMP_COMP_GZIP:
134 case KERNELDUMP_COMP_ZSTD:
141 xo_emit_h(xo, "{P: }{Lwc:Compression}{:compression/%s}\n", comp_str);
142 t = dtoh64(h->dumptime);
143 xo_emit_h(xo, "{P: }{Lwc:Dumptime}{:dumptime/%s}", ctime(&t));
144 xo_emit_h(xo, "{P: }{Lwc:Hostname}{:hostname/%s}\n", h->hostname);
145 xo_emit_h(xo, "{P: }{Lwc:Magic}{:magic/%s}\n", h->magic);
146 xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}",
148 xo_emit_h(xo, "{P: }{Lwc:Panic String}{:panic_string/%s}\n",
150 xo_emit_h(xo, "{P: }{Lwc:Dump Parity}{:dump_parity/%u}\n", h->parity);
151 xo_emit_h(xo, "{P: }{Lwc:Bounds}{:bounds/%d}\n", bounds);
161 stat_str = "unknown";
164 xo_emit_h(xo, "{P: }{Lwc:Dump Status}{:dump_status/%s}\n", stat_str);
176 * If we are just checking, then we haven't done a chdir to the dump
177 * directory and we should not try to read a bounds file.
184 if ((fp = fopen("bounds", "r")) == NULL) {
186 printf("unable to open bounds file, using 0\n");
190 if (fgets(buf, sizeof buf, fp) == NULL) {
192 syslog(LOG_WARNING, "bounds file is empty, using 0");
194 syslog(LOG_WARNING, "bounds file: %s", strerror(errno));
200 ret = (int)strtol(buf, NULL, 10);
201 if (ret == 0 && (errno == EINVAL || errno == ERANGE))
202 syslog(LOG_WARNING, "invalid value found in bounds, using 0");
208 writebounds(int bounds)
212 if ((fp = fopen("bounds", "w")) == NULL) {
213 syslog(LOG_WARNING, "unable to write to bounds file: %m");
218 printf("bounds number: %d\n", bounds);
220 fprintf(fp, "%d\n", bounds);
225 writekey(const char *keyname, uint8_t *dumpkey, uint32_t dumpkeysize)
229 fd = open(keyname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
231 syslog(LOG_ERR, "Unable to open %s to write the key: %m.",
236 if (write(fd, dumpkey, dumpkeysize) != (ssize_t)dumpkeysize) {
237 syslog(LOG_ERR, "Unable to write the key to %s: %m.", keyname);
247 file_size(const char *path)
251 /* Ignore all errors, those file may not exists. */
252 if (stat(path, &sb) == -1)
258 saved_dump_size(int bounds)
260 static char path[PATH_MAX];
265 (void)snprintf(path, sizeof(path), "info.%d", bounds);
266 dumpsize += file_size(path);
267 (void)snprintf(path, sizeof(path), "vmcore.%d", bounds);
268 dumpsize += file_size(path);
269 (void)snprintf(path, sizeof(path), "vmcore.%d.gz", bounds);
270 dumpsize += file_size(path);
271 (void)snprintf(path, sizeof(path), "vmcore.%d.zst", bounds);
272 dumpsize += file_size(path);
273 (void)snprintf(path, sizeof(path), "textdump.tar.%d", bounds);
274 dumpsize += file_size(path);
275 (void)snprintf(path, sizeof(path), "textdump.tar.%d.gz", bounds);
276 dumpsize += file_size(path);
282 saved_dump_remove(int bounds)
284 static char path[PATH_MAX];
286 (void)snprintf(path, sizeof(path), "info.%d", bounds);
288 (void)snprintf(path, sizeof(path), "vmcore.%d", bounds);
290 (void)snprintf(path, sizeof(path), "vmcore.%d.gz", bounds);
292 (void)snprintf(path, sizeof(path), "vmcore.%d.zst", bounds);
294 (void)snprintf(path, sizeof(path), "textdump.tar.%d", bounds);
296 (void)snprintf(path, sizeof(path), "textdump.tar.%d.gz", bounds);
301 symlinks_remove(void)
304 (void)unlink("info.last");
305 (void)unlink("key.last");
306 (void)unlink("vmcore.last");
307 (void)unlink("vmcore.last.gz");
308 (void)unlink("vmcore.last.zst");
309 (void)unlink("vmcore_encrypted.last");
310 (void)unlink("vmcore_encrypted.last.gz");
311 (void)unlink("textdump.tar.last");
312 (void)unlink("textdump.tar.last.gz");
316 * Check that sufficient space is available on the disk that holds the
320 check_space(const char *savedir, off_t dumpsize, int bounds)
323 off_t available, minfree, spacefree, totfree, needed;
327 if (statfs(".", &fsbuf) < 0) {
328 syslog(LOG_ERR, "%s: %m", savedir);
331 spacefree = ((off_t) fsbuf.f_bavail * fsbuf.f_bsize) / 1024;
332 totfree = ((off_t) fsbuf.f_bfree * fsbuf.f_bsize) / 1024;
334 if ((fp = fopen("minfree", "r")) == NULL)
337 if (fgets(buf, sizeof(buf), fp) == NULL)
343 minfree = strtoll(buf, &endp, 10);
344 if (minfree == 0 && errno != 0)
347 while (*endp != '\0' && isspace(*endp))
349 if (*endp != '\0' || minfree < 0)
354 "`minfree` didn't contain a valid size "
355 "(`%s`). Defaulting to 0", buf);
360 available = minfree > 0 ? spacefree - minfree : totfree;
361 needed = dumpsize / 1024 + 2; /* 2 for info file */
362 needed -= saved_dump_size(bounds);
363 if (available < needed) {
365 "no dump: not enough free space on device (need at least "
366 "%jdkB for dump; %jdkB available; %jdkB reserved)",
368 (intmax_t)available + minfree,
372 if (spacefree - needed < 0)
374 "dump performed, but free space threshold crossed");
379 compare_magic(const struct kerneldumpheader *kdh, const char *magic)
382 return (strncmp(kdh->magic, magic, sizeof(kdh->magic)) == 0);
385 #define BLOCKSIZE (1<<12)
386 #define BLOCKMASK (~(BLOCKSIZE-1))
389 DoRegularFile(int fd, off_t dumpsize, u_int sectorsize, bool sparse, char *buf,
390 const char *device, const char *filename, FILE *fp)
392 int he, hs, nr, nw, wl;
393 off_t dmpcnt, origsize;
398 while (dumpsize > 0) {
402 nr = read(fd, buf, roundup(wl, sectorsize));
403 if (nr != (int)roundup(wl, sectorsize)) {
406 "WARNING: EOF on dump device");
408 syslog(LOG_ERR, "read error on %s: %m", device);
413 nw = fwrite(buf, 1, wl, fp);
415 for (nw = 0; nw < nr; nw = he) {
416 /* find a contiguous block of zeroes */
417 for (hs = nw; hs < nr; hs += BLOCKSIZE) {
418 for (he = hs; he < nr && buf[he] == 0;
421 /* is the hole long enough to matter? */
422 if (he >= hs + BLOCKSIZE)
426 /* back down to a block boundary */
430 * 1) Don't go beyond the end of the buffer.
431 * 2) If the end of the buffer is less than
432 * BLOCKSIZE bytes away, we're at the end
433 * of the file, so just grab what's left.
435 if (hs + BLOCKSIZE > nr)
439 * At this point, we have a partial ordering:
440 * nw <= hs <= he <= nr
441 * If hs > nw, buf[nw..hs] contains non-zero
442 * data. If he > hs, buf[hs..he] is all zeroes.
445 if (fwrite(buf + nw, hs - nw, 1, fp)
449 if (fseeko(fp, he - hs, SEEK_CUR) == -1)
455 "write error on %s file: %m", filename);
457 "WARNING: vmcore may be incomplete");
463 printf("%llu\r", (unsigned long long)dmpcnt);
468 printf("%s %.1lf%%\n", filename, (100.0 - (100.0 *
469 (double)dumpsize / (double)origsize)));
477 * Specialized version of dump-reading logic for use with textdumps, which
478 * are written backwards from the end of the partition, and must be reversed
479 * before being written to the file. Textdumps are small, so do a bit less
480 * work to optimize/sparsify.
483 DoTextdumpFile(int fd, off_t dumpsize, off_t lasthd, char *buf,
484 const char *device, const char *filename, FILE *fp)
487 off_t dmpcnt, totsize;
492 if ((dumpsize % wl) != 0) {
493 syslog(LOG_ERR, "textdump uneven multiple of 512 on %s",
498 while (dumpsize > 0) {
499 nr = pread(fd, buf, wl, lasthd - (totsize - dumpsize) - wl);
503 "WARNING: EOF on dump device");
505 syslog(LOG_ERR, "read error on %s: %m", device);
509 nw = fwrite(buf, 1, wl, fp);
512 "write error on %s file: %m", filename);
514 "WARNING: textdump may be incomplete");
520 printf("%llu\r", (unsigned long long)dmpcnt);
529 DoFile(const char *savedir, const char *device)
531 xo_handle_t *xostdout, *xoinfo;
532 static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX];
533 static char keyname[PATH_MAX];
534 static char *buf = NULL;
536 struct kerneldumpheader kdhf, kdhl;
538 off_t mediasize, dumpextent, dumplength, firsthd, lasthd;
541 int fd, fdinfo, error;
543 u_int sectorsize, xostyle;
544 uint32_t dumpkeysize;
545 bool iscompressed, isencrypted, istextdump, ret;
547 bounds = getbounds();
550 status = STATUS_UNKNOWN;
552 xostdout = xo_create_to_file(stdout, XO_STYLE_TEXT, 0);
553 if (xostdout == NULL) {
554 syslog(LOG_ERR, "%s: %m", infoname);
558 if (maxdumps > 0 && bounds == maxdumps)
562 buf = malloc(BUFFERSIZE);
564 syslog(LOG_ERR, "%m");
570 printf("checking for kernel dump on device %s\n", device);
572 fd = open(device, (checkfor || keep) ? O_RDONLY : O_RDWR);
574 syslog(LOG_ERR, "%s: %m", device);
578 error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
580 error = ioctl(fd, DIOCGSECTORSIZE, §orsize);
583 "couldn't find media and/or sector size of %s: %m", device);
588 printf("mediasize = %lld bytes\n", (long long)mediasize);
589 printf("sectorsize = %u bytes\n", sectorsize);
592 if (sectorsize < sizeof(kdhl)) {
594 "Sector size is less the kernel dump header %zu",
599 lasthd = mediasize - sectorsize;
600 temp = malloc(sectorsize);
602 syslog(LOG_ERR, "%m");
605 if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
606 read(fd, temp, sectorsize) != (ssize_t)sectorsize) {
608 "error reading last dump header at offset %lld in %s: %m",
609 (long long)lasthd, device);
612 memcpy(&kdhl, temp, sizeof(kdhl));
613 iscompressed = istextdump = false;
614 if (compare_magic(&kdhl, TEXTDUMPMAGIC)) {
616 printf("textdump magic on last dump header on %s\n",
619 if (dtoh32(kdhl.version) != KERNELDUMP_TEXT_VERSION) {
621 "unknown version (%d) in last dump header on %s",
622 dtoh32(kdhl.version), device);
628 } else if (compare_magic(&kdhl, KERNELDUMPMAGIC)) {
629 if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
631 "unknown version (%d) in last dump header on %s",
632 dtoh32(kdhl.version), device);
638 switch (kdhl.compression) {
639 case KERNELDUMP_COMP_NONE:
641 case KERNELDUMP_COMP_GZIP:
642 case KERNELDUMP_COMP_ZSTD:
643 if (compress && verbose)
644 printf("dump is already compressed\n");
649 syslog(LOG_ERR, "unknown compression type %d on %s",
650 kdhl.compression, device);
655 printf("magic mismatch on last dump header on %s\n",
662 if (compare_magic(&kdhl, KERNELDUMPMAGIC_CLEARED)) {
664 printf("forcing magic on %s\n", device);
665 memcpy(kdhl.magic, KERNELDUMPMAGIC, sizeof(kdhl.magic));
667 syslog(LOG_ERR, "unable to force dump - bad magic");
670 if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
672 "unknown version (%d) in last dump header on %s",
673 dtoh32(kdhl.version), device);
685 if (kerneldump_parity(&kdhl)) {
687 "parity error on last dump header on %s", device);
693 dumpextent = dtoh64(kdhl.dumpextent);
694 dumplength = dtoh64(kdhl.dumplength);
695 dumpkeysize = dtoh32(kdhl.dumpkeysize);
696 firsthd = lasthd - dumpextent - sectorsize - dumpkeysize;
697 if (lseek(fd, firsthd, SEEK_SET) != firsthd ||
698 read(fd, temp, sectorsize) != (ssize_t)sectorsize) {
700 "error reading first dump header at offset %lld in %s: %m",
701 (long long)firsthd, device);
705 memcpy(&kdhf, temp, sizeof(kdhf));
708 printf("First dump headers:\n");
709 printheader(xostdout, &kdhf, device, bounds, -1);
711 printf("\nLast dump headers:\n");
712 printheader(xostdout, &kdhl, device, bounds, -1);
716 if (memcmp(&kdhl, &kdhf, sizeof(kdhl))) {
718 "first and last dump headers disagree on %s", device);
724 status = STATUS_GOOD;
728 printf("A dump exists on %s\n", device);
733 if (kdhl.panicstring[0] != '\0')
734 syslog(LOG_ALERT, "reboot after panic: %.*s",
735 (int)sizeof(kdhl.panicstring), kdhl.panicstring);
737 syslog(LOG_ALERT, "reboot");
740 printf("Checking for available free space\n");
742 if (!check_space(savedir, dumplength, bounds)) {
747 writebounds(bounds + 1);
749 saved_dump_remove(bounds);
751 snprintf(infoname, sizeof(infoname), "info.%d", bounds);
754 * Create or overwrite any existing dump header files.
756 fdinfo = open(infoname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
758 syslog(LOG_ERR, "%s: %m", infoname);
763 oumask = umask(S_IRWXG|S_IRWXO); /* Restrict access to the core file. */
764 isencrypted = (dumpkeysize > 0);
766 snprintf(corename, sizeof(corename), "%s.%d.gz",
767 istextdump ? "textdump.tar" :
768 (isencrypted ? "vmcore_encrypted" : "vmcore"), bounds);
769 fp = zopen(corename, "w");
770 } else if (iscompressed && !isencrypted) {
771 snprintf(corename, sizeof(corename), "vmcore.%d.%s", bounds,
772 (kdhl.compression == KERNELDUMP_COMP_GZIP) ? "gz" : "zst");
773 fp = fopen(corename, "w");
775 snprintf(corename, sizeof(corename), "%s.%d",
776 istextdump ? "textdump.tar" :
777 (isencrypted ? "vmcore_encrypted" : "vmcore"), bounds);
778 fp = fopen(corename, "w");
781 syslog(LOG_ERR, "%s: %m", corename);
788 info = fdopen(fdinfo, "w");
791 syslog(LOG_ERR, "fdopen failed: %m");
796 xostyle = xo_get_style(NULL);
797 xoinfo = xo_create_to_file(info, xostyle, 0);
798 if (xoinfo == NULL) {
799 syslog(LOG_ERR, "%s: %m", infoname);
803 xo_open_container_h(xoinfo, "crashdump");
806 printheader(xostdout, &kdhl, device, bounds, status);
808 printheader(xoinfo, &kdhl, device, bounds, status);
809 xo_close_container_h(xoinfo, "crashdump");
815 dumpkey = calloc(1, dumpkeysize);
816 if (dumpkey == NULL) {
817 syslog(LOG_ERR, "Unable to allocate kernel dump key.");
822 if (read(fd, dumpkey, dumpkeysize) != (ssize_t)dumpkeysize) {
823 syslog(LOG_ERR, "Unable to read kernel dump key: %m.");
828 snprintf(keyname, sizeof(keyname), "key.%d", bounds);
829 ret = writekey(keyname, dumpkey, dumpkeysize);
830 explicit_bzero(dumpkey, dumpkeysize);
837 syslog(LOG_NOTICE, "writing %s%score to %s/%s",
838 isencrypted ? "encrypted " : "", compress ? "compressed " : "",
842 if (DoTextdumpFile(fd, dumplength, lasthd, buf, device,
846 if (DoRegularFile(fd, dumplength, sectorsize,
847 !(compress || iscompressed || isencrypted), buf, device,
855 if (fclose(fp) < 0) {
856 syslog(LOG_ERR, "error on %s: %m", corename);
862 if (symlink(infoname, "info.last") == -1) {
863 syslog(LOG_WARNING, "unable to create symlink %s/%s: %m",
864 savedir, "info.last");
867 if (symlink(keyname, "key.last") == -1) {
869 "unable to create symlink %s/%s: %m", savedir,
873 if (compress || iscompressed) {
874 snprintf(linkname, sizeof(linkname), "%s.last.%s",
875 istextdump ? "textdump.tar" :
876 (isencrypted ? "vmcore_encrypted" : "vmcore"),
877 (kdhl.compression == KERNELDUMP_COMP_ZSTD) ? "zst" : "gz");
879 snprintf(linkname, sizeof(linkname), "%s.last",
880 istextdump ? "textdump.tar" :
881 (isencrypted ? "vmcore_encrypted" : "vmcore"));
883 if (symlink(corename, linkname) == -1) {
884 syslog(LOG_WARNING, "unable to create symlink %s/%s: %m",
891 printf("dump saved\n");
896 printf("clearing dump header\n");
897 memcpy(kdhl.magic, KERNELDUMPMAGIC_CLEARED, sizeof(kdhl.magic));
898 memcpy(temp, &kdhl, sizeof(kdhl));
899 if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
900 write(fd, temp, sectorsize) != (ssize_t)sectorsize)
902 "error while clearing the dump header: %m");
904 xo_close_container_h(xostdout, "crashdump");
905 xo_finish_h(xostdout);
923 xo_error("%s\n%s\n%s\n",
924 "usage: savecore -c [-v] [device ...]",
925 " savecore -C [-v] [device ...]",
926 " savecore [-fkvz] [-m maxdumps] [directory [device ...]]");
931 main(int argc, char **argv)
933 const char *savedir = ".";
937 checkfor = compress = clear = force = keep = verbose = 0;
938 nfound = nsaved = nerr = 0;
940 openlog("savecore", LOG_PERROR, LOG_DAEMON);
941 signal(SIGINFO, infohandler);
943 argc = xo_parse_args(argc, argv);
947 while ((ch = getopt(argc, argv, "Ccfkm:vz")) != -1)
962 maxdumps = atoi(optarg);
964 syslog(LOG_ERR, "Invalid maxdump value");
978 if (checkfor && (clear || force || keep))
980 if (clear && (compress || keep))
982 if (maxdumps > 0 && (checkfor || clear))
986 if (argc >= 1 && !checkfor && !clear) {
987 error = chdir(argv[0]);
989 syslog(LOG_ERR, "chdir(%s): %m", argv[0]);
1001 if (strcmp(fsp->fs_vfstype, "swap") &&
1002 strcmp(fsp->fs_vfstype, "dump"))
1004 DoFile(savedir, fsp->fs_spec);
1008 for (i = 0; i < argc; i++)
1009 DoFile(savedir, argv[i]);
1012 /* Emit minimal output. */
1016 printf("No dump exists\n");
1020 syslog(LOG_WARNING, "no dumps found");
1021 } else if (nsaved == 0) {
1025 "unsaved dumps found but not saved");
1028 syslog(LOG_WARNING, "no unsaved dumps found");
1035 infohandler(int sig __unused)