linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libkmod-module: Remove directory existence check for KMOD_MODULE_BUILTIN
@ 2015-02-17 12:56 Harish Jenny K N
  2015-02-17 17:30 ` Lucas De Marchi
  0 siblings, 1 reply; 20+ messages in thread
From: Harish Jenny K N @ 2015-02-17 12:56 UTC (permalink / raw)
  To: linux-modules

usecase: two sd cards are being mounted in parallel at same time on
dual core. example modules which are getting loaded is nls_cp437.
While one module is being loaded , it starts creating sysfs files.
meanwhile on other core, modprobe might return saying the module
is KMOD_MODULE_BUILTIN, which might result in not mounting sd card.

Experiments done to prove the issue in kmod.
Added sleep in kernel module.c at the place of creation of sysfs files.
Then tried `modprobe nls_cp437` from two different shells.
While the first was still waiting for its completion ,
the second one returned saying the module is built-in.

built-in modules are handled by searching the modules.builtin file.
mod->builtin gets set and are handled in kmod_module_get_initstate function.
Removing the checking of the presence of /sys/module/<modulename>/
directory, which may not be required. It has to be added in other place
accordingly if required.

Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
---
 libkmod/libkmod-module.c |   13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 30f15ca..21c2a7e 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -1708,7 +1708,7 @@ KMOD_EXPORT const char *kmod_module_initstate_str(enum kmod_module_initstate sta
 KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
 {
 	char path[PATH_MAX], buf[32];
-	int fd, err, pathlen;
+	int fd, err;
 
 	if (mod == NULL)
 		return -ENOENT;
@@ -1716,7 +1716,7 @@ KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
 	if (mod->builtin)
 		return KMOD_MODULE_BUILTIN;
 
-	pathlen = snprintf(path, sizeof(path),
+	snprintf(path, sizeof(path),
 				"/sys/module/%s/initstate", mod->name);
 	fd = open(path, O_RDONLY|O_CLOEXEC);
 	if (fd < 0) {
@@ -1725,15 +1725,6 @@ KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
 		DBG(mod->ctx, "could not open '%s': %s\n",
 			path, strerror(-err));
 
-		if (pathlen > (int)sizeof("/initstate") - 1) {
-			struct stat st;
-			path[pathlen - (sizeof("/initstate") - 1)] = '\0';
-			if (stat(path, &st) == 0 && S_ISDIR(st.st_mode))
-				return KMOD_MODULE_BUILTIN;
-		}
-
-		DBG(mod->ctx, "could not open '%s': %s\n",
-			path, strerror(-err));
 		return err;
 	}
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-03-02  4:52 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-17 12:56 [PATCH] libkmod-module: Remove directory existence check for KMOD_MODULE_BUILTIN Harish Jenny K N
2015-02-17 17:30 ` Lucas De Marchi
2015-02-18  4:07   ` Rusty Russell
2015-02-18  6:10     ` Harish Jenny Kandiga Nagaraj
2015-02-18 16:50     ` Lucas De Marchi
2015-02-18 22:40       ` Rusty Russell
2015-02-19  1:19         ` Lucas De Marchi
2015-02-19  2:25           ` greg KH
2015-02-19  3:46             ` Lucas De Marchi
2015-02-19  2:25           ` Rusty Russell
2015-02-19  3:34             ` Lucas De Marchi
2015-02-19  5:49           ` Harish Jenny Kandiga Nagaraj
2015-02-19 10:30             ` Lucas De Marchi
2015-02-19 12:32               ` Harish Jenny Kandiga Nagaraj
2015-02-19 12:43                 ` Lucas De Marchi
2015-02-19 14:02                   ` Harish Jenny Kandiga Nagaraj
2015-02-19 14:35                     ` Harish Jenny Kandiga Nagaraj
2015-02-28 17:28                       ` Lucas De Marchi
2015-03-02  4:52                         ` Harish Jenny Kandiga Nagaraj
2015-02-19 12:33               ` Harish Jenny Kandiga Nagaraj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).