small fix
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,7 +1,7 @@
|
|||||||
daemon:
|
daemon:
|
||||||
gcc guestfs-inspectd.c -o guestfs-inspectd `pkg-config libguestfs libczmq --cflags --libs`
|
gcc -ggdb3 -Wall guestfs-inspectd.c -o guestfs-inspectd `pkg-config libguestfs libczmq --cflags --libs`
|
||||||
|
|
||||||
client:
|
client:
|
||||||
gcc -g guestfs-inspect.c -o guestfs-inspect `pkg-config libguestfs libczmq --cflags --libs`
|
gcc -ggdb3 -Wall guestfs-inspect.c -o guestfs-inspect `pkg-config libguestfs libczmq --cflags --libs`
|
||||||
|
|
||||||
build: daemon client
|
build: daemon client
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ static void cat_file(guestfs_h *g, char *file_path, char **file_content, size_t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_guestfs(guestfs_h *g, char *disk_path) {
|
static guestfs_h* init_guestfs(char *disk_path) {
|
||||||
|
guestfs_h *g = NULL;
|
||||||
char **roots, **mountpoints;
|
char **roots, **mountpoints;
|
||||||
char *root;
|
char *root;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
@@ -85,12 +86,13 @@ static void init_guestfs(guestfs_h *g, char *disk_path) {
|
|||||||
free(roots);
|
free(roots);
|
||||||
|
|
||||||
printf("Finished initializing guestfs\n");
|
printf("Finished initializing guestfs\n");
|
||||||
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *worker_task(zsock_t *pipe, char *disk_path) {
|
static void *worker_task(zsock_t *pipe, char *disk_path) {
|
||||||
guestfs_h *g = NULL;
|
guestfs_h *g;
|
||||||
|
|
||||||
//init_guestfs(g, disk_path);
|
g = init_guestfs(disk_path);
|
||||||
|
|
||||||
// ZeroMQ Opens here
|
// ZeroMQ Opens here
|
||||||
zsock_signal(pipe, 0);
|
zsock_signal(pipe, 0);
|
||||||
@@ -106,6 +108,7 @@ static void *worker_task(zsock_t *pipe, char *disk_path) {
|
|||||||
|
|
||||||
printf("Size: %zu\tContent size: %zu\n", zmsg_size(msg), zmsg_content_size(msg));
|
printf("Size: %zu\tContent size: %zu\n", zmsg_size(msg), zmsg_content_size(msg));
|
||||||
struct guestfs_inpsect_command *command = zmsg_to_command(msg);
|
struct guestfs_inpsect_command *command = zmsg_to_command(msg);
|
||||||
|
printf("Size OF:: %zu\n", (sizeof(struct guestfs_inpsect_command)));
|
||||||
zmsg_t *reply = zmsg_new();
|
zmsg_t *reply = zmsg_new();
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
printf("wuddahec\n");
|
printf("wuddahec\n");
|
||||||
@@ -114,25 +117,21 @@ static void *worker_task(zsock_t *pipe, char *disk_path) {
|
|||||||
|
|
||||||
switch (command->command) {
|
switch (command->command) {
|
||||||
case GUESTFS_COMMAND_LS:
|
case GUESTFS_COMMAND_LS:
|
||||||
zmsg_pushstr(reply, "From worker!");
|
zmsg_pushstr(reply, "From worker! -- not implemented");
|
||||||
break;
|
break;
|
||||||
case GUESTFS_COMMAND_CAT:
|
case GUESTFS_COMMAND_CAT:
|
||||||
char *res;
|
char *res;
|
||||||
size_t s;
|
size_t s;
|
||||||
puts("catting file...");
|
puts("catting file...");
|
||||||
//cat_file(g, command->args.cat.paths[0], &res, &s);
|
cat_file(g, command->args.cat.paths[0], &res, &s);
|
||||||
init_guestfs(g, disk_path);
|
|
||||||
printf("STATUS::%d\n", guestfs_get_state(g));
|
|
||||||
if(guestfs_is_file_opts(g, "/etc/os-release", GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
|
|
||||||
res = guestfs_read_file(g, "/etc/os-release", &s);
|
|
||||||
}
|
|
||||||
puts("Done catting file contents...");
|
puts("Done catting file contents...");
|
||||||
zmsg_addmem(reply, res, s);
|
zmsg_addmem(reply, res, s);
|
||||||
|
free(res);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sending reply
|
// Sending reply
|
||||||
zmsg_send(&reply, pipe);
|
zmsg_send(&reply, pipe);
|
||||||
|
|
||||||
command_destroy(&command);
|
command_destroy(&command);
|
||||||
zmsg_destroy(&msg);
|
zmsg_destroy(&msg);
|
||||||
@@ -160,6 +159,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
worker_task(worker, path);
|
worker_task(worker, path);
|
||||||
|
|
||||||
|
zsock_destroy(&worker);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user