mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-17 06:04:23 +03:00
modprobe: check /sys/module entry first
Before executing modprobe for given module name, just check if the module is not already present in /sys/module. Useful when checking dm-cache-policy modules as we do not having matching interface like for targets.
This commit is contained in:
parent
ecae76c713
commit
aa91fe3d3c
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.152 -
|
Version 2.02.152 -
|
||||||
==================================
|
==================================
|
||||||
|
Check first /sys/module/dm_* dir existance before using modprobe.
|
||||||
Remove mpath from 10-dm.rules, superseded by 11-dm-mpath.rules (mpath>=0.6.0).
|
Remove mpath from 10-dm.rules, superseded by 11-dm-mpath.rules (mpath>=0.6.0).
|
||||||
|
|
||||||
Version 2.02.151 - 23rd April 2016
|
Version 2.02.151 - 23rd April 2016
|
||||||
|
@ -603,7 +603,24 @@ int module_present(struct cmd_context *cmd, const char *target_name)
|
|||||||
#ifdef MODPROBE_CMD
|
#ifdef MODPROBE_CMD
|
||||||
char module[128];
|
char module[128];
|
||||||
const char *argv[] = { MODPROBE_CMD, module, NULL };
|
const char *argv[] = { MODPROBE_CMD, module, NULL };
|
||||||
|
#endif
|
||||||
|
struct stat st;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
int i = dm_snprintf(path, (sizeof(path) - 1), "%smodule/dm_%s",
|
||||||
|
dm_sysfs_dir(), target_name);
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
while (path[--i] != '/') /* stop on dm_ */
|
||||||
|
if (path[i] == '-')
|
||||||
|
path[i] = '_'; /* replace '-' with '_' */
|
||||||
|
|
||||||
|
if ((lstat(path, &st) == 0) && S_ISDIR(st.st_mode)) {
|
||||||
|
log_debug("Module directory %s exists.", path);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MODPROBE_CMD
|
||||||
if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
|
if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
|
||||||
log_error("module_present module name too long: %s",
|
log_error("module_present module name too long: %s",
|
||||||
target_name);
|
target_name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user