diff options
author | jkim <jkim@FreeBSD.org> | 2009-06-05 18:50:45 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2009-06-05 18:50:45 +0000 |
commit | d0e44fd5779eca7e16548a30d919afcbeb2ef881 (patch) | |
tree | 43df3e14d718167d26d41331ba1f8879b4e3a990 /usr.sbin/acpi/acpidump/acpi.c | |
parent | 6d358bddff8eb82625370b62ff77b8fc34b088c6 (diff) | |
download | FreeBSD-src-d0e44fd5779eca7e16548a30d919afcbeb2ef881.zip FreeBSD-src-d0e44fd5779eca7e16548a30d919afcbeb2ef881.tar.gz |
Import ACPICA 20090521.
Diffstat (limited to 'usr.sbin/acpi/acpidump/acpi.c')
-rw-r--r-- | usr.sbin/acpi/acpidump/acpi.c | 32 |
1 files changed, 25 insertions, 7 deletions
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 <assert.h> #include <err.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -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; |