Use a string to identify the loom
Allows the use of the hostname by now
This commit is contained in:
parent
c6724f1e25
commit
b6af567b23
32
ovni.c
32
ovni.c
@ -41,31 +41,26 @@ struct ovni_rproc rproc = {0};
|
|||||||
_Thread_local struct ovni_rthread rthread = {0};
|
_Thread_local struct ovni_rthread rthread = {0};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
create_trace_dirs(char *tracedir, int loom, int proc)
|
create_trace_dirs(char *tracedir, char *loom, int proc)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
fprintf(stderr, "create trace dirs for loom=%d, proc=%d\n",
|
fprintf(stderr, "create trace dirs for loom=%s, proc=%d\n",
|
||||||
loom, proc);
|
loom, proc);
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s", tracedir);
|
snprintf(path, PATH_MAX, "%s", tracedir);
|
||||||
|
|
||||||
if(mkdir(path, 0755))
|
/* May fail if another loom created the directory already */
|
||||||
{
|
mkdir(path, 0755);
|
||||||
fprintf(stderr, "mkdir %s: %s\n", path, strerror(errno));
|
|
||||||
//return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s/loom.%d", tracedir, loom);
|
snprintf(path, PATH_MAX, "%s/loom.%s", tracedir, loom);
|
||||||
|
|
||||||
if(mkdir(path, 0755))
|
/* Also may fail */
|
||||||
{
|
mkdir(path, 0755);
|
||||||
fprintf(stderr, "mkdir %s: %s\n", path, strerror(errno));
|
|
||||||
//return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(rproc.dir, PATH_MAX, "%s/loom.%d/proc.%d", tracedir, loom, proc);
|
snprintf(rproc.dir, PATH_MAX, "%s/loom.%s/proc.%d", tracedir, loom, proc);
|
||||||
|
|
||||||
|
/* But this one shall not fail */
|
||||||
if(mkdir(rproc.dir, 0755))
|
if(mkdir(rproc.dir, 0755))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "mkdir %s: %s\n", rproc.dir, strerror(errno));
|
fprintf(stderr, "mkdir %s: %s\n", rproc.dir, strerror(errno));
|
||||||
@ -92,16 +87,14 @@ create_trace_stream()
|
|||||||
if(rthread.streamfd == -1)
|
if(rthread.streamfd == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "open %s failed: %s\n", path, strerror(errno));
|
fprintf(stderr, "open %s failed: %s\n", path, strerror(errno));
|
||||||
/* Shall we just return -1 ? */
|
return -1;
|
||||||
abort();
|
|
||||||
//return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ovni_proc_init(int loom, int proc)
|
ovni_proc_init(char *loom, int proc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -109,7 +102,8 @@ ovni_proc_init(int loom, int proc)
|
|||||||
|
|
||||||
memset(&rproc, 0, sizeof(rproc));
|
memset(&rproc, 0, sizeof(rproc));
|
||||||
|
|
||||||
rproc.loom = loom;
|
/* FIXME: strcpy is insecure */
|
||||||
|
strcpy(rproc.loom, loom);
|
||||||
rproc.proc = proc;
|
rproc.proc = proc;
|
||||||
|
|
||||||
/* By default we use the monotonic clock */
|
/* By default we use the monotonic clock */
|
||||||
|
5
ovni.h
5
ovni.h
@ -6,6 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#define OVNI_MAX_CPU 256
|
#define OVNI_MAX_CPU 256
|
||||||
#define OVNI_MAX_PROC 32
|
#define OVNI_MAX_PROC 32
|
||||||
@ -93,7 +94,7 @@ struct ovni_rproc {
|
|||||||
char dir[PATH_MAX];
|
char dir[PATH_MAX];
|
||||||
|
|
||||||
int proc;
|
int proc;
|
||||||
int loom;
|
char loom[HOST_NAME_MAX];
|
||||||
int ncpus;
|
int ncpus;
|
||||||
clockid_t clockid;
|
clockid_t clockid;
|
||||||
char procdir[PATH_MAX];
|
char procdir[PATH_MAX];
|
||||||
@ -101,7 +102,7 @@ struct ovni_rproc {
|
|||||||
int ready;
|
int ready;
|
||||||
};
|
};
|
||||||
|
|
||||||
int ovni_proc_init(int loom, int proc);
|
int ovni_proc_init(char *loom, int proc);
|
||||||
|
|
||||||
int ovni_thread_init(pid_t tid);
|
int ovni_thread_init(pid_t tid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user