Files
guestfs-inspect/guestfs-inspectd.c

38 lines
957 B
C

#include <stdio.h>
#include <stdlib.h>
#include <czmq.h>
#include <zactor.h>
#include <guestfs.h>
void *worker_task;
char *endpoint(void);
int main(int argc, char **argv) {
if (argc < 2) {
printf("Usage: %s <disk-path> ...\n", argv[0]);
return EXIT_FAILURE;
}
const int worker_count = argc - 1;
// One worker per disk image.
zactor_t *workers[worker_count];
for (int i = 0; i < worker_count; i++) {
char *path = strtok(argv[i+1], ":");
char *name = strtok(NULL, ":");
workers[i] = zactor_new(worker_task, (void *) &((struct { char* path; char *name; }) {.path = path, .name = name}));
}
return EXIT_SUCCESS;
}
char *endpoint() {
// TODO: This should be based on GUESTFS_INSPECT_ENDPOINT, or XDG_RUNTIME_DIR if the former is not set, and default to a sensible path if neither are set.
const char* ep = "ipc:///tmp/guestfs-inspect.sock";
char *res = malloc(strlen(ep) + 1);
strcpy(res, ep);
return res;
}