Blame SOURCES/0163-mllib-move-_exit-from-v2v-as-Exit-module.patch

e76f14
From 42c6c4c7130e4cc88458428edb0fb4654c52c2ab Mon Sep 17 00:00:00 2001
e76f14
From: Pino Toscano <ptoscano@redhat.com>
e76f14
Date: Wed, 3 Aug 2016 15:01:59 +0200
e76f14
Subject: [PATCH] mllib: move _exit from v2v as Exit module
e76f14
e76f14
Move the OCaml binding to C _exit to an own module.
e76f14
e76f14
Just code motion, adapting v2v in the process.
e76f14
e76f14
(cherry picked from commit 5077c020469827e104995cb2143d6d4eda981b9f)
e76f14
---
e76f14
 mllib/Makefile.am |  5 ++++-
e76f14
 mllib/exit-c.c    | 33 +++++++++++++++++++++++++++++++++
e76f14
 mllib/exit.ml     | 19 +++++++++++++++++++
e76f14
 mllib/exit.mli    | 20 ++++++++++++++++++++
e76f14
 po/POTFILES       |  2 +-
e76f14
 po/POTFILES-ml    |  1 +
e76f14
 v2v/Makefile.am   |  3 ++-
e76f14
 v2v/changeuid-c.c | 33 ---------------------------------
e76f14
 v2v/changeuid.ml  |  7 ++-----
e76f14
 9 files changed, 82 insertions(+), 41 deletions(-)
e76f14
 create mode 100644 mllib/exit-c.c
e76f14
 create mode 100644 mllib/exit.ml
e76f14
 create mode 100644 mllib/exit.mli
e76f14
 delete mode 100644 v2v/changeuid-c.c
e76f14
e76f14
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
e76f14
index 8807d86..22ee5db 100644
e76f14
--- a/mllib/Makefile.am
e76f14
+++ b/mllib/Makefile.am
e76f14
@@ -30,6 +30,7 @@ SOURCES_MLI = \
e76f14
 	common_utils.mli \
e76f14
 	curl.mli \
e76f14
 	dev_t.mli \
e76f14
+	exit.mli \
e76f14
 	fsync.mli \
e76f14
 	JSON.mli \
e76f14
 	mkdtemp.mli \
e76f14
@@ -55,12 +56,14 @@ SOURCES_ML = \
e76f14
 	regedit.ml \
e76f14
 	StatVFS.ml \
e76f14
 	JSON.ml \
e76f14
-	curl.ml
e76f14
+	curl.ml \
e76f14
+	exit.ml
e76f14
 
e76f14
 SOURCES_C = \
e76f14
 	../fish/progress.c \
e76f14
 	../fish/uri.c \
e76f14
 	dev_t-c.c \
e76f14
+	exit-c.c \
e76f14
 	fsync-c.c \
e76f14
 	mkdtemp-c.c \
e76f14
 	progress-c.c \
