libguestfs ocaml bindings

In addition to perl bindings, libguestfs now has 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));

which produces the following output:

$ ./lvs RHEL52PV32.img
PVs found: [ /dev/sda2 ]
VGs found: [ VolGroup00 ]
LVs found: [ /dev/VolGroup00/LogVol00; /dev/VolGroup00/LogVol01 ]

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.