mirror of
https://github.com/AuxXxilium/kmod.git
synced 2024-12-27 13:55:35 +07:00
modprobe: kill operations depending on path
It was not on module-init-tools and it doesn't make much sense. It will deal with dependencies, but looking at modules in the index. This might not be the module we want if we are loading another from outside of the tree. Dealing with paths causes this bug (supposing there's a module names squashfs): # cd / # touch squashfs # modprobe squashfs That is because it detects that squashfs exists as a file and it will try to load it instead of the alias "squashfs". If you need to load a module from a path, use insmod. Thanks to Silvan Calarco <silvan.calarco@mambasoft.it> who reported the bug and helped debugging it.
This commit is contained in:
parent
a41b39fb69
commit
569f1609bd
@ -461,22 +461,7 @@ error:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int rmmod_path(struct kmod_ctx *ctx, const char *path)
|
||||
{
|
||||
struct kmod_module *mod;
|
||||
int err;
|
||||
|
||||
err = kmod_module_new_from_path(ctx, path, &mod);
|
||||
if (err < 0) {
|
||||
LOG("Module %s not found.\n", path);
|
||||
return err;
|
||||
}
|
||||
err = rmmod_do_module(mod, true);
|
||||
kmod_module_unref(mod);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int rmmod_alias(struct kmod_ctx *ctx, const char *alias)
|
||||
static int rmmod(struct kmod_ctx *ctx, const char *alias)
|
||||
{
|
||||
struct kmod_list *l, *list = NULL;
|
||||
int err;
|
||||
@ -500,14 +485,6 @@ static int rmmod_alias(struct kmod_ctx *ctx, const char *alias)
|
||||
return err;
|
||||
}
|
||||
|
||||
static int rmmod(struct kmod_ctx *ctx, const char *name)
|
||||
{
|
||||
if (access(name, F_OK) == 0)
|
||||
return rmmod_path(ctx, name);
|
||||
else
|
||||
return rmmod_alias(ctx, name);
|
||||
}
|
||||
|
||||
static int rmmod_all(struct kmod_ctx *ctx, char **args, int nargs)
|
||||
{
|
||||
int i, err = 0;
|
||||
@ -727,27 +704,6 @@ error:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int insmod_path(struct kmod_ctx *ctx, const char *path,
|
||||
const char *extra_options)
|
||||
{
|
||||
struct kmod_module *mod;
|
||||
struct array recursion;
|
||||
int err;
|
||||
|
||||
err = kmod_module_new_from_path(ctx, path, &mod);
|
||||
if (err < 0) {
|
||||
LOG("Module %s not found.\n", path);
|
||||
return err;
|
||||
}
|
||||
|
||||
array_init(&recursion, INSMOD_RECURSION_STEP);
|
||||
err = insmod_do_module(mod, extra_options, true, &recursion);
|
||||
kmod_module_unref(mod);
|
||||
array_free_array(&recursion);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int handle_failed_lookup(struct kmod_ctx *ctx, const char *alias)
|
||||
{
|
||||
struct kmod_module *mod;
|
||||
@ -776,7 +732,7 @@ static int handle_failed_lookup(struct kmod_ctx *ctx, const char *alias)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int insmod_alias(struct kmod_ctx *ctx, const char *alias,
|
||||
static int insmod(struct kmod_ctx *ctx, const char *alias,
|
||||
const char *extra_options)
|
||||
{
|
||||
struct kmod_list *l, *list = NULL;
|
||||
@ -823,16 +779,6 @@ static int insmod_alias(struct kmod_ctx *ctx, const char *alias,
|
||||
return err;
|
||||
}
|
||||
|
||||
static int insmod(struct kmod_ctx *ctx, const char *name,
|
||||
const char *extra_options)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(name, &st) == 0)
|
||||
return insmod_path(ctx, name, extra_options);
|
||||
else
|
||||
return insmod_alias(ctx, name, extra_options);
|
||||
}
|
||||
|
||||
static int insmod_all(struct kmod_ctx *ctx, char **args, int nargs)
|
||||
{
|
||||
int i, err = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user