aboutsummaryrefslogtreecommitdiff
path: root/sbin/dumpon
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2018-02-13 19:28:02 +0000
committerMark Johnston <markj@FreeBSD.org>2018-02-13 19:28:02 +0000
commit6026dcd7ca888f3433f4df34ede69a77c1eb7701 (patch)
tree0de05c03d3e12526dae1a59da5a95ddedd6c3738 /sbin/dumpon
parent83ab0f9f33c1ba96cce50a48e27e40c8c2eead5a (diff)
downloadsrc-6026dcd7ca888f3433f4df34ede69a77c1eb7701.tar.gz
src-6026dcd7ca888f3433f4df34ede69a77c1eb7701.zip
Add support for zstd-compressed user and kernel core dumps.
This works similarly to the existing gzip compression support, but zstd is typically faster and gives better compression ratios. Support for this functionality must be configured by adding ZSTDIO to one's kernel configuration file. dumpon(8)'s new -Z option is used to configure zstd compression for kernel dumps. savecore(8) now recognizes and saves zstd-compressed kernel dumps with a .zst extension. Submitted by: cem (original version) Relnotes: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D13101, https://reviews.freebsd.org/D13633
Notes
Notes: svn path=/head/; revision=329240
Diffstat (limited to 'sbin/dumpon')
-rw-r--r--sbin/dumpon/dumpon.829
-rw-r--r--sbin/dumpon/dumpon.c23
2 files changed, 39 insertions, 13 deletions
diff --git a/sbin/dumpon/dumpon.8 b/sbin/dumpon/dumpon.8
index 572bd030aef1..e6aace1bbbc0 100644
--- a/sbin/dumpon/dumpon.8
+++ b/sbin/dumpon/dumpon.8
@@ -28,7 +28,7 @@
.\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
.\"
-.Dd October 24, 2017
+.Dd February 13, 2018
.Dt DUMPON 8
.Os
.Sh NAME
@@ -39,6 +39,7 @@
.Op Fl v
.Op Fl k Ar public_key_file
.Op Fl z
+.Op Fl Z
.Ar special_file
.Nm
.Op Fl v
@@ -116,8 +117,10 @@ kernel option.
.Pp
The
.Fl z
-option configures the kernel to compress the dump in gzip format before writing
-it to the dump device.
+and
+.Fl Z
+options configure the kernel to compress the dump before writing it to
+the dump device.
This reduces the amount of space required for the dump and accelerates
recovery with
.Xr savecore 8
@@ -126,9 +129,21 @@ When compression is enabled, the
.Nm
utility will not verify that the dump device is sufficiently large for a full
dump.
-This flag requires a kernel compiled with the
+The
+.Fl z
+and
+.Fl Z
+options cause the dump to be written in
+.Xr gzip 1
+and
+.Xr zstd 1
+format, respectively.
+These flags require a kernel compiled with the
.Dv GZIO
-kernel option.
+or
+.Dv ZSTDIO
+kernel options.
+.Pp
.Pp
The
.Fl l
@@ -269,15 +284,17 @@ The core was decrypted properly if
.Xr kgdb 1
does not print any errors.
.Sh SEE ALSO
+.Xr gzip 1 ,
.Xr kgdb 1 ,
+.Xr zstd 1 ,
.Xr ddb 4 ,
.Xr fstab 5 ,
.Xr rc.conf 5 ,
.Xr config 8 ,
+.Xr decryptcore 8 ,
.Xr init 8 ,
.Xr loader 8 ,
.Xr rc 8 ,
-.Xr decryptcore 8 ,
.Xr savecore 8 ,
.Xr swapon 8 ,
.Xr panic 9
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index 19fdb3f5d572..0ae95e6e1847 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -73,7 +73,7 @@ static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n",
- "usage: dumpon [-v] [-k public_key_file] [-z] special_file",
+ "usage: dumpon [-v] [-k public_key_file] [-Zz] special_file",
" dumpon [-v] off",
" dumpon [-v] -l");
exit(EX_USAGE);
@@ -192,12 +192,12 @@ main(int argc, char *argv[])
int ch;
int i, fd;
int do_listdumpdev = 0;
- bool enable, gzip;
+ bool enable, gzip, zstd;
- gzip = false;
+ gzip = zstd = false;
pubkeyfile = NULL;
- while ((ch = getopt(argc, argv, "k:lvz")) != -1)
+ while ((ch = getopt(argc, argv, "k:lvZz")) != -1)
switch((char)ch) {
case 'k':
pubkeyfile = optarg;
@@ -208,6 +208,9 @@ main(int argc, char *argv[])
case 'v':
verbose = 1;
break;
+ case 'Z':
+ zstd = true;
+ break;
case 'z':
gzip = true;
break;
@@ -215,6 +218,9 @@ main(int argc, char *argv[])
usage();
}
+ if (gzip && zstd)
+ errx(EX_USAGE, "The -z and -Z options are mutually exclusive.");
+
argc -= optind;
argv += optind;
@@ -254,7 +260,7 @@ main(int argc, char *argv[])
if (fd < 0)
err(EX_OSFILE, "%s", dumpdev);
- if (!gzip)
+ if (!gzip && !zstd)
check_size(fd, dumpdev);
bzero(&kda, sizeof(kda));
@@ -268,8 +274,11 @@ main(int argc, char *argv[])
#endif
kda.kda_enable = 1;
- kda.kda_compression = gzip ? KERNELDUMP_COMP_GZIP :
- KERNELDUMP_COMP_NONE;
+ kda.kda_compression = KERNELDUMP_COMP_NONE;
+ if (zstd)
+ kda.kda_compression = KERNELDUMP_COMP_ZSTD;
+ else if (gzip)
+ kda.kda_compression = KERNELDUMP_COMP_GZIP;
i = ioctl(fd, DIOCSKERNELDUMP, &kda);
explicit_bzero(kda.kda_encryptedkey, kda.kda_encryptedkeysize);
free(kda.kda_encryptedkey);