Commit db2a76b4 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Base

parent 8433ea6d
......@@ -31,6 +31,8 @@
static LIST_HEAD(allocations);
static LIST_HEAD(mmaps);
extern char *log_base;
void replay_memory()
{
struct panwrap_mapped_memory *pos;
......@@ -42,7 +44,7 @@ void replay_memory()
/* Dump to file */
char filename[128];
snprintf(filename, 128, "/dev/shm/%s.bin", pos->name);
snprintf(filename, 128, "%s/%s.bin", log_base, pos->name);
FILE *fp = fopen(filename, "wb");
fwrite(pos->addr, 1, pos->length, fp);
fclose(fp);
......
......@@ -23,6 +23,7 @@
#include "panwrap.h"
FILE *log_output;
char *log_base;
/**
* Grab the location of a symbol from the system's libc instead of our
......@@ -55,22 +56,19 @@ __rd_dlsym_helper(const char *name)
static void __attribute__((constructor)) constructor_util(void) {
const char *env;
env = getenv("PANWRAP_OUTPUT");
if (env) {
/* Don't try to reopen stderr or stdout, that won't work */
if (strcmp(env, "/dev/stderr") == 0) {
log_output = stderr;
} else if (strcmp(env, "/dev/stdout") == 0) {
log_output = stdout;
} else {
log_output = fopen(env, "w+");
if (!log_output) {
fprintf(stderr, "Failed to open %s: %s\n",
env, strerror(errno));
exit(1);
}
}
} else {
log_output = stdout;
log_base = getenv("PANWRAP_OUTPUT");
if (!log_base) {
log_base = "/dev/shm";
}
char control_name[256];
snprintf(control_name, sizeof(control_name), "%s/control.log", log_base);
log_output = fopen(control_name, "w+");
if (!log_output) {
fprintf(stderr, "Failed to open %s: %s\n",
env, strerror(errno));
exit(1);
}
}
......@@ -21,11 +21,6 @@
#include <time.h>
#include "panwrap-mmap.h"
struct panwrap_flag_info {
u64 flag;
const char *name;
};
#define PROLOG(func) \
static typeof(func) *orig_##func = NULL; \
if (!orig_##func) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment