X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fcommon%2Fmodule.c;fp=src%2Fceph%2Fsrc%2Fcommon%2Fmodule.c;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=f19f74324c752db7e6164c875c9c022a39fee2e8;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/common/module.c b/src/ceph/src/common/module.c deleted file mode 100644 index f19f743..0000000 --- a/src/ceph/src/common/module.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2014 Inktank Storage, Inc. - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include "acconfig.h" -#include -#include -#include -#include -#if defined(__FreeBSD__) -#include -#endif - -/* - * TODO: Switch to libkmod when we abandon older platforms. The APIs - * we want are: - * - * - kmod_module_new_from_name() for obtaining handles; - * - kmod_module_probe_insert_module() for module_load(); - * - kmod_module_get_info(), kmod_module_info_get_{key,value}() for - * module_has_param(). - */ - -/* - * Return command's exit status or -1 on error. - */ -static int run_command(const char *command) -{ - int status; - - status = system(command); - if (status >= 0 && WIFEXITED(status)) - return WEXITSTATUS(status); - - if (status < 0) { - char error_buf[80]; -#ifdef STRERROR_R_CHAR_P - char* dummy = strerror_r(errno, error_buf, sizeof(error_buf)); - (void)dummy; -#else - strerror_r(errno, error_buf, sizeof(error_buf)); -#endif - fprintf(stderr, "couldn't run '%s': %s\n", command, - error_buf); - } else if (WIFSIGNALED(status)) { - fprintf(stderr, "'%s' killed by signal %d\n", command, - WTERMSIG(status)); - } else { - fprintf(stderr, "weird status from '%s': %d\n", command, - status); - } - - return -1; -} - -int module_has_param(const char *module, const char *param) -{ - char command[128]; - - snprintf(command, sizeof(command), - "/sbin/modinfo -F parm %s | /bin/grep -q ^%s:", - module, param); - - return run_command(command) == 0; -} - -int module_load(const char *module, const char *options) -{ - char command[128]; - - snprintf(command, sizeof(command), "/sbin/modprobe %s %s", - module, (options ? options : "")); - - return run_command(command); -}