svn commit: r193395 -
projects/acpica_20090521/usr.sbin/acpi/acpidump
Jung-uk Kim
jkim at FreeBSD.org
Wed Jun 3 20:24:29 UTC 2009
Author: jkim
Date: Wed Jun 3 20:24:28 2009
New Revision: 193395
URL: http://svn.freebsd.org/changeset/base/193395
Log:
Fix acpidump(8) disassmebly with option -d. iasl(8) creates disassembled
output file from input file name as a template. Honor TMPDIR environment
variable while I am here.
Modified:
projects/acpica_20090521/usr.sbin/acpi/acpidump/acpi.c
Modified: projects/acpica_20090521/usr.sbin/acpi/acpidump/acpi.c
==============================================================================
--- projects/acpica_20090521/usr.sbin/acpi/acpidump/acpi.c Wed Jun 3 20:21:17 2009 (r193394)
+++ projects/acpica_20090521/usr.sbin/acpi/acpidump/acpi.c Wed Jun 3 20:24:28 2009 (r193395)
@@ -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 ACP
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;
+ size_t len;
+ int fd;
- strcpy(tmpstr, "/tmp/acpidump.XXXXXX");
+ 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, st
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, st
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;
More information about the svn-src-projects
mailing list