public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: chenxiaosong.chenxiaosong@linux.dev
To: stfrench@microsoft.com, metze@samba.org, pali@kernel.org,
	linkinjeon@kernel.org, smfrench@gmail.com, sfrench@samba.org,
	senozhatsky@chromium.org, tom@talpey.com, pc@manguebit.org,
	ronniesahlberg@gmail.com, sprasad@microsoft.com,
	bharathsm@microsoft.com, christophe.jaillet@wanadoo.fr,
	zhangguodong@kylinos.cn
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
	ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h
Date: Tue, 14 Oct 2025 15:18:58 +0800	[thread overview]
Message-ID: <20251014071917.3004573-4-chenxiaosong.chenxiaosong@linux.dev> (raw)
In-Reply-To: <20251014071917.3004573-1-chenxiaosong.chenxiaosong@linux.dev>

From: ZhangGuoDong <zhangguodong@kylinos.cn>

In order to maintain the code more easily, move duplicate definitions to
new common header file.

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
 fs/smb/client/cifsglob.h   | 19 +------------------
 fs/smb/common/cifsglob.h   | 30 ++++++++++++++++++++++++++++++
 fs/smb/server/smb_common.h | 14 +-------------
 3 files changed, 32 insertions(+), 31 deletions(-)
 create mode 100644 fs/smb/common/cifsglob.h

diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 8f6f567d7474..c5034cf9ac9e 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -24,6 +24,7 @@
 #include "cifsacl.h"
 #include <crypto/internal/hash.h>
 #include <uapi/linux/cifs/cifs_mount.h>
+#include "../common/cifsglob.h"
 #include "../common/smb2pdu.h"
 #include "smb2pdu.h"
 #include <linux/filelock.h>
@@ -702,12 +703,6 @@ get_rfc1002_length(void *buf)
 	return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
 }
 
