1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-09 22:38:01 -08:00

If the argument of -o specifies a directory, dump the files without using a

prefix.

ok deraadt@
This commit is contained in:
kettenis 2016-09-26 19:58:26 +00:00
parent d2ba3035c2
commit c8dab64c7c
2 changed files with 24 additions and 13 deletions

View File

@ -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) 1999 Doug Rabson <dfr@FreeBSD.org>
.\" Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@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 $ .\" $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 .Dt ACPIDUMP 8
.Os .Os
.Sh NAME .Sh NAME
@ -37,21 +37,25 @@
.Nd dump ACPI tables .Nd dump ACPI tables
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Fl o Ar prefix_for_output .Fl o Ar prefix
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm .Nm
command stores ACPI tables from physical memory into files specified by command stores ACPI tables from physical memory into files specified by
.Ar prefix_for_output . .Ar prefix .
The files generated will If
be of the form <prefix>.<sig>.<id>. .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 .Dq sig
is the signature of the ACPI Table; is the signature of the ACPI Table;
.Dq id .Dq id
is unique for each table. is unique for each table.
.Pp .Pp
Additionally a file called <prefix>.headers will be created that contains Additionally a file called <prefix>/headers or <prefix>.headers will
additional human readable information pertaining to this specific dump. be created that contains additional human readable information
pertaining to this specific dump.
.Pp .Pp
The ACPICA disassembler is available through the The ACPICA disassembler is available through the
.Ox .Ox

View File

@ -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> * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
* All rights reserved. * All rights reserved.
@ -167,6 +167,7 @@ LIST_HEAD(acpi_user_mapping_list, acpi_user_mapping) maplist;
int acpi_mem_fd = -1; int acpi_mem_fd = -1;
char *aml_dumpfile; char *aml_dumpfile;
int aml_dumpdir;
FILE *fhdr; FILE *fhdr;
int acpi_checksum(void *_p, size_t _length); int acpi_checksum(void *_p, size_t _length);
@ -343,8 +344,9 @@ aml_dump(struct ACPIsdt *hdr)
int fd; int fd;
mode_t mode; mode_t mode;
snprintf(name, sizeof(name), "%s.%c%c%c%c.%d", snprintf(name, sizeof(name), "%s%c%c%c%c%c.%d",
aml_dumpfile, hdr->signature[0], hdr->signature[1], aml_dumpfile, aml_dumpdir ? '/' : '.',
hdr->signature[0], hdr->signature[1],
hdr->signature[2], hdr->signature[3], hdr->signature[2], hdr->signature[3],
hdr_index++); hdr_index++);
@ -529,7 +531,8 @@ asl_dump_from_devmem(void)
struct ACPIsdt *rsdp; struct ACPIsdt *rsdp;
char name[PATH_MAX]; 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(); acpi_user_init();
@ -560,13 +563,14 @@ usage(void)
{ {
extern char *__progname; extern char *__progname;
fprintf(stderr, "usage: %s -o prefix_for_output\n", __progname); fprintf(stderr, "usage: %s -o prefix\n", __progname);
exit(1); exit(1);
} }
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
struct stat st;
char c; char c;
while ((c = getopt(argc, argv, "o:")) != -1) { while ((c = getopt(argc, argv, "o:")) != -1) {
@ -583,6 +587,9 @@ main(int argc, char *argv[])
if (aml_dumpfile == NULL) if (aml_dumpfile == NULL)
usage(); usage();
if (stat(aml_dumpfile, &st) == 0 && S_ISDIR(st.st_mode))
aml_dumpdir = 1;
asl_dump_from_devmem(); asl_dump_from_devmem();
return (0); return (0);