From: Michael Jeanson Date: Fri, 12 Feb 2016 21:31:45 +0000 (-0500) Subject: Move libkmod ifdef to beginning of file X-Git-Tag: v2.8.0-rc1~66 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=35e090b7b37c53e911e61007d0d08e424ab39470;p=lttng-tools.git Move libkmod ifdef to beginning of file This will be useful to add the libkmod implementation of the modprobe_remove_lttng() function in a single ifdef. Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c index 81ce8105a..6f9a9978a 100644 --- a/src/bin/lttng-sessiond/modprobe.c +++ b/src/bin/lttng-sessiond/modprobe.c @@ -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 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). */