summaryrefslogtreecommitdiffhomepage
path: root/modutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-08-03 08:23:33 +0000
committerEric Andersen <andersen@codepoet.org>2004-08-03 08:23:33 +0000
commit44b5758247cd42721e4bc681df5516e8f01dc8c7 (patch)
tree61adc1fcba8037e3e54414e225b3b91ed18e15a3 /modutils
parent93d7fba89288db6f9263c0ce8026f277bc4649e0 (diff)
William Barsse writes:
fixes two other issues (plus the previous as well) with a 2.4 kernel : - should be able to modprobe an already loaded module and get 0 return code : # modprobe <something> && modprobe <something> && echo "ok" || echo "failed" .... failed Well, hope this helps and that I didn't screw up again, - William
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 612e33a9e..e1e451943 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -368,15 +368,14 @@ static int mod_strcmp ( const char *mod_path, const char *mod_name )
#define MODULE_EXTENSION ".o"
#define MOD_EXTENSION_LEN 2
#endif
- if ((strstr (mod_path, mod_name) ==
- (mod_path + strlen(mod_path) -
- strlen(mod_name) - MOD_EXTENSION_LEN))
- && (!strcmp(mod_path + strlen(mod_path) -
- MOD_EXTENSION_LEN, MODULE_EXTENSION)))
- {
- return 1;
- }
- return 0;
+ /* last path component */
+ const char *last_comp = strrchr (mod_path, '/');
+
+ return (strncmp(last_comp ? last_comp + 1 : mod_path,
+ mod_name,
+ strlen(mod_name)) == 0 ) &&
+ (strcmp(mod_path + strlen(mod_path) -
+ MOD_EXTENSION_LEN, MODULE_EXTENSION) == 0);
}
/* return 1 = loaded, 0 = not loaded, -1 = can't tell */
@@ -409,7 +408,7 @@ static int already_loaded (const char *name)
static int mod_process ( struct mod_list_t *list, int do_insert )
{
char lcmd [256];
- int rc = 1;
+ int rc = 0;
while ( list ) {
*lcmd = '\0';