I have some trace files that are gzipped to save space. (They compress really
well.) It would be convenient if I could simply zcat them into kdump for
inspection.
This patch allows -f - to read from stdin. (Curiously, kdump always reads from
stdin, but uses freopen on the trace file.)
Unsure about man page. I think many utilities just generally assume the user
knows - means stdin/out?
Index: kdump.c
===================================================================
RCS file: /cvs/src/usr.bin/kdump/kdump.c,v
retrieving revision 1.135
diff -u -p -r1.135 kdump.c
--- kdump.c 21 Oct 2018 19:56:26 -0000 1.135
+++ kdump.c 12 Dec 2018 03:26:08 -0000
@@ -208,16 +208,18 @@ main(int argc, char *argv[])
if (argc > optind)
usage();
- if (unveil(tracefile, "r") == -1)
- err(1, "unveil");
+ if (strcmp(tracefile, "-") != 0)
+ if (unveil(tracefile, "r") == -1)
+ err(1, "unveil");
if (pledge("stdio rpath getpw", NULL) == -1)
err(1, "pledge");
m = malloc(size = 1025);
if (m == NULL)
err(1, NULL);
- if (!freopen(tracefile, "r", stdin))
- err(1, "%s", tracefile);
+ if (strcmp(tracefile, "-") != 0)
+ if (!freopen(tracefile, "r", stdin))
+ err(1, "%s", tracefile);
if (fread_tail(&ktr_header, sizeof(struct ktr_header), 1) == 0 ||
ktr_header.ktr_type != htobe32(KTR_START))