From d0e44fd5779eca7e16548a30d919afcbeb2ef881 Mon Sep 17 00:00:00 2001 From: jkim Date: Fri, 5 Jun 2009 18:50:45 +0000 Subject: Import ACPICA 20090521. --- usr.sbin/acpi/acpidump/acpi.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'usr.sbin/acpi/acpidump/acpi.c') diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index fed0fb2..30ed43f 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -34,7 +34,9 @@ #include #include #include +#include #include +#include #include #include @@ -803,11 +805,26 @@ dsdt_save_file(char *outfile, struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) void aml_disassemble(struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) { - char tmpstr[32], buf[256]; + char buf[PATH_MAX], tmpstr[PATH_MAX]; + const char *tmpdir; + char *tmpext; FILE *fp; - int fd, len; - - strcpy(tmpstr, "/tmp/acpidump.XXXXXX"); + size_t len; + int fd; + + tmpdir = getenv("TMPDIR"); + if (tmpdir == NULL) + tmpdir = _PATH_TMP; + strncpy(tmpstr, tmpdir, sizeof(tmpstr)); + strncat(tmpstr, "/acpidump.", sizeof(tmpstr) - strlen(tmpdir)); + if (realpath(tmpstr, buf) == NULL) { + perror("realpath tmp file"); + return; + } + strncpy(tmpstr, buf, sizeof(tmpstr)); + len = strlen(buf); + tmpext = tmpstr + len; + strncpy(tmpext, "XXXXXX", sizeof(tmpstr) - len); fd = mkstemp(tmpstr); if (fd < 0) { perror("iasl tmp file"); @@ -821,7 +838,7 @@ aml_disassemble(struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) close(STDOUT_FILENO); if (vflag == 0) close(STDERR_FILENO); - execl("/usr/sbin/iasl", "iasl", "-d", tmpstr, (char *) 0); + execl("/usr/sbin/iasl", "iasl", "-d", tmpstr, NULL); err(1, "exec"); } @@ -829,8 +846,9 @@ aml_disassemble(struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) unlink(tmpstr); /* Dump iasl's output to stdout */ - fp = fopen("acpidump.dsl", "r"); - unlink("acpidump.dsl"); + strncpy(tmpext, "dsl", sizeof(tmpstr) - len); + fp = fopen(tmpstr, "r"); + unlink(tmpstr); if (fp == NULL) { perror("iasl tmp file (read)"); return; -- cgit v1.1