ocaml/*.cmxa
ocaml/*.a
ocaml/*.so
+ocaml/examples/*.cmi
+ocaml/examples/*.cmo
+ocaml/examples/*.cmx
+ocaml/examples/lvs
perl/Guestfs.c
perl/Guestfs.bs
perl/Makefile-pl
dnl Produce output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile fish/Makefile examples/Makefile
- images/Makefile ocaml/Makefile perl/Makefile
+ images/Makefile
+ ocaml/Makefile ocaml/examples/Makefile
+ perl/Makefile
python/Makefile
make-initramfs.sh update-initramfs.sh
libguestfs.spec
rm -rf .deps .libs
popd
+# Same for ocaml/examples.
+pushd ocaml/examples
+make clean
+rm Makefile*
+popd
+
find $RPM_BUILD_ROOT -name perllocal.pod -delete
find $RPM_BUILD_ROOT -name .packlist -delete
%files ocaml-devel
%defattr(-,root,root,-)
+%doc ocaml/examples
%{_libdir}/ocaml/guestfs/*.a
%{_libdir}/ocaml/guestfs/*.cmxa
%{_libdir}/ocaml/guestfs/*.cmx
guestfs_c.c guestfs_c.h guestfs_c_actions.c \
.depend META.in
+SUBDIRS = examples
+
if HAVE_OCAML
noinst_DATA = mlguestfs.cma mlguestfs.cmxa META
--- /dev/null
+All the examples in the ocaml/examples/ subdirectory may be freely
+copied without any restrictions.
--- /dev/null
+EXTRA_DIST = LICENSE README lvs.ml
+
+if HAVE_OCAML
+
+lvs: lvs.ml
+ $(OCAMLFIND) ocamlopt -I .. mlguestfs.cmxa $< -o $@
+
+CLEANFILES = *.cmi *.cmo *.cmx *.o *~ lvs
+
+endif
\ No newline at end of file
--- /dev/null
+This directory contains various example programs which use the OCaml
+Guestfs bindings to the libguestfs API.
+
+As they are examples, these are licensed so they can be freely copied
+and used without any restrictions.
+
+Tips:
+
+(1) To enable verbose messages, set environment variable LIBGUESTFS_DEBUG=1
--- /dev/null
+(* 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 ()