From 7afdd643a7d17bdb296d414c7d5e41ddc228be02 Mon Sep 17 00:00:00 2001 From: ChenXiaoSong Date: Fri, 19 Dec 2025 12:15:52 +0800 Subject: [PATCH 1/7] cifs.upcall: fix calloc() argument order in main() The function prototype of `calloc` is: void *calloc (size_t __nmemb, size_t __size) Fix the argument order to eliminate the build warning. Reported-by: Steve French Signed-off-by: ChenXiaoSong --- cifs.upcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cifs.upcall.c b/cifs.upcall.c index 69e27a3..08ee101 100644 --- a/cifs.upcall.c +++ b/cifs.upcall.c @@ -1719,7 +1719,7 @@ int main(const int argc, char *const argv[]) /* pack SecurityBlob and SessionKey into downcall packet */ datalen = sizeof(struct cifs_spnego_msg) + secblob.length + sess_key.length; - keydata = (struct cifs_spnego_msg *)calloc(sizeof(char), datalen); + keydata = (struct cifs_spnego_msg *)calloc(datalen, sizeof(char)); if (!keydata) { rc = 1; goto out; From 8f7cc60d529173fcc34e02e6c3600bff41384ad7 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 10 Sep 2025 19:07:48 +1000 Subject: [PATCH 2/7] docs: update username= option to drop invalid examples When hurrying and scanning the documentation, my eye was drawn to the examples ``user%password`` or ``workgroup/user`` and ``workgroup/user%password``, especially because they were rendered in bold in my terminal. I didn't read them in the context of them being deprecated and experienced a non-zero amount of frustration when they didn't work. Given that these no longer work at all, remove them and add clarity. Signed-off-by: Martin Schwenke Signed-off-by: Steve French --- mount.cifs.rst | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/mount.cifs.rst b/mount.cifs.rst index 52fe492..37e955d 100644 --- a/mount.cifs.rst +++ b/mount.cifs.rst @@ -57,17 +57,14 @@ username=arg|user=arg specifies the username to connect as. If this is not given, then the environment variable USER is used. - Earlier versions of mount.cifs also allowed one to specify the - username in a ``user%password`` or ``workgroup/user`` or - ``workgroup/user%password`` to allow the password and workgroup to - be specified as part of the username. Support for those alternate - username formats is now deprecated and should no longer be - used. Users should use the discrete ``password=`` and ``domain=`` to - specify those values. While some versions of the cifs kernel module - accept ``user=`` as an abbreviation for this option, its use can - confuse the standard mount program into thinking that this is a - non-superuser mount. It is therefore recommended to use the full - ``username=`` option name. + Users must use the discrete ``password=`` and ``domain=`` options to + specify relevant values. Including these in the ``username=`` option + is no longer supported. + + While some versions of the cifs kernel module accept ``user=`` as an + abbreviation for this option, its use can confuse the standard mount + program into thinking that this is a non-superuser mount. It is + therefore recommended to use the full ``username=`` option name. password=arg|pass=arg specifies the CIFS password. If this option is not given then the From b06ae254313015d30d4591a6dbf9c57d96897948 Mon Sep 17 00:00:00 2001 From: ChenXiaoSong Date: Wed, 17 Dec 2025 21:44:56 +0800 Subject: [PATCH 3/7] smbinfo: add notify subcommand Add `notify` subcommand to query a directory for change notifications. Example: ./smbinfo notify /mnt/dir # Then create a new file `/server/export/dir/file` on SMB server Notify completed, returned data_len is 20 00000000: 00 00 00 00 01 00 00 00 08 00 00 00 66 00 69 00 ............f.i. 00000010: 6c 00 65 00 l.e. Link: https://lore.kernel.org/linux-cifs/CAH2r5msHiZWzP5hdtPgb+wV3DL3J31RtgQRLQeuhCa_ULt3PfA@mail.gmail.com/ Suggested-by: Steve French Signed-off-by: ChenXiaoSong Signed-off-by: Steve French --- smbinfo | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ smbinfo.rst | 2 ++ 2 files changed, 71 insertions(+) diff --git a/smbinfo b/smbinfo index 2e9e42d..2be2395 100755 --- a/smbinfo +++ b/smbinfo @@ -27,6 +27,7 @@ import struct import stat import datetime import calendar +import threading VERBOSE = False @@ -36,6 +37,7 @@ CIFS_ENUMERATE_SNAPSHOTS = 0x800ccf06 CIFS_DUMP_KEY = 0xc03acf08 CIFS_DUMP_FULL_KEY = 0xc011cf0a CIFS_GET_TCON_INFO = 0x800ccf0c +CIFS_IOC_NOTIFY_INFO = 0xc009cf0b # large enough input buffer length INPUT_BUFFER_LENGTH = 16384 @@ -294,6 +296,10 @@ def main(): sap.add_argument("file") sap.set_defaults(func=cmd_gettconinfo) + sap = subp.add_parser("notify", help="Query a directory for change notifications") + sap.add_argument("file") + sap.set_defaults(func=cmd_notify) + # parse arguments args = ap.parse_args() @@ -905,5 +911,68 @@ def cmd_gettconinfo(args): print("TCON Id: 0x%x"%tcon.tid) print("Session Id: 0x%x"%tcon.session_id) +def cmd_notify(args): + thread = threading.Thread(target=notify_thread, args=(args,)) + thread.start() + + try: + thread.join() + except KeyboardInterrupt: + return False + +def notify_thread(args): + # See `struct smb3_notify_info` in linux kernel fs/smb/client/cifs_ioctl.h + completion_filter = 0xFFF + watch_tree = False + data_len = 1000 + + fmt = "= 8): + pad += " " * (pad_len // 8) + + # ASCII + ascii_part = "".join( + chr(x) if 31 < x < 127 else "." + for x in chunk + ) + + print(f"{offset:08x}: {hex_bytes}{pad} {ascii_part}") + if __name__ == '__main__': main() diff --git a/smbinfo.rst b/smbinfo.rst index 17270c5..91b8895 100644 --- a/smbinfo.rst +++ b/smbinfo.rst @@ -98,6 +98,8 @@ the SMB3 traffic of this mount can be decryped e.g. via wireshark `gettconinfo`: Prints both the TCON Id and Session Id for a cifs file. +`notify`: Query a directory for change notifications. + ***** NOTES ***** From fe5082bfc787a826ebbf1150fdeadfa3a49d0f6e Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 6 Jan 2026 11:11:22 -0600 Subject: [PATCH 4/7] Revert "smbinfo: add notify subcommand" This reverts commit b06ae254313015d30d4591a6dbf9c57d96897948. Newer version of patch now available --- smbinfo | 69 ----------------------------------------------------- smbinfo.rst | 2 -- 2 files changed, 71 deletions(-) diff --git a/smbinfo b/smbinfo index 2be2395..2e9e42d 100755 --- a/smbinfo +++ b/smbinfo @@ -27,7 +27,6 @@ import struct import stat import datetime import calendar -import threading VERBOSE = False @@ -37,7 +36,6 @@ CIFS_ENUMERATE_SNAPSHOTS = 0x800ccf06 CIFS_DUMP_KEY = 0xc03acf08 CIFS_DUMP_FULL_KEY = 0xc011cf0a CIFS_GET_TCON_INFO = 0x800ccf0c -CIFS_IOC_NOTIFY_INFO = 0xc009cf0b # large enough input buffer length INPUT_BUFFER_LENGTH = 16384 @@ -296,10 +294,6 @@ def main(): sap.add_argument("file") sap.set_defaults(func=cmd_gettconinfo) - sap = subp.add_parser("notify", help="Query a directory for change notifications") - sap.add_argument("file") - sap.set_defaults(func=cmd_notify) - # parse arguments args = ap.parse_args() @@ -911,68 +905,5 @@ def cmd_gettconinfo(args): print("TCON Id: 0x%x"%tcon.tid) print("Session Id: 0x%x"%tcon.session_id) -def cmd_notify(args): - thread = threading.Thread(target=notify_thread, args=(args,)) - thread.start() - - try: - thread.join() - except KeyboardInterrupt: - return False - -def notify_thread(args): - # See `struct smb3_notify_info` in linux kernel fs/smb/client/cifs_ioctl.h - completion_filter = 0xFFF - watch_tree = False - data_len = 1000 - - fmt = "= 8): - pad += " " * (pad_len // 8) - - # ASCII - ascii_part = "".join( - chr(x) if 31 < x < 127 else "." - for x in chunk - ) - - print(f"{offset:08x}: {hex_bytes}{pad} {ascii_part}") - if __name__ == '__main__': main() diff --git a/smbinfo.rst b/smbinfo.rst index 91b8895..17270c5 100644 --- a/smbinfo.rst +++ b/smbinfo.rst @@ -98,8 +98,6 @@ the SMB3 traffic of this mount can be decryped e.g. via wireshark `gettconinfo`: Prints both the TCON Id and Session Id for a cifs file. -`notify`: Query a directory for change notifications. - ***** NOTES ***** From b63b57dc8a874c7cfae678a9b6bfc37179b190a6 Mon Sep 17 00:00:00 2001 From: ChenXiaoSong Date: Sun, 21 Dec 2025 23:22:16 +0800 Subject: [PATCH 5/7] smbinfo: add notify subcommand Add `notify` subcommand to query a directory for change notifications. Example: ./smbinfo notify /mnt/dir # Then create a new file `/server/export/dir/file` on SMB server Notify completed, returned data_len is 20 00000000: 00 00 00 00 01 00 00 00 08 00 00 00 66 00 69 00 ............f.i. 00000010: 6c 00 65 00 l.e. # Call `ioctl()` again Press `Ctrl+C` to exit `smbinfo`. Link: https://lore.kernel.org/linux-cifs/CAH2r5msHiZWzP5hdtPgb+wV3DL3J31RtgQRLQeuhCa_ULt3PfA@mail.gmail.com/ Suggested-by: Steve French Signed-off-by: ChenXiaoSong Signed-off-by: Steve French --- smbinfo | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ smbinfo.rst | 2 ++ 2 files changed, 77 insertions(+) diff --git a/smbinfo b/smbinfo index 2e9e42d..381f318 100755 --- a/smbinfo +++ b/smbinfo @@ -27,6 +27,7 @@ import struct import stat import datetime import calendar +import threading VERBOSE = False @@ -36,6 +37,7 @@ CIFS_ENUMERATE_SNAPSHOTS = 0x800ccf06 CIFS_DUMP_KEY = 0xc03acf08 CIFS_DUMP_FULL_KEY = 0xc011cf0a CIFS_GET_TCON_INFO = 0x800ccf0c +CIFS_IOC_NOTIFY_INFO = 0xc009cf0b # large enough input buffer length INPUT_BUFFER_LENGTH = 16384 @@ -294,6 +296,10 @@ def main(): sap.add_argument("file") sap.set_defaults(func=cmd_gettconinfo) + sap = subp.add_parser("notify", help="Query a directory for change notifications") + sap.add_argument("file") + sap.set_defaults(func=cmd_notify) + # parse arguments args = ap.parse_args() @@ -905,5 +911,74 @@ def cmd_gettconinfo(args): print("TCON Id: 0x%x"%tcon.tid) print("Session Id: 0x%x"%tcon.session_id) +def cmd_notify(args): + thread = threading.Thread(target=notify_thread, args=(args,)) + thread.start() + + try: + thread.join() + except KeyboardInterrupt: + return False + +def notify_thread(args): + fmt = "= 8): + pad += " " * (pad_len // 8) + + # ASCII + ascii_part = "".join( + chr(x) if 31 < x < 127 else "." + for x in chunk + ) + + print(f"{offset:08x}: {hex_bytes}{pad} {ascii_part}") + if __name__ == '__main__': main() diff --git a/smbinfo.rst b/smbinfo.rst index 17270c5..91b8895 100644 --- a/smbinfo.rst +++ b/smbinfo.rst @@ -98,6 +98,8 @@ the SMB3 traffic of this mount can be decryped e.g. via wireshark `gettconinfo`: Prints both the TCON Id and Session Id for a cifs file. +`notify`: Query a directory for change notifications. + ***** NOTES ***** From 06505efe79854d47367fe3a25d6349bd4035de9c Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 7 Jan 2026 13:39:35 -0600 Subject: [PATCH 6/7] Revert "smbinfo: add notify subcommand" This reverts commit b63b57dc8a874c7cfae678a9b6bfc37179b190a6. --- smbinfo | 75 ----------------------------------------------------- smbinfo.rst | 2 -- 2 files changed, 77 deletions(-) diff --git a/smbinfo b/smbinfo index 381f318..2e9e42d 100755 --- a/smbinfo +++ b/smbinfo @@ -27,7 +27,6 @@ import struct import stat import datetime import calendar -import threading VERBOSE = False @@ -37,7 +36,6 @@ CIFS_ENUMERATE_SNAPSHOTS = 0x800ccf06 CIFS_DUMP_KEY = 0xc03acf08 CIFS_DUMP_FULL_KEY = 0xc011cf0a CIFS_GET_TCON_INFO = 0x800ccf0c -CIFS_IOC_NOTIFY_INFO = 0xc009cf0b # large enough input buffer length INPUT_BUFFER_LENGTH = 16384 @@ -296,10 +294,6 @@ def main(): sap.add_argument("file") sap.set_defaults(func=cmd_gettconinfo) - sap = subp.add_parser("notify", help="Query a directory for change notifications") - sap.add_argument("file") - sap.set_defaults(func=cmd_notify) - # parse arguments args = ap.parse_args() @@ -911,74 +905,5 @@ def cmd_gettconinfo(args): print("TCON Id: 0x%x"%tcon.tid) print("Session Id: 0x%x"%tcon.session_id) -def cmd_notify(args): - thread = threading.Thread(target=notify_thread, args=(args,)) - thread.start() - - try: - thread.join() - except KeyboardInterrupt: - return False - -def notify_thread(args): - fmt = "= 8): - pad += " " * (pad_len // 8) - - # ASCII - ascii_part = "".join( - chr(x) if 31 < x < 127 else "." - for x in chunk - ) - - print(f"{offset:08x}: {hex_bytes}{pad} {ascii_part}") - if __name__ == '__main__': main() diff --git a/smbinfo.rst b/smbinfo.rst index 91b8895..17270c5 100644 --- a/smbinfo.rst +++ b/smbinfo.rst @@ -98,8 +98,6 @@ the SMB3 traffic of this mount can be decryped e.g. via wireshark `gettconinfo`: Prints both the TCON Id and Session Id for a cifs file. -`notify`: Query a directory for change notifications. - ***** NOTES ***** From 8a2b68d625c9d4ec1a16794f9735fbed47a68eb0 Mon Sep 17 00:00:00 2001 From: ChenXiaoSong Date: Wed, 7 Jan 2026 12:31:08 +0800 Subject: [PATCH 7/7] smbinfo: add notify subcommand Add `notify` subcommand to query a directory for change notifications. Example: ./smbinfo notify /mnt/dir # Then create a new file `/server/export/dir/file` on SMB server Notify completed, returned data_len is 20 00000000: 00 00 00 00 01 00 00 00 08 00 00 00 66 00 69 00 ............f.i. 00000010: 6c 00 65 00 l.e. # Call `ioctl()` again Press `Ctrl+C` to exit `smbinfo`. Link: https://lore.kernel.org/linux-cifs/CAH2r5msHiZWzP5hdtPgb+wV3DL3J31RtgQRLQeuhCa_ULt3PfA@mail.gmail.com/ Suggested-by: Steve French Signed-off-by: ChenXiaoSong Signed-off-by: Steve French --- smbinfo | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ smbinfo.rst | 2 ++ 2 files changed, 80 insertions(+) diff --git a/smbinfo b/smbinfo index 2e9e42d..57e8a0a 100755 --- a/smbinfo +++ b/smbinfo @@ -27,6 +27,7 @@ import struct import stat import datetime import calendar +import threading VERBOSE = False @@ -36,6 +37,7 @@ CIFS_ENUMERATE_SNAPSHOTS = 0x800ccf06 CIFS_DUMP_KEY = 0xc03acf08 CIFS_DUMP_FULL_KEY = 0xc011cf0a CIFS_GET_TCON_INFO = 0x800ccf0c +CIFS_IOC_NOTIFY_INFO = 0xc009cf0b # large enough input buffer length INPUT_BUFFER_LENGTH = 16384 @@ -294,6 +296,10 @@ def main(): sap.add_argument("file") sap.set_defaults(func=cmd_gettconinfo) + sap = subp.add_parser("notify", help="Query a directory for change notifications") + sap.add_argument("file") + sap.set_defaults(func=cmd_notify) + # parse arguments args = ap.parse_args() @@ -905,5 +911,77 @@ def cmd_gettconinfo(args): print("TCON Id: 0x%x"%tcon.tid) print("Session Id: 0x%x"%tcon.session_id) +def cmd_notify(args): + try: + fd = os.open(args.file, os.O_RDONLY) + except Exception as e: + print("syscall failed: %s"%e) + return False + + thread = threading.Thread(target=notify_thread, args=(fd,)) + thread.start() + + try: + thread.join() + except KeyboardInterrupt: + pass + finally: + os.close(fd) + return False + +def notify_thread(fd): + fmt = "= 8: + pad += " " * (pad_len // 8) + + # ASCII + ascii_part = "".join( + chr(x) if 31 < x < 127 else "." + for x in chunk + ) + + print(f"{offset:08x}: {hex_bytes}{pad} {ascii_part}") + if __name__ == '__main__': main() diff --git a/smbinfo.rst b/smbinfo.rst index 17270c5..91b8895 100644 --- a/smbinfo.rst +++ b/smbinfo.rst @@ -98,6 +98,8 @@ the SMB3 traffic of this mount can be decryped e.g. via wireshark `gettconinfo`: Prints both the TCON Id and Session Id for a cifs file. +`notify`: Query a directory for change notifications. + ***** NOTES *****