From cc44ce530d2594e0bdbee3b8b2acfdf08c15bade Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Thu, 28 Mar 2024 08:18:35 +0900 Subject: [PATCH] ksmbd-tools: add support for durable handles As durable handles is supported in ksmbd kernel server, Add durable handles parameter in ksmbd-tools. I would like to make it default disable till it is stable. Signed-off-by: Namjae Jeon --- include/linux/ksmbd_server.h | 1 + ksmbd.conf.5.in | 5 +++++ ksmbd.conf.example | 1 + tools/config_parser.c | 10 ++++++++++ 4 files changed, 17 insertions(+) diff --git a/include/linux/ksmbd_server.h b/include/linux/ksmbd_server.h index 22224145..eb5a55f0 100644 --- a/include/linux/ksmbd_server.h +++ b/include/linux/ksmbd_server.h @@ -29,6 +29,7 @@ struct ksmbd_heartbeat { #define KSMBD_GLOBAL_FLAG_SMB3_ENCRYPTION (1 << 1) #define KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL (1 << 2) #define KSMBD_GLOBAL_FLAG_SMB3_ENCRYPTION_OFF (1 << 3) +#define KSMBD_GLOBAL_FLAG_DURABLE_HANDLES (1 << 4) struct ksmbd_startup_request { __u32 flags; diff --git a/ksmbd.conf.5.in b/ksmbd.conf.5.in index 478976bf..2fea4f34 100644 --- a/ksmbd.conf.5.in +++ b/ksmbd.conf.5.in @@ -76,6 +76,11 @@ Default: \fBdeadtime = 0\fR Octal bitmask that gets bitwise ANDed with DOS-to-UNIX-mapped permissions when creating a directory. Default: \fBdirectory mask = 0755\fR +.TP +\fBdurable handles\fR (G) +Can grant SMB2 durable file handles on a share. + +Default: \fBdurable handles = no\fR \" .TP \" \fBfollow symlinks\fR (S) \" diff --git a/ksmbd.conf.example b/ksmbd.conf.example index cf3c57d7..b7529384 100644 --- a/ksmbd.conf.example +++ b/ksmbd.conf.example @@ -31,6 +31,7 @@ smbd max io size = 8MB tcp port = 445 workgroup = WORKGROUP + durable handles = no ; default share parameters browseable = yes diff --git a/tools/config_parser.c b/tools/config_parser.c index 86e03386..faa4228e 100644 --- a/tools/config_parser.c +++ b/tools/config_parser.c @@ -518,6 +518,16 @@ static void process_global_conf_kv(char *k, char *v) KSMBD_CONF_MAX_CONNECTIONS; return; } + + if (!cp_key_cmp(k, "durable handles")) { + if (cp_get_group_kv_bool(v)) + global_conf.flags |= + KSMBD_GLOBAL_FLAG_DURABLE_HANDLES; + else + global_conf.flags &= + ~KSMBD_GLOBAL_FLAG_DURABLE_HANDLES; + return; + } } static void add_group_global_conf(void)