e76f14
diff --git a/mllib/exit-c.c b/mllib/exit-c.c
e76f14
new file mode 100644
e76f14
index 0000000..eed58a3
e76f14
--- /dev/null
e76f14
+++ b/mllib/exit-c.c
e76f14
@@ -0,0 +1,33 @@
e76f14
+/* libguestfs OCaml tools common code
e76f14
+ * Copyright (C) 2009-2016 Red Hat Inc.
e76f14
+ *
e76f14
+ * This program is free software; you can redistribute it and/or modify
e76f14
+ * it under the terms of the GNU General Public License as published by
e76f14
+ * the Free Software Foundation; either version 2 of the License, or
e76f14
+ * (at your option) any later version.
e76f14
+ *
e76f14
+ * This program is distributed in the hope that it will be useful,
e76f14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
+ * GNU General Public License for more details.
e76f14
+ *
e76f14
+ * You should have received a copy of the GNU General Public License along
e76f14
+ * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
+ */
e76f14
+
e76f14
+#include <config.h>
e76f14
+
e76f14
+#include <stdio.h>
e76f14
+#include <stdlib.h>
e76f14
+#include <unistd.h>
e76f14
+
e76f14
+#include <caml/mlvalues.h>
e76f14
+
e76f14
+extern int guestfs_int_mllib_exit (value rv) __attribute__((noreturn));
e76f14
+
e76f14
+int
e76f14
+guestfs_int_mllib_exit (value rv)
e76f14
+{
e76f14
+  _exit (Int_val (rv));
e76f14
+}
e76f14
diff --git a/mllib/exit.ml b/mllib/exit.ml
e76f14
new file mode 100644
e76f14
index 0000000..e752bfe
e76f14
--- /dev/null
e76f14
+++ b/mllib/exit.ml
e76f14
@@ -0,0 +1,19 @@
e76f14
+(* libguestfs OCaml tools common code
e76f14
+ * Copyright (C) 2016 Red Hat Inc.
e76f14
+ *
e76f14
+ * This program is free software; you can redistribute it and/or modify
e76f14
+ * it under the terms of the GNU General Public License as published by
e76f14
+ * the Free Software Foundation; either version 2 of the License, or
e76f14
+ * (at your option) any later version.
e76f14
+ *
e76f14
+ * This program is distributed in the hope that it will be useful,
e76f14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
+ * GNU General Public License for more details.
e76f14
+ *
e76f14
+ * You should have received a copy of the GNU General Public License along
e76f14
+ * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
+ *)
e76f14
+
e76f14
+external _exit : int -> unit = "guestfs_int_mllib_exit" "noalloc"
e76f14
diff --git a/mllib/exit.mli b/mllib/exit.mli
e76f14
new file mode 100644
e76f14
index 0000000..c1f0ab5
e76f14
--- /dev/null
e76f14
+++ b/mllib/exit.mli
e76f14
@@ -0,0 +1,20 @@
e76f14
+(* libguestfs OCaml tools common code
e76f14
+ * Copyright (C) 2016 Red Hat Inc.
e76f14
+ *
e76f14
+ * This program is free software; you can redistribute it and/or modify
e76f14
+ * it under the terms of the GNU General Public License as published by
e76f14
+ * the Free Software Foundation; either version 2 of the License, or
e76f14
+ * (at your option) any later version.
e76f14
+ *
e76f14
+ * This program is distributed in the hope that it will be useful,
e76f14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
+ * GNU General Public License for more details.
e76f14
+ *
e76f14
+ * You should have received a copy of the GNU General Public License along
e76f14
+ * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
+ *)
e76f14
+
e76f14
+val _exit : int -> unit
e76f14
+(** Call _exit directly, ie. do not run OCaml atexit handlers. *)
e76f14
diff --git a/po/POTFILES b/po/POTFILES
e76f14
index 98d4623..756fc5e 100644
e76f14
--- a/po/POTFILES
e76f14
+++ b/po/POTFILES
e76f14
@@ -265,6 +265,7 @@ lua/lua-guestfs.c
e76f14
 make-fs/make-fs.c
e76f14
 mllib/dev_t-c.c
e76f14
 mllib/dummy.c
e76f14
+mllib/exit-c.c
e76f14
 mllib/fsync-c.c
e76f14
 mllib/mkdtemp-c.c
e76f14
 mllib/progress-c.c
e76f14
@@ -369,7 +370,6 @@ utils/boot-benchmark/boot-benchmark-range.pl
e76f14
 utils/boot-benchmark/boot-benchmark.c
e76f14
 utils/qemu-boot/qemu-boot.c
e76f14
 utils/qemu-speed-test/qemu-speed-test.c
e76f14
-v2v/changeuid-c.c
e76f14
 v2v/domainxml-c.c
e76f14
 v2v/utils-c.c
e76f14
 v2v/xml-c.c
e76f14
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
e76f14
index f5e8eba..8b1cad7 100644
e76f14
--- a/po/POTFILES-ml
e76f14
+++ b/po/POTFILES-ml
e76f14
@@ -46,6 +46,7 @@ mllib/common_utils.ml
e76f14
 mllib/common_utils_tests.ml
e76f14
 mllib/curl.ml
e76f14
 mllib/dev_t.ml
e76f14
+mllib/exit.ml
e76f14
 mllib/fsync.ml
