Adds pid file support.

This commit is contained in:
Andrea Mazzoleni 2013-06-17 23:50:26 +02:00
parent 875081f530
commit bc2a837953
8 changed files with 149 additions and 14 deletions

View file

@ -45,6 +45,7 @@ void state_init(struct snapraid_state* state)
state->qarity_device = 0;
state->pool[0] = 0;
state->pool_device = 0;
state->pidfile[0] = 0;
state->level = 1; /* default is the lowest protection */
tommy_list_init(&state->disklist);
@ -462,6 +463,12 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
content = content_alloc(buffer, st.st_dev);
tommy_list_insert_tail(&state->contentlist, &content->node, content);
/* if not set pid file, set it as the first content file */
if (!state->pidfile[0]) {
pathcpy(state->pidfile, sizeof(state->pidfile), buffer);
pathcat(state->pidfile, sizeof(state->pidfile), ".pid");
}
} else if (strcmp(tag, "disk") == 0) {
char dir[PATH_MAX];
char device[PATH_MAX];