diff options
author | Lee Duncan <lduncan@suse.com> | 2018-10-09 12:48:04 -0700 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2018-10-09 12:48:04 -0700 |
commit | 2da7176acc36e612dfefd5e75922cb3abe5d5fee (patch) | |
tree | c79b90dffafc82aa50e45d8632fa1219a7987b8b | |
parent | ab7d6f854588e08c9f352067c023577a3b82b82d (diff) | |
download | open-iscsi-2da7176acc36e612dfefd5e75922cb3abe5d5fee.tar.gz |
Use libkmod instead of fork/exec of modprobe.
There is no reason to continue to use fork/exec to probe
for modules, so remove the code that supported this.
-rw-r--r-- | libopeniscsiusr/iface.c | 38 | ||||
-rw-r--r-- | usr/transport.c | 52 |
2 files changed, 0 insertions, 90 deletions
diff --git a/libopeniscsiusr/iface.c b/libopeniscsiusr/iface.c index e2355bc..e7938a5 100644 --- a/libopeniscsiusr/iface.c +++ b/libopeniscsiusr/iface.c @@ -33,9 +33,7 @@ #include <sys/stat.h> #include <sys/wait.h> #include <stdbool.h> -#ifdef USE_KMOD #include <libkmod.h> -#endif #include <limits.h> #include "libopeniscsiusr/libopeniscsiusr.h" @@ -419,7 +417,6 @@ out: static int _load_kernel_module(struct iscsi_context *ctx, const char *drv_name) { -#ifdef USE_KMOD struct kmod_ctx *kctx = NULL; struct kmod_module *mod = NULL; int rc = LIBISCSI_OK; @@ -447,41 +444,6 @@ out: if (kctx != NULL) kmod_unref(kctx); return rc; - -#else - char *cmdline[4]; - pid_t pid = 0; - char strerr_buff[_STRERR_BUFF_LEN]; - int errno_save = 0; - - cmdline[0] = "/sbin/modprobe"; - cmdline[1] = "-qb"; - cmdline[2] = (char *) drv_name; - cmdline[3] = NULL; - - pid = fork(); - if (pid == 0) { - if (execv("/sbin/modprobe", cmdline) < 0) { - errno_save = errno; - _error(ctx, "Failed to load module %s, error %d: %s", - drv_name, errno_save, - _strerror(errno_save, strerr_buff)); - exit(-errno_save); - } - exit(0); - } else if (pid < 0) { - _error(ctx, "Failed to fork process to load module %s: %s", - drv_name, _strerror(errno_save, strerr_buff)); - return LIBISCSI_ERR_TRANS_NOT_FOUND; - } - - if (waitpid(pid, NULL, 0) < 0) { - _error(ctx, "Failed to load module %s", drv_name); - return LIBISCSI_ERR_TRANS_NOT_FOUND; - } - - return LIBISCSI_OK; -#endif } static int _iface_conf_write(struct iscsi_context *ctx, diff --git a/usr/transport.c b/usr/transport.c index 35a8ccd..4004582 100644 --- a/usr/transport.c +++ b/usr/transport.c @@ -19,9 +19,7 @@ #include <stdio.h> #include <unistd.h> #include <errno.h> -#ifdef USE_KMOD #include <libkmod.h> -#endif #include <net/if.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -192,7 +190,6 @@ free_ifni: * Most distros still do not have wide libkmod use, so * use modprobe for now */ -#ifdef USE_KMOD int transport_load_kmod(char *transport_name) { struct kmod_ctx *ctx; @@ -238,55 +235,6 @@ unref_mod: return rc; } -#else - -int transport_load_kmod(char *transport_name) -{ - char *cmdline[4]; - pid_t pid; - - cmdline[0] = "/sbin/modprobe"; - cmdline[1] = "-qb"; - cmdline[3] = NULL; - - /* - * dumb dumb mistake - named iscsi_tcp and ib_iser differently from - * transport name - */ - if (!strcmp(transport_name, "tcp")) - cmdline[2] = "iscsi_tcp"; - else if (!strcmp(transport_name, "iser")) - cmdline[2] = "ib_iser"; - else - cmdline[2] = transport_name; - - if (iscsi_sysfs_is_transport_loaded(cmdline[2])) - return 0; - - pid = fork(); - if (pid == 0) { - if (execv("/sbin/modprobe", cmdline) < 0) { - log_error("Failed to load module %s: %s", - transport_name, strerror(errno)); - exit(-errno); - } - exit(0); - } else if (pid < 0) { - log_error("Failed to fork process to load module %s: %s", - transport_name, strerror(errno)); - return ISCSI_ERR_TRANS_NOT_FOUND; - } - - if (waitpid(pid, NULL, 0) < 0) { - log_error("Failed to load module %s", transport_name); - return ISCSI_ERR_TRANS_NOT_FOUND; - } - - return 0; -} - -#endif - int set_transport_template(struct iscsi_transport *t) { struct iscsi_transport_template *tmpl; |