Compare commits
4 Commits
9899945354
...
ac70e240c8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac70e240c8 | ||
|
|
991ffb5224 | ||
| 15322a601b | |||
| 6ca7727ee8 |
@@ -5,9 +5,11 @@
|
||||
#include <zactor.h>
|
||||
#include <guestfs.h>
|
||||
|
||||
#include "libguestfs-inspect.h"
|
||||
|
||||
#define STREQ(a, b) (strcmp((a), (b)) == 0)
|
||||
|
||||
static void *worker_task(char*);
|
||||
static void *worker_task(zsock_t*, char*);
|
||||
|
||||
char *endpoint(void);
|
||||
|
||||
@@ -34,7 +36,7 @@ static int count_mountpoints(char *const *argv) {
|
||||
return c;
|
||||
}
|
||||
|
||||
static void *worker_task(char *disk_path) {
|
||||
static void *worker_task(zsock_t *pipe, char *disk_path) {
|
||||
guestfs_h *g;
|
||||
char **roots, **mountpoints;
|
||||
char *root;
|
||||
@@ -50,9 +52,7 @@ static void *worker_task(char *disk_path) {
|
||||
}
|
||||
|
||||
// Adding disk_path to connection handle
|
||||
if (guestfs_add_drive_opts(g, disk_path,
|
||||
GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
|
||||
-1) == -1) {
|
||||
if (guestfs_add_drive_opts(g, disk_path, GUESTFS_ADD_DRIVE_OPTS_READONLY, 1, -1) == -1) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -86,8 +86,21 @@ static void *worker_task(char *disk_path) {
|
||||
}
|
||||
|
||||
// ZeroMQ Opens here
|
||||
for (;;) {
|
||||
zsock_signal(pipe, 0);
|
||||
while (true) {
|
||||
zmsg_t *message = zmsg_recv(pipe);
|
||||
if (message == NULL) {
|
||||
break;
|
||||
}
|
||||
// Process message
|
||||
|
||||
// do something here
|
||||
|
||||
// Sending reply
|
||||
zmsg_t *reply = zmsg_new();
|
||||
zmsg_addstr(reply, "Reply from worker");
|
||||
zmsg_send(&reply, pipe);
|
||||
zmsg_destroy(&message);
|
||||
}
|
||||
/*if (guestfs_is_file_opts(g, file_path, GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
|
||||
printf("--- %s ---\n", file_path);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
enum guestfs_inspect_command {
|
||||
GUESTFS_COMMAND_LS,
|
||||
/* GUESTFS_COMMAND_TOUCH, */
|
||||
/* GUESTFS_COMMAND_MKDIR, */
|
||||
GUESTFS_COMMAND_CAT
|
||||
};
|
||||
|
||||
struct guestfs_ls_args {
|
||||
size_t path_length;
|
||||
char path[];
|
||||
};
|
||||
struct guestfs_cat_args {};
|
||||
|
||||
struct guestfs_inpsect_command {
|
||||
enum guestfs_inspect_command command;
|
||||
union {
|
||||
struct guestfs_ls_args ls;
|
||||
struct guestfs_cat_args cat;
|
||||
} args;
|
||||
size_t name_length;
|
||||
char name[];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user