Files
guestfs-inspect/guestfs-inspectd.c
Robby Zambito c17ae09fb6 Add worker for each disk image specified
Remove loading the drive, that is the job of the worker.
2024-03-02 21:44:39 -05:00

43 lines
907 B
C

#include <stdio.h>
#include <stdlib.h>
#include <czmq.h>
#include <guestfs.h>
int main(int argc, char **argv) {
if (argc < 2) {
printf("Usage: %s <disk-path> ...\n", argv[0]);
return EXIT_FAILURE;
}
// One worker per disk image.
zactor_t *workers[argc-1];
char **filesystems = guestfs_list_filesystems(g);
if (filesystems == NULL)
return EXIT_FAILURE;
for (int i = 0; filesystems[i] != NULL; i += 2) {
printf("%s:%s is a %s filesystem\n",
argv[2], filesystems[i], filesystems[i+1]);
free(filesystems[i]);
free(filesystems[i+1]);
}
free(filesystems);
guestfs_mount(g, "/dev/sda3", "/");
char *passwd = guestfs_cat(g, "/etc/passwd");
printf("passwd contents:\n\n%s", passwd);
free(passwd);
/* Unmount everything. */
if (guestfs_umount_all(g) == -1)
return EXIT_FAILURE;
guestfs_shutdown(g);
return EXIT_SUCCESS;
}