summaryrefslogtreecommitdiffstats
path: root/net/9p/mod.c
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2021-10-17 15:46:11 +0200
committerDominique Martinet <asmadeus@codewreck.org>2021-11-03 09:50:35 +0900
commit4cd82a5bb0f68236f67b1678bc9e6348a42241ed (patch)
tree07e99ec9f62849458007333e3e1c3c32fc66bc68 /net/9p/mod.c
parent27eb4c3144f7a5ebef3c9a261d80cb3e1fa784dc (diff)
downloadlinux-4cd82a5bb0f68236f67b1678bc9e6348a42241ed.tar.gz
linux-4cd82a5bb0f68236f67b1678bc9e6348a42241ed.tar.bz2
linux-4cd82a5bb0f68236f67b1678bc9e6348a42241ed.zip
net/9p: autoload transport modules
Automatically load transport modules based on the trans= parameter passed to mount. This removes the requirement for the user to know which module to use. Link: http://lkml.kernel.org/r/20211017134611.4330-1-linux@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Diffstat (limited to 'net/9p/mod.c')
-rw-r--r--net/9p/mod.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/net/9p/mod.c b/net/9p/mod.c
index 5126566850bd..aa38b8b0e0f6 100644
--- a/net/9p/mod.c
+++ b/net/9p/mod.c
@@ -12,6 +12,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
+#include <linux/kmod.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/moduleparam.h>
@@ -87,12 +88,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m)
}
EXPORT_SYMBOL(v9fs_unregister_trans);
-/**
- * v9fs_get_trans_by_name - get transport with the matching name
- * @s: string identifying transport
- *
- */
-struct p9_trans_module *v9fs_get_trans_by_name(char *s)
+static struct p9_trans_module *_p9_get_trans_by_name(char *s)
{
struct p9_trans_module *t, *found = NULL;
@@ -106,6 +102,28 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s)
}
spin_unlock(&v9fs_trans_lock);
+
+ return found;
+}
+
+/**
+ * v9fs_get_trans_by_name - get transport with the matching name
+ * @s: string identifying transport
+ *
+ */
+struct p9_trans_module *v9fs_get_trans_by_name(char *s)
+{
+ struct p9_trans_module *found = NULL;
+
+ found = _p9_get_trans_by_name(s);
+
+#ifdef CONFIG_MODULES
+ if (!found) {
+ request_module("9p-%s", s);
+ found = _p9_get_trans_by_name(s);
+ }
+#endif
+
return found;
}
EXPORT_SYMBOL(v9fs_get_trans_by_name);