All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RFC: ksmbd: provide MODULE_VERSION()
@ 2025-05-31  6:42 Linus Walleij
  2025-05-31  6:56 ` Greg Kroah-Hartman
  2025-05-31 17:50 ` Steve French
  0 siblings, 2 replies; 11+ messages in thread
From: Linus Walleij @ 2025-05-31  6:42 UTC (permalink / raw)
  To: Namjae Jeon, Steve French, Sergey Senozhatsky, Tom Talpey
  Cc: linux-cifs, Greg Kroah-Hartman, Rosen Penev, Linus Walleij

Adding MODULE_VERSION("1.0") to ksmbd makes /sys/modules/ksmbd
appear even when ksmbd is compiled into the kernel.

Adding a version as a way to get a module name is documented in
Documentation/ABI/stable/sysfs-module.

This is nice when you boot a custom kernel on OpenWrt because
the startup script does things such as:

[ ! -e /sys/module/ksmbd ] && modprobe ksmbd 2> /dev/null
if [ ! -e /sys/module/ksmbd ]; then
    logger -p daemon.error -t 'ksmbd' "modprobe of ksmbd "
    "module failed, can\'t start ksmbd!"
     exit 1
fi

which makes the script not work with a compiled-in ksmbd.

Since I actually turn off modules and compile all my modules
into the kernel, I can't change the script to just check
cat /lib/modules/$(uname -r)/modules.builtin | grep ksmbd
either: no /lib/modules directory.

We define the string together with the version number for
the netlink, as they probably should be in tandem. Perhaps
this is a general nice thing to do.

An option would be to change the script to proceed and
just assume the module is compiled in but it feels wrong.

Cc: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 fs/smb/server/ksmbd_netlink.h | 1 +
 fs/smb/server/server.c        | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/fs/smb/server/ksmbd_netlink.h b/fs/smb/server/ksmbd_netlink.h
index 3f07a612c05b40a000151cef1117b918dc5da9ea..9ae6be7c7b116ab29277074089f2305e2b243594 100644
--- a/fs/smb/server/ksmbd_netlink.h
+++ b/fs/smb/server/ksmbd_netlink.h
@@ -58,6 +58,7 @@
 
 #define KSMBD_GENL_NAME		"SMBD_GENL"
 #define KSMBD_GENL_VERSION		0x01
+#define KSMBD_GENL_VERSION_STRING	"1.0"
 
 #define KSMBD_REQ_MAX_ACCOUNT_NAME_SZ	48
 #define KSMBD_REQ_MAX_HASH_SZ		18
diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c
index ab533c6029879fe8a972ebc85efc829ef0e0dcd3..332e3e39dc613d8a9077da0745eb1fb7a30b6bb5 100644
--- a/fs/smb/server/server.c
+++ b/fs/smb/server/server.c
@@ -632,5 +632,7 @@ MODULE_SOFTDEP("pre: aead2");
 MODULE_SOFTDEP("pre: ccm");
 MODULE_SOFTDEP("pre: gcm");
 MODULE_SOFTDEP("pre: crc32");
+/* MODULE_VERSION() Makes /sys/module/ksmbd appear when compiled-in */
+MODULE_VERSION(KSMBD_GENL_VERSION_STRING);
 module_init(ksmbd_server_init)
 module_exit(ksmbd_server_exit)

---
base-commit: 0ff41df1cb268fc69e703a08a57ee14ae967d0ca
change-id: 20250531-ksmbd-sysfs-module-efaf2d1a86ca

Best regards,
-- 
Linus Walleij <linus.walleij@linaro.org>


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

end of thread, other threads:[~2025-06-02  5:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-31  6:42 [PATCH] RFC: ksmbd: provide MODULE_VERSION() Linus Walleij
2025-05-31  6:56 ` Greg Kroah-Hartman
2025-05-31 19:37   ` Linus Walleij
2025-05-31 17:50 ` Steve French
2025-05-31 18:49   ` Paulo Alcantara
2025-06-01  7:41     ` Greg Kroah-Hartman
2025-06-01 18:54       ` Linus Walleij
2025-06-01 19:18         ` Steve French
2025-06-02  5:34         ` Greg Kroah-Hartman
2025-06-01 19:56       ` Paulo Alcantara
2025-06-01 19:59         ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.