diff options
author | rjones <rjones> | 2009-03-03 15:35:50 +0000 |
---|---|---|
committer | rjones <rjones> | 2009-03-03 15:35:50 +0000 |
commit | b6233d1fff5d9a6bbc61e7123a57bdd7d8cbc792 (patch) | |
tree | 4cd7d3feb9ff7c741a8524c6b9521c76524c4b81 /examples | |
parent | 407caabfd04a8bb6338a7fcf4f46d85d75e709df (diff) | |
download | libguestfs-b6233d1fff5d9a6bbc61e7123a57bdd7d8cbc792.tar.gz libguestfs-b6233d1fff5d9a6bbc61e7123a57bdd7d8cbc792.tar.xz libguestfs-b6233d1fff5d9a6bbc61e7123a57bdd7d8cbc792.zip |
Running qemu as a subprocess.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/.cvsignore | 5 | ||||
-rw-r--r-- | examples/LICENSE | 2 | ||||
-rw-r--r-- | examples/Makefile.am | 7 | ||||
-rw-r--r-- | examples/df.c | 36 |
4 files changed, 50 insertions, 0 deletions
diff --git a/examples/.cvsignore b/examples/.cvsignore new file mode 100644 index 00000000..d8d66249 --- /dev/null +++ b/examples/.cvsignore @@ -0,0 +1,5 @@ +.deps +.libs +Makefile +Makefile.in +df
\ No newline at end of file diff --git a/examples/LICENSE b/examples/LICENSE new file mode 100644 index 00000000..5ba695a6 --- /dev/null +++ b/examples/LICENSE @@ -0,0 +1,2 @@ +All the examples in the examples/ subdirectory may be freely copied +without any restrictions. diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 00000000..66a32d7b --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,7 @@ +# libguestfs examples + +noinst_PROGRAMS = df + +df_SOURCES = df.c +df_CFLAGS = -I$(top_builddir)/src +df_LDADD = $(top_builddir)/src/libguestfs.la diff --git a/examples/df.c b/examples/df.c new file mode 100644 index 00000000..818de6e7 --- /dev/null +++ b/examples/df.c @@ -0,0 +1,36 @@ +/* A simple "df" command for guests. */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <guestfs.h> + +int +main (int argc, char *argv[]) +{ + guestfs_h *g; + + if (argc != 2 || access (argv[1], F_OK) != 0) { + fprintf (stderr, "Usage: df disk-image\n"); + exit (1); + } + + g = guestfs_create (); + if (!g) { + perror ("guestfs_create"); + exit (1); + } + + guestfs_set_exit_on_error (g, 1); + guestfs_set_verbose (g, 1); + + guestfs_add_drive (g, argv[1]); + + guestfs_wait_ready (g); + + + + + guestfs_free (g); + return 0; +} |