e76f14
 mllib/guestfs_config.ml
e76f14
 mllib/libdir.ml
e76f14
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
e76f14
index 73a2d68..0486cfe 100644
e76f14
--- a/v2v/Makefile.am
e76f14
+++ b/v2v/Makefile.am
e76f14
@@ -116,8 +116,8 @@ SOURCES_C = \
e76f14
 	../mllib/dev_t-c.c \
e76f14
 	../mllib/mkdtemp-c.c \
e76f14
 	../mllib/statvfs-c.c \
e76f14
+	../mllib/exit-c.c \
e76f14
 	domainxml-c.c \
e76f14
-	changeuid-c.c \
e76f14
 	utils-c.c \
e76f14
 	xml-c.c
e76f14
 
e76f14
@@ -146,6 +146,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/mkdtemp.cmo \
e76f14
 	$(top_builddir)/mllib/JSON.cmo \
e76f14
 	$(top_builddir)/mllib/StatVFS.cmo \
e76f14
+	$(top_builddir)/mllib/exit.cmo \
e76f14
 	$(top_builddir)/mllib/curl.cmo \
e76f14
 	$(top_builddir)/customize/customize_utils.cmo \
e76f14
 	$(top_builddir)/customize/firstboot.cmo \
e76f14
diff --git a/v2v/changeuid-c.c b/v2v/changeuid-c.c
e76f14
deleted file mode 100644
e76f14
index 0de5a30..0000000
e76f14
--- a/v2v/changeuid-c.c
e76f14
+++ /dev/null
e76f14
@@ -1,33 +0,0 @@
e76f14
-/* virt-v2v
e76f14
- * Copyright (C) 2009-2016 Red Hat Inc.
e76f14
- *
e76f14
- * This program is free software; you can redistribute it and/or modify
e76f14
- * it under the terms of the GNU General Public License as published by
e76f14
- * the Free Software Foundation; either version 2 of the License, or
e76f14
- * (at your option) any later version.
e76f14
- *
e76f14
- * This program is distributed in the hope that it will be useful,
e76f14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
- * GNU General Public License for more details.
e76f14
- *
e76f14
- * You should have received a copy of the GNU General Public License along
e76f14
- * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
- */
e76f14
-
e76f14
-#include <config.h>
e76f14
-
e76f14
-#include <stdio.h>
e76f14
-#include <stdlib.h>
e76f14
-#include <unistd.h>
e76f14
-
e76f14
-#include <caml/mlvalues.h>
e76f14
-
e76f14
-extern int v2v_exit (value rv) __attribute__((noreturn));
e76f14
-
e76f14
-int
e76f14
-v2v_exit (value rv)
e76f14
-{
e76f14
-  _exit (Int_val (rv));
e76f14
-}
e76f14
diff --git a/v2v/changeuid.ml b/v2v/changeuid.ml
e76f14
index 07cf6fb..53c0bc3 100644
e76f14
--- a/v2v/changeuid.ml
e76f14
+++ b/v2v/changeuid.ml
e76f14
@@ -33,9 +33,6 @@ type t = {
e76f14
 
e76f14
 let create ?uid ?gid () = { uid = uid; gid = gid }
e76f14
 
e76f14
-(* Call _exit directly, ie. do not run OCaml atexit handlers. *)
e76f14
-external _exit : int -> unit = "v2v_exit" "noalloc"
e76f14
-
e76f14
 let with_fork { uid = uid; gid = gid } name f =
e76f14
   let pid = fork () in
e76f14
 
e76f14
@@ -46,9 +43,9 @@ let with_fork { uid = uid; gid = gid } name f =
e76f14
     (try f ()
e76f14
      with exn ->
e76f14
        eprintf "%s: changeuid: %s: %s\n%!" prog name (Printexc.to_string exn);
e76f14
-       _exit 1
e76f14
+       Exit._exit 1
e76f14
     );
e76f14
-    _exit 0
e76f14
+    Exit._exit 0
e76f14
   );
e76f14
 
e76f14
   (* Parent. *)
e76f14
-- 
e76f14
1.8.3.1
e76f14