|
|
@ -48,14 +48,22 @@ noreturn void usage_then_exit(int err, int argc, char** argv)
|
|
|
|
static int map_haystacks(const char* const * h, map_t maps[pOUT])
|
|
|
|
static int map_haystacks(const char* const * h, map_t maps[pOUT])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const char* path;
|
|
|
|
const char* path;
|
|
|
|
|
|
|
|
usize d =0;
|
|
|
|
while( (path = *h++) )
|
|
|
|
while( (path = *h++) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
map_t *pOUT c = maps++;
|
|
|
|
map_t *pOUT c = maps++;
|
|
|
|
INFO("Mapping haystack file `%s' (to map addr %p)", path, c);
|
|
|
|
INFO("Mapping haystack file `%s' (to map addr %p)", path, c);
|
|
|
|
debug_assert(c);
|
|
|
|
debug_assert(c);
|
|
|
|
if(!map_handle_err(map_file(path, false, 0, 0, c)))
|
|
|
|
if(!map_handle_err(map_file(path, false, 0, 0, c))) {
|
|
|
|
//TODO: Handle unmapping previous haystacks before return
|
|
|
|
//Handle unmapping previous haystacks before return
|
|
|
|
|
|
|
|
// Prep reset maps to before `c` for unwind
|
|
|
|
|
|
|
|
maps-=1;
|
|
|
|
|
|
|
|
ERROR("Failed to map file `%s', rolling back %lu maps. (erp: %p, prev: %p)", path, d, c, maps);
|
|
|
|
|
|
|
|
for(usize i=0;i<d;i++)
|
|
|
|
|
|
|
|
if(!map_handle_err(map_free(* (--maps)))) WARN("Failed to free map at %p (in %lu unwind)", maps, i);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
d+=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|