Skip to content

Commit d877470

Browse files
ZhangGuoDongsmfrench
authored andcommitted
smb: move some duplicate definitions to common/cifsglob.h
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> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent b043220 commit d877470

3 files changed

Lines changed: 32 additions & 31 deletions

File tree

fs/smb/client/cifsglob.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "cifsacl.h"
2525
#include <crypto/internal/hash.h>
2626
#include <uapi/linux/cifs/cifs_mount.h>
27+
#include "../common/cifsglob.h"
2728
#include "../common/smb2pdu.h"
2829
#include "smb2pdu.h"
2930
#include <linux/filelock.h>
@@ -702,12 +703,6 @@ get_rfc1002_length(void *buf)
702703
return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
703704
}
704705

705-
static inline void
706-
inc_rfc1001_len(void *buf, int count)
707-
{
708-
be32_add_cpu((__be32 *)buf, count);
709-
}
710-
711706
struct TCP_Server_Info {
712707
struct list_head tcp_ses_list;
713708
struct list_head smb_ses_list;
@@ -1021,8 +1016,6 @@ compare_mid(__u16 mid, const struct smb_hdr *smb)
10211016
#define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
10221017
#define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)
10231018

1024-
#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
1025-
10261019
/*
10271020
* Windows only supports a max of 60kb reads and 65535 byte writes. Default to
10281021
* those values when posix extensions aren't in force. In actuality here, we
@@ -2148,30 +2141,20 @@ extern mempool_t cifs_io_request_pool;
21482141
extern mempool_t cifs_io_subrequest_pool;
21492142

21502143
/* Operations for different SMB versions */
2151-
#define SMB1_VERSION_STRING "1.0"
2152-
#define SMB20_VERSION_STRING "2.0"
21532144
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
21542145
extern struct smb_version_operations smb1_operations;
21552146
extern struct smb_version_values smb1_values;
21562147
extern struct smb_version_operations smb20_operations;
21572148
extern struct smb_version_values smb20_values;
21582149
#endif /* CIFS_ALLOW_INSECURE_LEGACY */
2159-
#define SMB21_VERSION_STRING "2.1"
21602150
extern struct smb_version_operations smb21_operations;
21612151
extern struct smb_version_values smb21_values;
2162-
#define SMBDEFAULT_VERSION_STRING "default"
21632152
extern struct smb_version_values smbdefault_values;
2164-
#define SMB3ANY_VERSION_STRING "3"
21652153
extern struct smb_version_values smb3any_values;
2166-
#define SMB30_VERSION_STRING "3.0"
21672154
extern struct smb_version_operations smb30_operations;
21682155
extern struct smb_version_values smb30_values;
2169-
#define SMB302_VERSION_STRING "3.02"
2170-
#define ALT_SMB302_VERSION_STRING "3.0.2"
21712156
/*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
21722157
extern struct smb_version_values smb302_values;
2173-
#define SMB311_VERSION_STRING "3.1.1"
2174-
#define ALT_SMB311_VERSION_STRING "3.11"
21752158
extern struct smb_version_operations smb311_operations;
21762159
extern struct smb_version_values smb311_values;
21772160

fs/smb/common/cifsglob.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* SPDX-License-Identifier: LGPL-2.1 */
2+
/*
3+
*
4+
* Copyright (C) International Business Machines Corp., 2002,2008
5+
* Author(s): Steve French (sfrench@us.ibm.com)
6+
* Jeremy Allison (jra@samba.org)
7+
*
8+
*/
9+
#ifndef _COMMON_CIFS_GLOB_H
10+
#define _COMMON_CIFS_GLOB_H
11+
12+
static inline void inc_rfc1001_len(void *buf, int count)
13+
{
14+
be32_add_cpu((__be32 *)buf, count);
15+
}
16+
17+
#define SMB1_VERSION_STRING "1.0"
18+
#define SMB20_VERSION_STRING "2.0"
19+
#define SMB21_VERSION_STRING "2.1"
20+
#define SMBDEFAULT_VERSION_STRING "default"
21+
#define SMB3ANY_VERSION_STRING "3"
22+
#define SMB30_VERSION_STRING "3.0"
23+
#define SMB302_VERSION_STRING "3.02"
24+
#define ALT_SMB302_VERSION_STRING "3.0.2"
25+
#define SMB311_VERSION_STRING "3.1.1"
26+
#define ALT_SMB311_VERSION_STRING "3.11"
27+
28+
#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
29+
30+
#endif /* _COMMON_CIFS_GLOB_H */

fs/smb/server/smb_common.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "glob.h"
1212
#include "nterr.h"
13+
#include "../common/cifsglob.h"
1314
#include "../common/smb2pdu.h"
1415
#include "smb2pdu.h"
1516

@@ -26,16 +27,8 @@
2627
#define SMB311_PROT 6
2728
#define BAD_PROT 0xFFFF
2829

29-
#define SMB1_VERSION_STRING "1.0"
30-
#define SMB20_VERSION_STRING "2.0"
31-
#define SMB21_VERSION_STRING "2.1"
32-
#define SMB30_VERSION_STRING "3.0"
33-
#define SMB302_VERSION_STRING "3.02"
34-
#define SMB311_VERSION_STRING "3.1.1"
35-
3630
#define SMB_ECHO_INTERVAL (60 * HZ)
3731

38-
#define CIFS_DEFAULT_IOSIZE (64 * 1024)
3932
#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
4033

4134
#define MAX_STREAM_PROT_LEN 0x00FFFFFF
@@ -464,9 +457,4 @@ static inline unsigned int get_rfc1002_len(void *buf)
464457
{
465458
return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
466459
}
467-
468-
static inline void inc_rfc1001_len(void *buf, int count)
469-
{
470-
be32_add_cpu((__be32 *)buf, count);
471-
}
472460
#endif /* __SMB_COMMON_H__ */

0 commit comments

Comments
 (0)