#include <sys/file.h>
#include <lxc.h>
+#include "monitor.h"
static char *strstate[] = {
"STOPPED", "STARTING", "RUNNING", "STOPPING",
"ABORTING", "FREEZING", "FROZEN",
};
-const char *state2str(lxc_state_t state)
+const char *lxc_state2str(lxc_state_t state)
{
if (state < STOPPED || state > MAX_STATE - 1)
return NULL;
return strstate[state];
}
-lxc_state_t str2state(const char *state)
+lxc_state_t lxc_str2state(const char *state)
{
int i, len;
len = sizeof(strstate)/sizeof(strstate[0]);
{
int fd, err;
char file[MAXPATHLEN];
- const char *str = state2str(state);
+ const char *str = lxc_state2str(state);
if (!str)
return -1;
out:
close(fd);
+ lxc_monitor_send_state(name, state);
+
/* let the event to be propagated, crappy but that works,
* otherwise the events will be folded into only one event,
* and I want to have them to be one by one in order
return -err;
}
-int mkstate(const char *name)
+int lxc_mkstate(const char *name)
{
int fd;
char file[MAXPATHLEN];
return 0;
}
-int rmstate(const char *name)
+int lxc_rmstate(const char *name)
{
char file[MAXPATHLEN];
snprintf(file, MAXPATHLEN, LXCPATH "/%s/state", name);
file[err] = '\0';
close(fd);
- return str2state(file);
+ return lxc_str2state(file);
}
static int freezer_state(const char *name)
LXCPATH "/%s/freezer.freeze", name);
file = fopen(freezer, "r");
- if (file < 0) {
+ if (!file) {
lxc_log_syserror("failed to open %s", freezer);
return -1;
}
return -1;
}
- return str2state(status);
+ return lxc_str2state(status);
}
lxc_state_t lxc_state(const char *name)