small fix

This commit is contained in:
Pin
2024-03-05 20:40:11 -05:00
parent 20fc94fb35
commit 46d9500d3a
2 changed files with 13 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
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:
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

View File

@@ -38,7 +38,8 @@ static void cat_file(guestfs_h *g, char *file_path, char **file_content, size_t
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 *root;
size_t i, j;
@@ -85,12 +86,13 @@ static void init_guestfs(guestfs_h *g, char *disk_path) {
free(roots);
printf("Finished initializing guestfs\n");
return g;
}
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
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));
struct guestfs_inpsect_command *command = zmsg_to_command(msg);
printf("Size OF:: %zu\n", (sizeof(struct guestfs_inpsect_command)));
zmsg_t *reply = zmsg_new();
if (!reply) {
printf("wuddahec\n");
@@ -114,25 +117,21 @@ static void *worker_task(zsock_t *pipe, char *disk_path) {
switch (command->command) {
case GUESTFS_COMMAND_LS:
zmsg_pushstr(reply, "From worker!");
zmsg_pushstr(reply, "From worker! -- not implemented");
break;
case GUESTFS_COMMAND_CAT:
char *res;
size_t s;
puts("catting file...");
//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);
}
cat_file(g, command->args.cat.paths[0], &res, &s);
puts("Done catting file contents...");
zmsg_addmem(reply, res, s);
free(res);
break;
}
// Sending reply
zmsg_send(&reply, pipe);
zmsg_send(&reply, pipe);
command_destroy(&command);
zmsg_destroy(&msg);
@@ -160,6 +159,7 @@ int main(int argc, char **argv) {
worker_task(worker, path);
zsock_destroy(&worker);
return EXIT_SUCCESS;
}