summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-15 13:59:07 +0100
committerRichard Jones <rjones@redhat.com>2009-04-15 13:59:07 +0100
commitad5abc8d367c9c410051062cae066b1b141b4c76 (patch)
tree9b22bc0900d83ac5a79a8bed7c3283f2fc742536 /ocaml
parentd5ae4a54e83018687ec05255bc39e7f5ab71a453 (diff)
downloadlibguestfs-ad5abc8d367c9c410051062cae066b1b141b4c76.tar.gz
libguestfs-ad5abc8d367c9c410051062cae066b1b141b4c76.tar.xz
libguestfs-ad5abc8d367c9c410051062cae066b1b141b4c76.zip
Generated code for tune2fs-l command and RHashtable return type.
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/guestfs.ml1
-rw-r--r--ocaml/guestfs.mli3
-rw-r--r--ocaml/guestfs_c_actions.c51
3 files changed, 55 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index f0344ac7..e29daea5 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -181,3 +181,4 @@ external command_lines : t -> string array -> string array = "ocaml_guestfs_comm
external stat : t -> string -> stat = "ocaml_guestfs_stat"
external lstat : t -> string -> stat = "ocaml_guestfs_lstat"
external statvfs : t -> string -> statvfs = "ocaml_guestfs_statvfs"
+external tune2fs_l : t -> string -> (string * string) list = "ocaml_guestfs_tune2fs_l"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index 30629681..e6f5231e 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -322,3 +322,6 @@ val lstat : t -> string -> stat
val statvfs : t -> string -> statvfs
(** get file system statistics *)
+val tune2fs_l : t -> string -> (string * string) list
+(** get ext2/ext3 superblock details *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 01fbcb06..b1c4652b 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -35,6 +35,33 @@
#include "guestfs_c.h"
+/* Copy a hashtable of string pairs into an assoc-list. We return
+ * the list in reverse order, but hashtables aren't supposed to be
+ * ordered anyway.
+ */
+static CAMLprim value
+copy_table (char * const * argv)
+{
+ CAMLparam0 ();
+ CAMLlocal5 (rv, pairv, kv, vv, cons);
+ int i;
+
+ rv = Val_int (0);
+ for (i = 0; argv[i] != NULL; i += 2) {
+ kv = caml_copy_string (argv[i]);
+ vv = caml_copy_string (argv[i+1]);
+ pairv = caml_alloc (2, 0);
+ Store_field (pairv, 0, kv);
+ Store_field (pairv, 1, vv);
+ cons = caml_alloc (2, 0);
+ Store_field (cons, 1, rv);
+ rv = cons;
+ Store_field (cons, 0, pairv);
+ }
+
+ CAMLreturn (rv);
+}
+
static CAMLprim value
copy_lvm_pv (const struct guestfs_lvm_pv *pv)
{
@@ -1881,3 +1908,27 @@ ocaml_guestfs_statvfs (value gv, value pathv)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_tune2fs_l (value gv, value devicev)
+{
+ CAMLparam2 (gv, devicev);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("tune2fs_l: used handle after closing it");
+
+ const char *device = String_val (devicev);
+ char **r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_tune2fs_l (g, device);
+ caml_leave_blocking_section ();
+ if (r == NULL)
+ ocaml_guestfs_raise_error (g, "tune2fs_l");
+
+ rv = copy_table (r);
+ free (r);
+ CAMLreturn (rv);
+}
+