ocaml: Bind guestfs_last_errno.
[libguestfs.git] / ocaml / guestfs_c.c
index 45b8eae..3f862ea 100644 (file)
@@ -52,6 +52,7 @@ CAMLprim value ocaml_guestfs_create (void);
 CAMLprim value ocaml_guestfs_close (value gv);
 CAMLprim value ocaml_guestfs_set_event_callback (value gv, value closure, value events);
 CAMLprim value ocaml_guestfs_delete_event_callback (value gv, value eh);
+value ocaml_guestfs_last_errno (value gv);
 value ocaml_guestfs_user_cancel (value gv);
 
 /* Allocate handles and deal with finalization. */
@@ -374,6 +375,24 @@ event_callback_wrapper (guestfs_h *g,
   CAMLreturn0;
 }
 
+value
+ocaml_guestfs_last_errno (value gv)
+{
+  CAMLparam1 (gv);
+  CAMLlocal1 (rv);
+  int r;
+  guestfs_h *g;
+
+  g = Guestfs_val (gv);
+  if (g == NULL)
+    ocaml_guestfs_raise_closed ("last_errno");
+
+  r = guestfs_last_errno (g);
+
+  rv = Val_int (r);
+  CAMLreturn (rv);
+}
+
 /* NB: This is and must remain a "noalloc" function. */
 value
 ocaml_guestfs_user_cancel (value gv)