eed31a34dae33f4dc46d185655a17097364ae6fb
[libguestfs.git] / examples / df.c
1 /* A simple "df" command for guests. */
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <guestfs.h>
7
8 int
9 main (int argc, char *argv[])
10 {
11   guestfs_h *g;
12
13   if (argc != 2 || access (argv[1], F_OK) != 0) {
14     fprintf (stderr, "Usage: df disk-image\n");
15     exit (1);
16   }
17
18   if (!(g = guestfs_create ())) exit (1);
19
20   guestfs_set_verbose (g, 1);
21   if (guestfs_add_drive (g, argv[1]) == -1) exit (1);
22
23   if (guestfs_launch (g) == -1) exit (1);
24   if (guestfs_wait_ready (g) == -1) exit (1);
25
26
27
28   guestfs_close (g);
29   return 0;
30 }