diff options
Diffstat (limited to 'ocaml')
-rw-r--r-- | ocaml/.depend | 5 | ||||
-rw-r--r-- | ocaml/META.in | 5 | ||||
-rw-r--r-- | ocaml/Makefile.am | 46 | ||||
-rw-r--r-- | ocaml/guestfs.ml | 110 | ||||
-rw-r--r-- | ocaml/guestfs.mli | 153 | ||||
-rw-r--r-- | ocaml/guestfs_c.c | 41 | ||||
-rw-r--r-- | ocaml/guestfs_c.h | 24 | ||||
-rw-r--r-- | ocaml/guestfs_c_actions.c | 147 |
8 files changed, 531 insertions, 0 deletions
diff --git a/ocaml/.depend b/ocaml/.depend new file mode 100644 index 00000000..2f840b0b --- /dev/null +++ b/ocaml/.depend @@ -0,0 +1,5 @@ +guestfs.cmi: +guestfs_internal.cmo: +guestfs_internal.cmx: +guestfs.cmo: guestfs.cmi +guestfs.cmx: guestfs.cmi diff --git a/ocaml/META.in b/ocaml/META.in new file mode 100644 index 00000000..43af4ad2 --- /dev/null +++ b/ocaml/META.in @@ -0,0 +1,5 @@ +name="guestfs" +version="@PACKAGE_VERSION@" +description="libguestfs bindings for OCaml" +archive(byte)="mlguestfs.cma" +archive(native)="mlguestfs.cmxa" diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 2b9e08ae..176bcec9 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -14,3 +14,49 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +if HAVE_OCAML + +EXTRA_DIST = \ + guestfs.mli guestfs.ml \ + guestfs_internal.ml \ + guestfs_c.c guestfs_c.h guestfs_c_actions.c \ + .depend META.in + +noinst_DATA = mlguestfs.cma mlguestfs.cmxa META + +mlguestfs.cma: guestfs_c.o guestfs_c_actions.o guestfs_internal.cmo guestfs.cmo + $(OCAMLMKLIB) -o mlguestfs $^ -lguestfs + +mlguestfs.cmxa: guestfs_c.o guestfs_c_actions.o guestfs_internal.cmx guestfs.cmx + $(OCAMLMKLIB) -o mlguestfs $^ -lguestfs + +guestfs_c.o: guestfs_c.c + $(CC) $(CFLAGS) -I$(OCAMLLIB) -c $< + +guestfs_c_actions.o: guestfs_c_actions.c + $(CC) $(CFLAGS) -I$(OCAMLLIB) -c $< + +.mli.cmi: + $(OCAMLFIND) ocamlc -c $< +.ml.cmo: + $(OCAMLFIND) ocamlc -c $< +.ml.cmx: + $(OCAMLFIND) ocamlopt -c $< + +depend: .depend + +.depend: $(wildcard *.mli) $(wildcard *.ml) + rm -f .depend + $(OCAMLFIND) ocamldep $^ > $@ + +include .depend + +SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly + +# Do the installation by hand, because we want to run ocamlfind. +install-data-hook: + $(OCAMLFIND) install -destdir $(DESTDIR) guestfs \ + META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli + +endif
\ No newline at end of file diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml new file mode 100644 index 00000000..ba6f0d64 --- /dev/null +++ b/ocaml/guestfs.ml @@ -0,0 +1,110 @@ +(* libguestfs generated file + * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. + * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. + * + * Copyright (C) 2009 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +type t +exception Error of string +external create : unit -> t = "ocaml_guestfs_create" +external close : t -> unit = "ocaml_guestfs_create" +external launch : t -> unit = "ocaml_guestfs_launch" +external wait_ready : t -> unit = "ocaml_guestfs_wait_ready" +external kill_subprocess : t -> unit = "ocaml_guestfs_kill_subprocess" +external add_drive : t -> string -> unit = "ocaml_guestfs_add_drive" +external add_cdrom : t -> string -> unit = "ocaml_guestfs_add_cdrom" +external config : t -> string -> string option -> unit = "ocaml_guestfs_config" +external set_path : t -> string option -> unit = "ocaml_guestfs_set_path" +external get_path : t -> string = "ocaml_guestfs_get_path" +external set_autosync : t -> bool -> unit = "ocaml_guestfs_set_autosync" +external get_autosync : t -> bool = "ocaml_guestfs_get_autosync" +external set_verbose : t -> bool -> unit = "ocaml_guestfs_set_verbose" +external get_verbose : t -> bool = "ocaml_guestfs_get_verbose" + +type lvm_pv = { + pv_name : string; + pv_uuid : string; + pv_fmt : string; + pv_size : int64; + dev_size : int64; + pv_free : int64; + pv_used : int64; + pv_attr : string; + pv_pe_count : int64; + pv_pe_alloc_count : int64; + pv_tags : string; + pe_start : int64; + pv_mda_count : int64; + pv_mda_free : int64; +} + +type lvm_vg = { + vg_name : string; + vg_uuid : string; + vg_fmt : string; + vg_attr : string; + vg_size : int64; + vg_free : int64; + vg_sysid : string; + vg_extent_size : int64; + vg_extent_count : int64; + vg_free_count : int64; + max_lv : int64; + max_pv : int64; + pv_count : int64; + lv_count : int64; + snap_count : int64; + vg_seqno : int64; + vg_tags : string; + vg_mda_count : int64; + vg_mda_free : int64; +} + +type lvm_lv = { + lv_name : string; + lv_uuid : string; + lv_attr : string; + lv_major : int64; + lv_minor : int64; + lv_kernel_major : int64; + lv_kernel_minor : int64; + lv_size : int64; + seg_count : int64; + origin : string; + snap_percent : float option; + copy_percent : float option; + move_pv : string; + lv_tags : string; + mirror_log : string; + modules : string; +} + +external cat : t -> string -> string = "ocaml_guestfs_cat" +external list_devices : t -> string list = "ocaml_guestfs_list_devices" +external list_partitions : t -> string list = "ocaml_guestfs_list_partitions" +external ll : t -> string -> string = "ocaml_guestfs_ll" +external ls : t -> string -> string list = "ocaml_guestfs_ls" +external lvs : t -> string list = "ocaml_guestfs_lvs" +external lvs_full : t -> lvm_lv list = "ocaml_guestfs_lvs_full" +external mount : t -> string -> string -> unit = "ocaml_guestfs_mount" +external pvs : t -> string list = "ocaml_guestfs_pvs" +external pvs_full : t -> lvm_pv list = "ocaml_guestfs_pvs_full" +external sync : t -> unit = "ocaml_guestfs_sync" +external touch : t -> string -> unit = "ocaml_guestfs_touch" +external vgs : t -> string list = "ocaml_guestfs_vgs" +external vgs_full : t -> lvm_vg list = "ocaml_guestfs_vgs_full" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli new file mode 100644 index 00000000..ba750368 --- /dev/null +++ b/ocaml/guestfs.mli @@ -0,0 +1,153 @@ +(* libguestfs generated file + * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. + * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. + * + * Copyright (C) 2009 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** For API documentation you should refer to the C API + in the guestfs(3) manual page. The OCaml API uses almost + exactly the same calls. *) + +type t +(** A [guestfs_h] handle. *) + +exception Error of string +(** This exception is raised when there is an error. *) + +val create : unit -> t + +val close : t -> unit +(** Handles are closed by the garbage collector when they become + unreferenced, but callers can also call this in order to + provide predictable cleanup. *) + +val launch : t -> unit +val wait_ready : t -> unit +val kill_subprocess : t -> unit + +val add_drive : t -> string -> unit +val add_cdrom : t -> string -> unit +val config : t -> string -> string option -> unit + +val set_path : t -> string option -> unit +val get_path : t -> string +val set_autosync : t -> bool -> unit +val get_autosync : t -> bool +val set_verbose : t -> bool -> unit +val get_verbose : t -> bool + +type lvm_pv = { + pv_name : string; + pv_uuid : string; + pv_fmt : string; + pv_size : int64; + dev_size : int64; + pv_free : int64; + pv_used : int64; + pv_attr : string; + pv_pe_count : int64; + pv_pe_alloc_count : int64; + pv_tags : string; + pe_start : int64; + pv_mda_count : int64; + pv_mda_free : int64; +} + +type lvm_vg = { + vg_name : string; + vg_uuid : string; + vg_fmt : string; + vg_attr : string; + vg_size : int64; + vg_free : int64; + vg_sysid : string; + vg_extent_size : int64; + vg_extent_count : int64; + vg_free_count : int64; + max_lv : int64; + max_pv : int64; + pv_count : int64; + lv_count : int64; + snap_count : int64; + vg_seqno : int64; + vg_tags : string; + vg_mda_count : int64; + vg_mda_free : int64; +} + +type lvm_lv = { + lv_name : string; + lv_uuid : string; + lv_attr : string; + lv_major : int64; + lv_minor : int64; + lv_kernel_major : int64; + lv_kernel_minor : int64; + lv_size : int64; + seg_count : int64; + origin : string; + snap_percent : float option; + copy_percent : float option; + move_pv : string; + lv_tags : string; + mirror_log : string; + modules : string; +} + +val cat : t -> string -> string +(** list the contents of a file *) + +val list_devices : t -> string list +(** list the block devices *) + +val list_partitions : t -> string list +(** list the partitions *) + +val ll : t -> string -> string +(** list the files in a directory (long format) *) + +val ls : t -> string -> string list +(** list the files in a directory *) + +val lvs : t -> string list +(** list the LVM logical volumes (LVs) *) + +val lvs_full : t -> lvm_lv list +(** list the LVM logical volumes (LVs) *) + +val mount : t -> string -> string -> unit +(** mount a guest disk at a position in the filesystem *) + +val pvs : t -> string list +(** list the LVM physical volumes (PVs) *) + +val pvs_full : t -> lvm_pv list +(** list the LVM physical volumes (PVs) *) + +val sync : t -> unit +(** sync disks, writes are flushed through to the disk image *) + +val touch : t -> string -> unit +(** update file timestamps or create a new file *) + +val vgs : t -> string list +(** list the LVM volume groups (VGs) *) + +val vgs_full : t -> lvm_vg list +(** list the LVM volume groups (VGs) *) + diff --git a/ocaml/guestfs_c.c b/ocaml/guestfs_c.c new file mode 100644 index 00000000..dda338fa --- /dev/null +++ b/ocaml/guestfs_c.c @@ -0,0 +1,41 @@ +/* libguestfs + * Copyright (C) 2009 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <stdlib.h> + +#include <guestfs.h> + +#include <caml/config.h> +#include <caml/alloc.h> +#include <caml/callback.h> +#include <caml/fail.h> +#include <caml/memory.h> +#include <caml/mlvalues.h> + +#include "guestfs_c.h" + +CAMLprim value +ocaml_guestfs_create (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +/* etc */ diff --git a/ocaml/guestfs_c.h b/ocaml/guestfs_c.h new file mode 100644 index 00000000..52b5aeaa --- /dev/null +++ b/ocaml/guestfs_c.h @@ -0,0 +1,24 @@ +/* libguestfs + * Copyright (C) 2009 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef GUESTFS_OCAML_C_H +#define GUESTFS_OCAML_C_H + + + +#endif /* GUESTFS_OCAML_C_H */ diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c new file mode 100644 index 00000000..b22e4d6e --- /dev/null +++ b/ocaml/guestfs_c_actions.c @@ -0,0 +1,147 @@ +/* libguestfs generated file + * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. + * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. + * + * Copyright (C) 2009 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <stdlib.h> + +#include <guestfs.h> + +#include <caml/config.h> +#include <caml/alloc.h> +#include <caml/callback.h> +#include <caml/fail.h> +#include <caml/memory.h> +#include <caml/mlvalues.h> + +#include "guestfs_c.h" + +CAMLprim value +ocaml_guestfs_cat (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_list_devices (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_list_partitions (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_ll (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_ls (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_lvs (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_lvs_full (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_mount (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_pvs (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_pvs_full (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_sync (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_touch (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_vgs (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + +CAMLprim value +ocaml_guestfs_vgs_full (value hv /* XXX */) +{ + CAMLparam1 (hv); /* XXX */ +/* XXX write something here */ + CAMLreturn (Val_unit); /* XXX */ +} + |