X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmodprobe.c;h=5fed97bf992061ee4efd78c148c41ce83fc4646d;hb=1661351d4b89cad297122e8a4fe59d713ed3fda7;hp=d329bb9514905570a1c3a25c36c5a9672d4bf353;hpb=c9d424071aa532aa287fa86cfe02edbeded50e7b;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c index d329bb951..5fed97bf9 100644 --- a/src/bin/lttng-sessiond/modprobe.c +++ b/src/bin/lttng-sessiond/modprobe.c @@ -17,6 +17,7 @@ */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -98,8 +99,8 @@ static struct kern_modules_param *probes; static int nr_probes; static int probes_capacity; -void modprobe_remove_lttng(const struct kern_modules_param *modules, - int entries, int required) +static void modprobe_remove_lttng(const struct kern_modules_param *modules, + int entries, int required) { int ret = 0, i; char modprobe[256]; @@ -209,8 +210,16 @@ static int modprobe_lttng(struct kern_modules_param *modules, ret = kmod_module_probe_insert_module(mod, KMOD_PROBE_IGNORE_LOADED, NULL, NULL, NULL, NULL); - if (required && ret < 0) { - ERR("Unable to load module %s", modules[i].name); + if (ret < 0) { + if (required) { + ERR("Unable to load required module %s", + modules[i].name); + goto error; + } else { + DBG("Unable to load optional module %s; continuing", + modules[i].name); + ret = 0; + } } else { DBG("Modprobe successfully %s", modules[i].name); } @@ -245,10 +254,25 @@ static int modprobe_lttng(struct kern_modules_param *modules, modprobe[sizeof(modprobe) - 1] = '\0'; ret = system(modprobe); if (ret == -1) { - ERR("Unable to launch modprobe for module %s", - modules[i].name); - } else if (required && WEXITSTATUS(ret) != 0) { - ERR("Unable to load module %s", modules[i].name); + if (required) { + ERR("Unable to launch modprobe for required module %s", + modules[i].name); + goto error; + } else { + DBG("Unable to launch modprobe for optional module %s; continuing", + modules[i].name); + ret = 0; + } + } else if (WEXITSTATUS(ret) != 0) { + if (required) { + ERR("Unable to load required module %s", + modules[i].name); + goto error; + } else { + DBG("Unable to load optional module %s; continuing", + modules[i].name); + ret = 0; + } } else { DBG("Modprobe successfully %s", modules[i].name); }