]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/module.c
2 * Ceph - scalable distributed file system
4 * Copyright (C) 2014 Inktank Storage, Inc.
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
14 #include "include/compat.h"
19 #if defined(__FreeBSD__)
25 * TODO: Switch to libkmod when we abandon older platforms. The APIs
28 * - kmod_module_new_from_name() for obtaining handles;
29 * - kmod_module_probe_insert_module() for module_load();
30 * - kmod_module_get_info(), kmod_module_info_get_{key,value}() for
35 * Return command's exit status or -1 on error.
37 static int run_command(const char *command
)
41 status
= system(command
);
42 if (status
>= 0 && WIFEXITED(status
))
43 return WEXITSTATUS(status
);
47 char* errp
= ceph_strerror_r(errno
, error_buf
, sizeof(error_buf
));
48 fprintf(stderr
, "couldn't run '%s': %s\n", command
,
50 } else if (WIFSIGNALED(status
)) {
51 fprintf(stderr
, "'%s' killed by signal %d\n", command
,
54 fprintf(stderr
, "weird status from '%s': %d\n", command
,
61 int module_has_param(const char *module
, const char *param
)
65 snprintf(command
, sizeof(command
),
66 "/sbin/modinfo -F parm %s | /bin/grep -q ^%s:",
69 return run_command(command
) == 0;
72 int module_load(const char *module
, const char *options
)
76 snprintf(command
, sizeof(command
), "/sbin/modprobe %s %s",
77 module
, (options
? options
: ""));
79 return run_command(command
);
84 // We're stubbing out those functions, for now.
85 int module_has_param(const char *module
, const char *param
)
90 int module_load(const char *module
, const char *options
)