Move libkmod ifdef to beginning of file
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 12 Feb 2016 21:31:45 +0000 (16:31 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 16 Mar 2016 18:53:05 +0000 (14:53 -0400)
This will be useful to add the libkmod implementation of the
modprobe_remove_lttng() function in a single ifdef.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/modprobe.c

index 81ce8105a220be9568618ac07ceb032811432127..6f9a9978a75496f2510b9302b0b058008d3cc206 100644 (file)
@@ -90,81 +90,6 @@ static struct kern_modules_param *probes;
 static int nr_probes;
 static int probes_capacity;
 
-static void modprobe_remove_lttng(const struct kern_modules_param *modules,
-               int entries, int required)
-{
-       int ret = 0, i;
-       char modprobe[256];
-
-       for (i = entries - 1; i >= 0; i--) {
-               ret = snprintf(modprobe, sizeof(modprobe),
-                               "/sbin/modprobe -r -q %s",
-                               modules[i].name);
-               if (ret < 0) {
-                       PERROR("snprintf modprobe -r");
-                       return;
-               }
-               modprobe[sizeof(modprobe) - 1] = '\0';
-               ret = system(modprobe);
-               if (ret == -1) {
-                       ERR("Unable to launch modprobe -r for module %s",
-                                       modules[i].name);
-               } else if (required && WEXITSTATUS(ret) != 0) {
-                       ERR("Unable to remove module %s",
-                                       modules[i].name);
-               } else {
-                       DBG("Modprobe removal successful %s",
-                                       modules[i].name);
-               }
-       }
-}
-
-/*
- * Remove control kernel module(s) in reverse load order.
- */
-void modprobe_remove_lttng_control(void)
-{
-       modprobe_remove_lttng(kern_modules_control_core,
-                             ARRAY_SIZE(kern_modules_control_core),
-                             LTTNG_MOD_REQUIRED);
-}
-
-static void free_probes(void)
-{
-       int i;
-
-       if (!probes) {
-               return;
-       }
-       for (i = 0; i < nr_probes; ++i) {
-               free(probes[i].name);
-       }
-       free(probes);
-       probes = NULL;
-       nr_probes = 0;
-}
-
-/*
- * Remove data kernel modules in reverse load order.
- */
-void modprobe_remove_lttng_data(void)
-{
-       if (!probes) {
-               return;
-       }
-       modprobe_remove_lttng(probes, nr_probes, LTTNG_MOD_OPTIONAL);
-       free_probes();
-}
-
-/*
- * Remove all kernel modules in reverse order.
- */
-void modprobe_remove_lttng_all(void)
-{
-       modprobe_remove_lttng_data();
-       modprobe_remove_lttng_control();
-}
-
 #if HAVE_KMOD
 #include <libkmod.h>
 static void log_kmod(void *data, int priority, const char *file, int line,
@@ -280,6 +205,81 @@ error:
 
 #endif /* HAVE_KMOD */
 
+static void modprobe_remove_lttng(const struct kern_modules_param *modules,
+               int entries, int required)
+{
+       int ret = 0, i;
+       char modprobe[256];
+
+       for (i = entries - 1; i >= 0; i--) {
+               ret = snprintf(modprobe, sizeof(modprobe),
+                               "/sbin/modprobe -r -q %s",
+                               modules[i].name);
+               if (ret < 0) {
+                       PERROR("snprintf modprobe -r");
+                       return;
+               }
+               modprobe[sizeof(modprobe) - 1] = '\0';
+               ret = system(modprobe);
+               if (ret == -1) {
+                       ERR("Unable to launch modprobe -r for module %s",
+                                       modules[i].name);
+               } else if (required && WEXITSTATUS(ret) != 0) {
+                       ERR("Unable to remove module %s",
+                                       modules[i].name);
+               } else {
+                       DBG("Modprobe removal successful %s",
+                                       modules[i].name);
+               }
+       }
+}
+
+/*
+ * Remove control kernel module(s) in reverse load order.
+ */
+void modprobe_remove_lttng_control(void)
+{
+       modprobe_remove_lttng(kern_modules_control_core,
+                             ARRAY_SIZE(kern_modules_control_core),
+                             LTTNG_MOD_REQUIRED);
+}
+
+static void free_probes(void)
+{
+       int i;
+
+       if (!probes) {
+               return;
+       }
+       for (i = 0; i < nr_probes; ++i) {
+               free(probes[i].name);
+       }
+       free(probes);
+       probes = NULL;
+       nr_probes = 0;
+}
+
+/*
+ * Remove data kernel modules in reverse load order.
+ */
+void modprobe_remove_lttng_data(void)
+{
+       if (!probes) {
+               return;
+       }
+       modprobe_remove_lttng(probes, nr_probes, LTTNG_MOD_OPTIONAL);
+       free_probes();
+}
+
+/*
+ * Remove all kernel modules in reverse order.
+ */
+void modprobe_remove_lttng_all(void)
+{
+       modprobe_remove_lttng_data();
+       modprobe_remove_lttng_control();
+}
+
 /*
  * Load control kernel module(s).
  */
This page took 0.02629 seconds and 4 git commands to generate.