From 18c35c397d37144d4ec0e2815dc6333977397b91 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 2 Jun 2016 14:50:44 +0100
Subject: [PATCH] mllib: Add bindings for makedev(3), major(3) and minor(3).
(cherry picked from commit dd2ce98d242c0598a3bd484110f8cb0f9e88ec54)
---
mllib/Makefile.am | 3 +++
mllib/dev_t-c.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
mllib/dev_t.ml | 21 +++++++++++++++++++++
mllib/dev_t.mli | 28 ++++++++++++++++++++++++++++
po/POTFILES | 1 +
po/POTFILES-ml | 1 +
6 files changed, 106 insertions(+)
create mode 100644 mllib/dev_t-c.c
create mode 100644 mllib/dev_t.ml
create mode 100644 mllib/dev_t.mli
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index fc4dd95..e44abed 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -29,6 +29,7 @@ CLEANFILES = *~ *.annot *.cmi *.cmo *.cmx *.cmxa *.o
SOURCES_MLI = \
common_utils.mli \
curl.mli \
+ dev_t.mli \
fsync.mli \
JSON.mli \
mkdtemp.mli \
@@ -41,6 +42,7 @@ SOURCES_ML = \
guestfs_config.ml \
libdir.ml \
common_gettext.ml \
+ dev_t.ml \
common_utils.ml \
fsync.ml \
progress.ml \
@@ -54,6 +56,7 @@ SOURCES_ML = \
SOURCES_C = \
../fish/progress.c \
../fish/uri.c \
+ dev_t-c.c \
fsync-c.c \
mkdtemp-c.c \
progress-c.c \
diff --git a/mllib/dev_t-c.c b/mllib/dev_t-c.c
new file mode 100644
index 0000000..036b60d
--- /dev/null
+++ b/mllib/dev_t-c.c
@@ -0,0 +1,52 @@
+/* libguestfs OCaml tools common code
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include <caml/mlvalues.h>
+
+/* OCaml doesn't bind the dev_t calls makedev, major and minor. */
+
+extern value guestfs_int_mllib_dev_t_makedev (value majv, value minv);
+extern value guestfs_int_mllib_dev_t_major (value devv);
+extern value guestfs_int_mllib_dev_t_minor (value devv);
+
+/* NB: This is a "noalloc" call. */
+value
+guestfs_int_mllib_dev_t_makedev (value majv, value minv)
+{
+ return Val_int (makedev (Int_val (majv), Int_val (minv)));
+}
+
+/* NB: This is a "noalloc" call. */
+value
+guestfs_int_mllib_dev_t_major (value devv)
+{
+ return Val_int (major (Int_val (devv)));
+}
+
+/* NB: This is a "noalloc" call. */
+value
+guestfs_int_mllib_dev_t_minor (value devv)
+{
+ return Val_int (minor (Int_val (devv)));
+}
diff --git a/mllib/dev_t.ml b/mllib/dev_t.ml
new file mode 100644
index 0000000..143954a
--- /dev/null
+++ b/mllib/dev_t.ml
@@ -0,0 +1,21 @@
+(* libguestfs OCaml tools common code
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+external makedev : int -> int -> int = "guestfs_int_mllib_dev_t_makedev" "noalloc"
+external major : int -> int = "guestfs_int_mllib_dev_t_major" "noalloc"
+external minor : int -> int = "guestfs_int_mllib_dev_t_minor" "noalloc"
diff --git a/mllib/dev_t.mli b/mllib/dev_t.mli
new file mode 100644
index 0000000..340ead0
--- /dev/null
+++ b/mllib/dev_t.mli
@@ -0,0 +1,28 @@
+(* virt-resize
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+(** Bindings for [dev_t] related functions [makedev], [major] and [minor]. *)
+
+val makedev : int -> int -> int
+(** makedev(3) *)
+
+val major : int -> int
+(** major(3) *)
+
+val minor : int -> int
+(** minor(3) *)
diff --git a/po/POTFILES b/po/POTFILES
index ebee244..1252d8b 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -261,6 +261,7 @@ inspector/inspector.c
java/com_redhat_et_libguestfs_GuestFS.c
lua/lua-guestfs.c
make-fs/make-fs.c
+mllib/dev_t-c.c
mllib/dummy.c
mllib/fsync-c.c
mllib/mkdtemp-c.c
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index b7f3cc2..2b9bba1 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
@@ -43,6 +43,7 @@ mllib/common_gettext.ml
mllib/common_utils.ml
mllib/common_utils_tests.ml
mllib/curl.ml
+mllib/dev_t.ml
mllib/fsync.ml
mllib/guestfs_config.ml
mllib/libdir.ml
--
2.7.4