#define UXC_VERSION "0.2"
#define OCI_VERSION_STRING "1.0.2"
-#define UXC_CONFDIR "/etc/uxc"
+#define UXC_ETC_CONFDIR "/etc/uxc"
+#define UXC_VOL_CONFDIR "/var/run/uxc"
static bool verbose = false;
+static char *confdir = UXC_ETC_CONFDIR;
struct runtime_state {
struct avl_node avl;
printf(" [--autostart]\t\t\t\tstart on boot\n");
printf(" [--temp-overlay-size size]\t\tuse tmpfs overlay with {size}\n");
printf(" [--write-overlay-path path]\t\tuse overlay on {path}\n");
- printf(" [--volumes v1,v2,...,vN]\t\trequire volumes to be available\n");
+ printf(" [--mounts v1,v2,...,vN]\t\trequire filesystems to be available\n");
printf("\tstart <conf>\t\t\t\t\tstart container <conf>\n");
printf("\tstate <conf>\t\t\t\t\tget state of container <conf>\n");
printf("\tkill <conf> [<signal>]\t\t\t\tsend signal to container <conf>\n");
glob_t gl;
char *globstr;
void *c, *o;
+ struct stat sb;
+
+ if (!stat(UXC_VOL_CONFDIR, &sb)) {
+ if (sb.st_mode & S_IFDIR)
+ confdir = UXC_VOL_CONFDIR;
+ }
- if (asprintf(&globstr, "%s/*.json", UXC_CONFDIR) == -1)
+ if (asprintf(&globstr, "%s/*.json", confdir) == -1)
return ENOMEM;
blob_buf_init(&conf, 0);
char *bundle = NULL;
char *jail_name = NULL;
char *state = NULL;
+ char *tmp;
static struct blob_buf buf;
if (s)
blobmsg_add_string(&buf, "status", s?"stopped":"uninitialized");
blobmsg_add_string(&buf, "bundle", bundle);
- printf("%s\n", blobmsg_format_json_indent(buf.head, true, 0));
+ tmp = blobmsg_format_json_indent(buf.head, true, 0);
+ if (!tmp) {
+ blob_buf_free(&buf);
+ return ENOMEM;
+ }
+
+ printf("%s\n", tmp);
+ free(tmp);
+
blob_buf_free(&buf);
return 0;
return ENOTDIR;
}
- ret = mkdir(UXC_CONFDIR, 0755);
+ ret = mkdir(confdir, 0755);
if (ret && errno != EEXIST)
return ret;
- if (asprintf(&fname, "%s/%s.json", UXC_CONFDIR, name) == -1)
+ if (asprintf(&fname, "%s/%s.json", confdir, name) == -1)
return ENOMEM;
f = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0644);
}
blob_buf_free(&req);
+ close(f);
return 0;
}