9p/trans_fd: split into dedicated module
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 3 Nov 2021 19:38:21 +0000 (20:38 +0100)
committerDominique Martinet <asmadeus@codewreck.org>
Mon, 10 Jan 2022 00:58:30 +0000 (09:58 +0900)
This allows these transports only to be used when needed.

Link: https://lkml.kernel.org/r/20211103193823.111007-3-linux@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
[Dominique: Kconfig NET_9P_FD: -depends VIRTIO, +default NET_9P]
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
include/net/9p/9p.h
net/9p/Kconfig
net/9p/Makefile
net/9p/mod.c
net/9p/trans_fd.c

index 9c6ec78e47a5631445f35f9653b196d31a8338cc..24a509f559ee2b5210724a1117eb6be54679a056 100644 (file)
@@ -551,6 +551,4 @@ struct p9_fcall {
 int p9_errstr2errno(char *errstr, int len);
 
 int p9_error_init(void);
-int p9_trans_fd_init(void);
-void p9_trans_fd_exit(void);
 #endif /* NET_9P_H */
index 64468c49791f19244aaecea9c18745f318ef9877..deabbd376cb1cd70bb3d5a28c82d2ba08a1f7c15 100644 (file)
@@ -15,6 +15,13 @@ menuconfig NET_9P
 
 if NET_9P
 
+config NET_9P_FD
+       default NET_9P
+       tristate "9P FD Transport"
+       help
+         This builds support for transports over TCP, Unix sockets and
+         filedescriptors.
+
 config NET_9P_VIRTIO
        depends on VIRTIO
        tristate "9P Virtio Transport"
index aa0a5641e5d010a29860313b7cd2bf6fb60bc722..1df9b344c30bde875810db1c91dec2acd934ab2e 100644 (file)
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_NET_9P) := 9pnet.o
+obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o
 obj-$(CONFIG_NET_9P_XEN) += 9pnet_xen.o
 obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o
 obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o
@@ -9,9 +10,11 @@ obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o
        client.o \
        error.o \
        protocol.o \
-       trans_fd.o \
        trans_common.o \
 
+9pnet_fd-objs := \
+       trans_fd.o \
+
 9pnet_virtio-objs := \
        trans_virtio.o \
 
index c37fc201a944aaf1dc8216daf82fd826081bbb7e..521e0925fbd6a339cfb7700c85f8385ffb49bd39 100644 (file)
@@ -177,7 +177,6 @@ static int __init init_p9(void)
 
        p9_error_init();
        pr_info("Installing 9P2000 support\n");
-       p9_trans_fd_init();
 
        return ret;
 }
@@ -191,7 +190,6 @@ static void __exit exit_p9(void)
 {
        pr_info("Unloading 9P2000 support\n");
 
-       p9_trans_fd_exit();
        p9_client_exit();
 }
 
index 827c47620fc02328f7f6fb631e8a2aa4dd7a5b27..8f8f95e39b03a231d836808dbaf7c3ae4830afff 100644 (file)
@@ -1090,6 +1090,7 @@ static struct p9_trans_module p9_tcp_trans = {
        .show_options = p9_fd_show_options,
        .owner = THIS_MODULE,
 };
+MODULE_ALIAS_9P("tcp");
 
 static struct p9_trans_module p9_unix_trans = {
        .name = "unix",
@@ -1103,6 +1104,7 @@ static struct p9_trans_module p9_unix_trans = {
        .show_options = p9_fd_show_options,
        .owner = THIS_MODULE,
 };
+MODULE_ALIAS_9P("unix");
 
 static struct p9_trans_module p9_fd_trans = {
        .name = "fd",
@@ -1116,6 +1118,7 @@ static struct p9_trans_module p9_fd_trans = {
        .show_options = p9_fd_show_options,
        .owner = THIS_MODULE,
 };
+MODULE_ALIAS_9P("fd");
 
 /**
  * p9_poll_workfn - poll worker thread
@@ -1149,7 +1152,7 @@ static void p9_poll_workfn(struct work_struct *work)
        p9_debug(P9_DEBUG_TRANS, "finish\n");
 }
 
-int p9_trans_fd_init(void)
+static int __init p9_trans_fd_init(void)
 {
        v9fs_register_trans(&p9_tcp_trans);
        v9fs_register_trans(&p9_unix_trans);
@@ -1158,10 +1161,17 @@ int p9_trans_fd_init(void)
        return 0;
 }
 
-void p9_trans_fd_exit(void)
+static void __exit p9_trans_fd_exit(void)
 {
        flush_work(&p9_poll_work);
        v9fs_unregister_trans(&p9_tcp_trans);
        v9fs_unregister_trans(&p9_unix_trans);
        v9fs_unregister_trans(&p9_fd_trans);
 }
+
+module_init(p9_trans_fd_init);
+module_exit(p9_trans_fd_exit);
+
+MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>");
+MODULE_DESCRIPTION("Filedescriptor Transport for 9P");
+MODULE_LICENSE("GPL");