load pier directory on serf for saving tracing files

This commit is contained in:
Isaac Visintainer 2019-03-10 13:43:34 -07:00
parent 5c88da2619
commit 03ae60505b
4 changed files with 36 additions and 5 deletions

View File

@ -541,6 +541,7 @@
c3_w nid_w; // nock pid
FILE* fil_u; // trace file (json)
c3_w con_w; // trace counter
c3_w fun_w; // file counter
} u3_trac;
/* u3_opts: command line configuration.

View File

@ -762,6 +762,7 @@ main(c3_i argc,
u3_Host.tra_u.nid_w = 0;
u3_Host.tra_u.fil_u = NULL;
u3_Host.tra_u.con_w = 0;
u3_Host.tra_u.fun_w = 0;
}
}

View File

@ -346,19 +346,16 @@ u3t_flee(void)
void
u3t_trace_open()
{
c3_c fil_c[2048];
snprintf(fil_c, 2048, "%s/.urb/put/trace", u3_Host.dir_c);
snprintf(fil_c, 2048, "%s/.urb/put/trace", u3C.dir_c);
struct stat st;
if ( -1 == stat(fil_c, &st) ) {
mkdir(fil_c, 0700);
}
c3_c * wen_c = u3r_string(u3A->wen);
c3_c lif_c[2048];
snprintf(lif_c, 2048, "%s/%s.json", fil_c, wen_c);
free(wen_c);
snprintf(lif_c, 2048, "%s/%d.json", fil_c, u3_Host.tra_u.fun_w);
u3_Host.tra_u.fil_u = fopen(lif_c, "w");
u3_Host.tra_u.nid_w = (int)getpid();
@ -402,6 +399,7 @@ u3t_trace_close()
// We don't terminate the JSON because of the file format.
fclose(u3_Host.tra_u.fil_u);
u3_Host.tra_u.con_w = 0;
u3_Host.tra_u.fun_w++;
}
/* u3t_trace_time(): microsecond clock

View File

@ -762,6 +762,37 @@ main(c3_i argc, c3_c* argv[])
sscanf(wag_c, "%" SCNu32, &u3C.wag_w);
}
/* load pier directory
*/
{
c3_i abs_i = 1000;
c3_c* abs_c = c3_malloc(abs_i);
while ( abs_c != getcwd(abs_c, abs_i) ) {
free(abs_c);
abs_i *= 2;
abs_c = c3_malloc(abs_i);
}
c3_i ful_i = abs_i + strlen(dir_c);
c3_c* ful_c = c3_malloc(ful_i);
snprintf(ful_c, ful_i, "%s/%s", abs_c, dir_c);
u3C.dir_c = strdup(ful_c);
free(ful_c);
free(abs_c);
}
/* clear tracing struct
*/
{
u3_Host.tra_u.nid_w = 0;
u3_Host.tra_u.fil_u = NULL;
u3_Host.tra_u.con_w = 0;
u3_Host.tra_u.fun_w = 0;
}
/* boot image
*/
{