summaryrefslogtreecommitdiffstats
path: root/usr.sbin/acpidump
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2016-09-26 19:58:26 +0000
committerkettenis <kettenis@openbsd.org>2016-09-26 19:58:26 +0000
commitc8dab64c7c999c55518ac37b96c25209f66de2bb (patch)
treed4ae7d5e65ec1046fde82208ab3e25b1a97632cb /usr.sbin/acpidump
parenttypo in comment (diff)
downloadwireguard-openbsd-c8dab64c7c999c55518ac37b96c25209f66de2bb.tar.xz
wireguard-openbsd-c8dab64c7c999c55518ac37b96c25209f66de2bb.zip
If the argument of -o specifies a directory, dump the files without using a
prefix. ok deraadt@
Diffstat (limited to 'usr.sbin/acpidump')
-rw-r--r--usr.sbin/acpidump/acpidump.820
-rw-r--r--usr.sbin/acpidump/acpidump.c17
2 files changed, 24 insertions, 13 deletions
diff --git a/usr.sbin/acpidump/acpidump.8 b/usr.sbin/acpidump/acpidump.8
index ff8747898a2..42f1f2623d2 100644
--- a/usr.sbin/acpidump/acpidump.8
+++ b/usr.sbin/acpidump/acpidump.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: acpidump.8,v 1.16 2016/09/25 15:23:37 deraadt Exp $
+.\" $OpenBSD: acpidump.8,v 1.17 2016/09/26 19:58:26 kettenis Exp $
.\"
.\" Copyright (c) 1999 Doug Rabson <dfr@FreeBSD.org>
.\" Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD: src/usr.sbin/acpi/acpidump/acpidump.8,v 1.9 2001/09/05 19:21:25 dd Exp $
.\"
-.Dd $Mdocdate: September 25 2016 $
+.Dd $Mdocdate: September 26 2016 $
.Dt ACPIDUMP 8
.Os
.Sh NAME
@@ -37,21 +37,25 @@
.Nd dump ACPI tables
.Sh SYNOPSIS
.Nm
-.Fl o Ar prefix_for_output
+.Fl o Ar prefix
.Sh DESCRIPTION
The
.Nm
command stores ACPI tables from physical memory into files specified by
-.Ar prefix_for_output .
-The files generated will
-be of the form <prefix>.<sig>.<id>.
+.Ar prefix .
+If
+.Ar prefix
+specifies a directory, the generated files will be of the form
+<prefix>/<sig>.<id>.
+Otherwise, they will be named <prefix>.<sig>.<id>.
.Dq sig
is the signature of the ACPI Table;
.Dq id
is unique for each table.
.Pp
-Additionally a file called <prefix>.headers will be created that contains
-additional human readable information pertaining to this specific dump.
+Additionally a file called <prefix>/headers or <prefix>.headers will
+be created that contains additional human readable information
+pertaining to this specific dump.
.Pp
The ACPICA disassembler is available through the
.Ox
diff --git a/usr.sbin/acpidump/acpidump.c b/usr.sbin/acpidump/acpidump.c
index 24746a5ae57..4a499e2f47e 100644
--- a/usr.sbin/acpidump/acpidump.c
+++ b/usr.sbin/acpidump/acpidump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpidump.c,v 1.16 2015/10/12 04:02:57 semarie Exp $ */
+/* $OpenBSD: acpidump.c,v 1.17 2016/09/26 19:58:26 kettenis Exp $ */
/*
* Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
* All rights reserved.
@@ -167,6 +167,7 @@ LIST_HEAD(acpi_user_mapping_list, acpi_user_mapping) maplist;
int acpi_mem_fd = -1;
char *aml_dumpfile;
+int aml_dumpdir;
FILE *fhdr;
int acpi_checksum(void *_p, size_t _length);
@@ -343,8 +344,9 @@ aml_dump(struct ACPIsdt *hdr)
int fd;
mode_t mode;
- snprintf(name, sizeof(name), "%s.%c%c%c%c.%d",
- aml_dumpfile, hdr->signature[0], hdr->signature[1],
+ snprintf(name, sizeof(name), "%s%c%c%c%c%c.%d",
+ aml_dumpfile, aml_dumpdir ? '/' : '.',
+ hdr->signature[0], hdr->signature[1],
hdr->signature[2], hdr->signature[3],
hdr_index++);
@@ -529,7 +531,8 @@ asl_dump_from_devmem(void)
struct ACPIsdt *rsdp;
char name[PATH_MAX];
- snprintf(name, sizeof(name), "%s.headers", aml_dumpfile);
+ snprintf(name, sizeof(name), "%s%cheaders", aml_dumpfile,
+ aml_dumpdir ? '/' : '.');
acpi_user_init();
@@ -560,13 +563,14 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "usage: %s -o prefix_for_output\n", __progname);
+ fprintf(stderr, "usage: %s -o prefix\n", __progname);
exit(1);
}
int
main(int argc, char *argv[])
{
+ struct stat st;
char c;
while ((c = getopt(argc, argv, "o:")) != -1) {
@@ -583,6 +587,9 @@ main(int argc, char *argv[])
if (aml_dumpfile == NULL)
usage();
+ if (stat(aml_dumpfile, &st) == 0 && S_ISDIR(st.st_mode))
+ aml_dumpdir = 1;
+
asl_dump_from_devmem();
return (0);