|
|
|
@ -48,15 +48,23 @@ noreturn void usage_then_exit(int err, int argc, char** argv)
|
|
|
|
|
static int map_haystacks(const char* const * h, map_t maps[pOUT])
|
|
|
|
|
{
|
|
|
|
|
const char* path;
|
|
|
|
|
usize d =0;
|
|
|
|
|
while( (path = *h++) )
|
|
|
|
|
{
|
|
|
|
|
map_t *pOUT c = maps++;
|
|
|
|
|
INFO("Mapping haystack file `%s' (to map addr %p)", path, c);
|
|
|
|
|
debug_assert(c);
|
|
|
|
|
if(!map_handle_err(map_file(path, false, 0, 0, c)))
|
|
|
|
|
//TODO: Handle unmapping previous haystacks before return
|
|
|
|
|
if(!map_handle_err(map_file(path, false, 0, 0, c))) {
|
|
|
|
|
//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;
|
|
|
|
|
}
|
|
|
|
|
d+=1;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|