--- mllib/Makefile.am | 3 +++ mllib/dev_t-c.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ mllib/dev_t.ml | 21 +++++++++++++++++++++ mllib/dev_t.mli | 28 ++++++++++++++++++++++++++++ 4 files changed, 104 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 25f0081..5e30755 100644 --- a/mllib/Makefile.am +++ b/mllib/Makefile.am @@ -28,6 +28,7 @@ CLEANFILES = *~ *.annot *.cmi *.cmo *.cmx *.cmxa *.o SOURCES_MLI = \ common_utils.mli \ + dev_t.mli \ fsync.mli \ JSON.mli \ mkdtemp.mli \ @@ -40,6 +41,7 @@ SOURCES_ML = \ guestfs_config.ml \ libdir.ml \ common_gettext.ml \ + dev_t.ml \ common_utils.ml \ fsync.ml \ progress.ml \ @@ -52,6 +54,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) *) -- 2.7.4