-static inline void
-inc_rfc1001_len(void *buf, int count)
-{
-	be32_add_cpu((__be32 *)buf, count);
-}
-
 struct TCP_Server_Info {
 	struct list_head tcp_ses_list;
 	struct list_head smb_ses_list;
@@ -1021,8 +1016,6 @@ compare_mid(__u16 mid, const struct smb_hdr *smb)
 #define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
 #define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)
 
-#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
-
 /*
  * Windows only supports a max of 60kb reads and 65535 byte writes. Default to
  * those values when posix extensions aren't in force. In actuality here, we
@@ -2148,30 +2141,20 @@ extern mempool_t cifs_io_request_pool;
 extern mempool_t cifs_io_subrequest_pool;
 
 /* Operations for different SMB versions */
-#define SMB1_VERSION_STRING	"1.0"
-#define SMB20_VERSION_STRING    "2.0"
 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
 extern struct smb_version_operations smb1_operations;
 extern struct smb_version_values smb1_values;
 extern struct smb_version_operations smb20_operations;
 extern struct smb_version_values smb20_values;
 #endif /* CIFS_ALLOW_INSECURE_LEGACY */
-#define SMB21_VERSION_STRING	"2.1"
 extern struct smb_version_operations smb21_operations;
 extern struct smb_version_values smb21_values;
-#define SMBDEFAULT_VERSION_STRING "default"
 extern struct smb_version_values smbdefault_values;
-#define SMB3ANY_VERSION_STRING "3"
 extern struct smb_version_values smb3any_values;
-#define SMB30_VERSION_STRING	"3.0"
 extern struct smb_version_operations smb30_operations;
 extern struct smb_version_values smb30_values;
-#define SMB302_VERSION_STRING	"3.02"
-#define ALT_SMB302_VERSION_STRING "3.0.2"
 /*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
 extern struct smb_version_values smb302_values;
-#define SMB311_VERSION_STRING	"3.1.1"
-#define ALT_SMB311_VERSION_STRING "3.11"
 extern struct smb_version_operations smb311_operations;
 extern struct smb_version_values smb311_values;
 
diff --git a/fs/smb/common/cifsglob.h b/fs/smb/common/cifsglob.h
new file mode 100644
index 000000000000..00fd215e3eb5
--- /dev/null
+++ b/fs/smb/common/cifsglob.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+/*
+ *
+ *   Copyright (C) International Business Machines  Corp., 2002,2008
+ *   Author(s): Steve French (sfrench@us.ibm.com)
+ *              Jeremy Allison (jra@samba.org)
+ *
+ */
+#ifndef _COMMON_CIFS_GLOB_H
+#define _COMMON_CIFS_GLOB_H
+
+static inline void inc_rfc1001_len(void *buf, int count)
+{
+	be32_add_cpu((__be32 *)buf, count);
+}
+
+#define SMB1_VERSION_STRING	"1.0"
+#define SMB20_VERSION_STRING    "2.0"
+#define SMB21_VERSION_STRING	"2.1"
+#define SMBDEFAULT_VERSION_STRING "default"
+#define SMB3ANY_VERSION_STRING "3"
+#define SMB30_VERSION_STRING	"3.0"
+#define SMB302_VERSION_STRING	"3.02"
+#define ALT_SMB302_VERSION_STRING "3.0.2"
+#define SMB311_VERSION_STRING	"3.1.1"
+#define ALT_SMB311_VERSION_STRING "3.11"
+
+#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
+
+#endif	/* _COMMON_CIFS_GLOB_H */
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index d742ba754348..863716207a0d 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -10,6 +10,7 @@
 
 #include "glob.h"
 #include "nterr.h"
+#include "../common/cifsglob.h"
 #include "../common/smb2pdu.h"
 #include "smb2pdu.h"
 
@@ -26,16 +27,8 @@
 #define SMB311_PROT		6
 #define BAD_PROT		0xFFFF
 
-#define SMB1_VERSION_STRING	"1.0"
-#define SMB20_VERSION_STRING	"2.0"
-#define SMB21_VERSION_STRING	"2.1"
-#define SMB30_VERSION_STRING	"3.0"
-#define SMB302_VERSION_STRING	"3.02"
-#define SMB311_VERSION_STRING	"3.1.1"
-
 #define SMB_ECHO_INTERVAL	(60 * HZ)
 
-#define CIFS_DEFAULT_IOSIZE	(64 * 1024)
 #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
 
 #define MAX_STREAM_PROT_LEN	0x00FFFFFF
@@ -464,9 +457,4 @@ static inline unsigned int get_rfc1002_len(void *buf)
 {
 	return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
 }
-
-static inline void inc_rfc1001_len(void *buf, int count)
-{
-	be32_add_cpu((__be32 *)buf, count);
-}
 #endif /* __SMB_COMMON_H__ */
-- 
2.43.0


  parent reply	other threads:[~2025-10-14  7:21 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14  7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
2025-10-14  7:18 ` [PATCH v3 01/22] smb/server: fix possible memory leak in smb2_read() chenxiaosong.chenxiaosong
2025-10-14  7:18 ` [PATCH v3 02/22] smb/server: fix possible refcount leak in smb2_sess_setup() chenxiaosong.chenxiaosong
2025-10-14  7:18 ` chenxiaosong.chenxiaosong [this message]
2025-10-20  4:39   ` [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h Namjae Jeon
2025-10-14  7:18 ` [PATCH v3 04/22] smb: move smb_version_values " chenxiaosong.chenxiaosong
2025-10-14  7:19 ` [PATCH v3 05/22] smb: move get_rfc1002_len() " chenxiaosong.chenxiaosong
2025-10-14  7:19 ` [PATCH v3 06/22] smb: move SMB1_PROTO_NUMBER " chenxiaosong.chenxiaosong
2025-10-14  7:19 ` [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h chenxiaosong.chenxiaosong
2025-10-20  4:52   ` Namjae Jeon
2025-10-26  9:20     ` ChenXiaoSong
2025-10-26 23:17       ` Namjae Jeon
2025-10-14  7:19 ` [PATCH v3 08/22] smb: move smb_sockaddr_in and smb_sockaddr_in6 " chenxiaosong.chenxiaosong
2025-10-14  7:19 ` [PATCH v3 09/22] smb: move copychunk definitions " chenxiaosong.chenxiaosong
2025-10-20  5:03   ` Namjae Jeon
2025-10-22  5:47     ` ChenXiaoSong
2025-10-14  7:19 ` [PATCH v3 10/22] smb: move resume_key_ioctl_rsp " chenxiaosong.chenxiaosong
2025-10-14  7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h chenxiaosong.chenxiaosong
2025-10-20  5:22     ` Namjae Jeon
2025-10-22  6:01       ` ChenXiaoSong
2025-10-14  7:28   ` [PATCH v3 13/22] smb: move file access permission bits " chenxiaosong.chenxiaosong
2025-10-20  5:27     ` Namjae Jeon
2025-10-22  5:55       ` ChenXiaoSong
2025-10-14  7:28   ` [PATCH v3 14/22] smb: move SMB frame " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO " chenxiaosong.chenxiaosong
2025-10-20  5:35     ` Namjae Jeon
2025-10-21  6:35       ` ChenXiaoSong
2025-10-21  6:36       ` ChenXiaoSong
2025-10-14  7:28   ` [PATCH v3 16/22] smb: move FILE_SYSTEM_DEVICE_INFO " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 17/22] smb: move FILE_SYSTEM_INFO " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 18/22] smb: move FILE_DIRECTORY_INFO " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 19/22] smb: move FILE_FULL_DIRECTORY_INFO " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 20/22] smb: move FILE_BOTH_DIRECTORY_INFO " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 21/22] smb: move SEARCH_ID_FULL_DIR_INFO " chenxiaosong.chenxiaosong
2025-10-14  7:28   ` [PATCH v3 22/22] smb: move FILE_SYSTEM_POSIX_INFO " chenxiaosong.chenxiaosong
2025-10-15  5:43 ` [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file Namjae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251014071917.3004573-4-chenxiaosong.chenxiaosong@linux.dev \
    --to=chenxiaosong.chenxiaosong@linux.dev \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=pali@kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=stfrench@microsoft.com \
    --cc=tom@talpey.com \
    --cc=zhangguodong@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox