summaryrefslogtreecommitdiffstats
path: root/ocaml/examples/lvs.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/examples/lvs.ml')
-rw-r--r--ocaml/examples/lvs.ml26
1 files changed, 26 insertions, 0 deletions
diff --git a/ocaml/examples/lvs.ml b/ocaml/examples/lvs.ml
new file mode 100644
index 00000000..12c7c15a
--- /dev/null
+++ b/ocaml/examples/lvs.ml
@@ -0,0 +1,26 @@
+(* An example using the OCaml bindings. *)
+
+open Printf
+
+let () =
+ if Array.length Sys.argv <= 1 || not (Sys.file_exists Sys.argv.(1)) then (
+ eprintf "Usage: lvs guest.img\n";
+ exit 1
+ );
+
+ let h = Guestfs.create () in
+ Guestfs.add_drive h Sys.argv.(1);
+ Guestfs.launch h;
+ Guestfs.wait_ready h;
+
+ let pvs = Guestfs.pvs h in
+ printf "PVs found: [ %s ]\n" (String.concat "; " (Array.to_list pvs));
+
+ let vgs = Guestfs.vgs h in
+ printf "VGs found: [ %s ]\n" (String.concat "; " (Array.to_list vgs));
+
+ let lvs = Guestfs.lvs h in
+ printf "LVs found: [ %s ]\n" (String.concat "; " (Array.to_list lvs));
+
+ (* Helps to find any allocation errors. *)
+ Gc.compact ()