smb: move duplicate definitions to common header file
Subsystems (2)
v5 cover smb: move duplicate definitions to common header file
From: ChenXiaoSong <[email protected]>
The following patches from v3 have already been merged into the mainline:
- 6fced056d2cc smb/server: fix possible memory leak in smb2_read()
- 379510a815cb smb/server: fix possible refcount leak in smb2_sess_setup()
- d877470b5991 smb: move some duplicate definitions to common/cifsglob.h
The following patches from v4 have been applied to [the ksmbd-for-next-next branch](https://git.samba.org/?p=ksmbd.git;a=shortlog;h=refs/heads/ksmbd-for-next-next):
- smb: move resume_key_ioctl_rsp to common/smb2pdu.h
- smb: move copychunk definitions to common/smb2pdu.h
- smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
- smb: move SMB1_PROTO_NUMBER to common/smbglob.h
- smb: move get_rfc1002_len() to common/smbglob.h
- smb: move smb_version_values to common/smbglob.h
- smb: rename common/cifsglob.h to common/smbglob.h
In order to maintain the code more easily, move some duplicate definitions to common header file.
Add some MS documentation references for macro and struct definitions.
I will test these code changes with smbtorure and xfstests as soon as possible.
By cleaning the common definitions for client and server, I've become more familiar with the MS documentation, which I believe will be very useful for developing SMB features soon.
v4->v5:
- The following modifications were made according to Namjae's and Steve's suggestions.
- Create patch #01 #02 #08.
- Patch #07: move struct smb_hdr to common/smb2pdu.h, do not move SET_FILE_READ_RIGHTS and SET_FILE_WRITE_RIGHTS.
- Patch #09 ~ #12: move definitions to common/fscc.h
- Patch #10: include all changes that only rename structures in this patch.
- Patch #11 #12: some cleanups.
v4: https://lore.kernel.org/all/[email protected]/
ChenXiaoSong (13):
smb/client: fix CAP_BULK_TRANSFER value
smb: move MAX_CIFS_SMALL_BUFFER_SIZE to common/smbglob.h
smb: move create_durable_req_v2 to common/smb2pdu.h
smb: move create_durable_handle_reconnect_v2 to common/smb2pdu.h
smb: move create_durable_rsp_v2 to common/smb2pdu.h smb/server: remove create_durable_reconn_req
smb: move SMB_NEGOTIATE_REQ to common/smb2pdu.h
smb: move list of FileSystemAttributes to common/fscc.h
smb: move some duplicate struct definitions to common/fscc.h
smb: move FILE_SYSTEM_SIZE_INFO to common/fscc.h
smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
smb: do some cleanups
smb: fix some warnings reported by scripts/checkpatch.pl
ZhangGuoDong (1):
smb: move some duplicate definitions to common/smb2pdu.h
fs/smb/client/cifsglob.h | 1 + fs/smb/client/cifspdu.h | 593 +++++++++++-------------------------- fs/smb/client/cifssmb.c | 12 +- fs/smb/client/connect.c | 4 +- fs/smb/client/inode.c | 4 +- fs/smb/client/ntlmssp.h | 8 +- fs/smb/client/readdir.c | 12 +- fs/smb/client/reparse.h | 8 +- fs/smb/client/rfc1002pdu.h | 8 +- fs/smb/client/smb1ops.c | 2 +- fs/smb/client/smb2inode.c | 2 +- fs/smb/client/smb2pdu.c | 16 +- fs/smb/client/smb2pdu.h | 69 ----- fs/smb/common/fscc.h | 179 +++++++++++ fs/smb/common/smb2pdu.h | 221 +++++++++++++- fs/smb/common/smbacl.h | 8 +- fs/smb/common/smbglob.h | 4 + fs/smb/server/oplock.c | 8 +- fs/smb/server/smb2ops.c | 6 +- fs/smb/server/smb2pdu.c | 116 ++++---- fs/smb/server/smb2pdu.h | 68 ----- fs/smb/server/smb_common.h | 237 +-------------- fs/smb/server/vfs.c | 2 +- 23 files changed, 682 insertions(+), 906 deletions(-) create mode 100644 fs/smb/common/fscc.h
Signature · 1 line
2.43.0
PATCH v5 1/14 smb/client: fix CAP_BULK_TRANSFER value
From: ChenXiaoSong <[email protected]>
See MS-CIFS 2.2.4.52.2.
Keep it consistent with the value in the documentation.
--- fs/smb/client/cifspdu.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/smb/client/cifspdu.h +7 -2
@@ -711,7 +711,12 @@ struct ntlmv2_resp {#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux" -/* Capabilities bits (for NTLM SessSetup request) */ + +/* +* Capabilities bits (for NTLM SessSetup request) +* See MS-CIFS 2.2.4.52.2 +* MS-SMB 2.2.4.5.2.1 +*/ #define CAP_UNICODE 0x00000004#define CAP_LARGE_FILES 0x00000008#define CAP_NT_SMBS 0x00000010
@@ -719,7 +724,7 @@ struct ntlmv2_resp {#define CAP_LEVEL_II_OPLOCKS 0x00000080#define CAP_NT_FIND 0x00000200/* reserved should be zero (because NT_SMBs implies the same thing?) */ -#define CAP_BULK_TRANSFER 0x20000000 +#define CAP_BULK_TRANSFER 0x00000400#define CAP_EXTENDED_SECURITY 0x80000000/* Action bits */
Signature · 1 line
2.43.0
PATCH v5 2/14 smb: move MAX_CIFS_SMALL_BUFFER_SIZE to common/smbglob.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to common header file.
By the way, add the copyright and author information for Namjae to common/smbglob.h.
--- fs/smb/client/cifspdu.h | 1 - fs/smb/common/smbglob.h | 4 ++++ fs/smb/server/smb_common.h | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-)
fs/smb/client/cifspdu.h +0 -1
@@ -86,7 +86,6 @@#define NT_TRANSACT_GET_USER_QUOTA 0x07#define NT_TRANSACT_SET_USER_QUOTA 0x08 -#define MAX_CIFS_SMALL_BUFFER_SIZE 448/* big enough for most */ /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */ /* among the requests (NTCreateX response is bigger with wct of 34) */ #define MAX_CIFS_HDR_SIZE 0x58/* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
fs/smb/common/smbglob.h +4 -0
@@ -2,8 +2,10 @@/* * * Copyright (C) International Business Machines Corp., 2002,2008 +* 2018 Samsung Electronics Co., Ltd. * Author(s): Steve French ([email protected]) * Jeremy Allison ([email protected]) +* Namjae Jeon ([email protected]) * */ #ifndef _COMMON_SMB_GLOB_H
@@ -65,4 +67,6 @@ static inline void inc_rfc1001_len(void *buf, int count)#define CIFS_DEFAULT_IOSIZE (1024 * 1024) +#define MAX_CIFS_SMALL_BUFFER_SIZE 448/* big enough for most */ +#endif /* _COMMON_SMB_GLOB_H */
fs/smb/server/smb_common.h +0 -2
@@ -29,8 +29,6 @@#define SMB_ECHO_INTERVAL (60 * HZ) -#define MAX_CIFS_SMALL_BUFFER_SIZE 448/* big enough for most */ -#define MAX_STREAM_PROT_LEN 0x00FFFFFF/* Responses when opening a file. */
Signature · 1 line
2.43.0
PATCH v5 3/14 smb: move create_durable_req_v2 to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Modify the following places:
- some fields in "struct create_durable_req_v2" -> struct durable_context_v2
- durable_context_v2 -> durable_context_v2_req
- create_durable_v2 -> create_durable_req_v2
Then move duplicate definitions to common header file.
--- fs/smb/client/smb2pdu.c | 14 +++++++------- fs/smb/client/smb2pdu.h | 12 ------------ fs/smb/common/smb2pdu.h | 14 ++++++++++++++ fs/smb/server/smb2pdu.c | 8 ++++---- fs/smb/server/smb2pdu.h | 9 --------- 5 files changed, 25 insertions(+), 32 deletions(-)
fs/smb/client/smb2pdu.c +7 -7
@@ -2424,21 +2424,21 @@ add_lease_context(struct TCP_Server_Info *server,return 0 ; } -static struct create_durable_v2 * +static struct create_durable_req_v2 *create_durable_v2_buf (struct cifs_open_parms *oparms) {struct cifs_fid *pfid = oparms->fid; -struct create_durable_v2 *buf; +struct create_durable_req_v2 *buf; - buf =kzalloc (sizeof (struct create_durable_v2 ),GFP_KERNEL ); + buf =kzalloc (sizeof (struct create_durable_req_v2 ),GFP_KERNEL );if (!buf)return NULL ; buf->ccontext.DataOffset =cpu_to_le16 (offsetof - (struct create_durable_v2 , dcontext)); - buf->ccontext.DataLength =cpu_to_le32 (sizeof (struct durable_context_v2 )); + (struct create_durable_req_v2 , dcontext)); + buf->ccontext.DataLength =cpu_to_le32 (sizeof (struct durable_context_v2_req )); buf->ccontext.NameOffset =cpu_to_le16 (offsetof - (struct create_durable_v2 , Name)); + (struct create_durable_req_v2 , Name)); buf->ccontext.NameLength =cpu_to_le16 (4 );/*
@@ -2508,7 +2508,7 @@ add_durable_v2_context(struct kvec *iov, unsigned int *num_iovec, iov[num].iov_base =create_durable_v2_buf (oparms);if (iov[num].iov_base ==NULL )return -ENOMEM ; - iov[num].iov_len =sizeof (struct create_durable_v2 ); + iov[num].iov_len =sizeof (struct create_durable_req_v2 ); *num_iovec = num +1 ;return 0 ; }
fs/smb/client/smb2pdu.h +0 -12
@@ -137,18 +137,6 @@ struct share_redirect_error_context_rsp {/* See MS-SMB2 2.2.13.2.11 */ /* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -struct durable_context_v2 { -__le32 Timeout; -__le32 Flags; -__u64 Reserved; -__u8 CreateGuid[16 ]; -} __packed; - -struct create_durable_v2 { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -struct durable_context_v2 dcontext; -} __packed;/* See MS-SMB2 2.2.13.2.12 */ struct durable_reconnect_context_v2 {
fs/smb/common/smb2pdu.h +14 -0
@@ -1290,6 +1290,20 @@ struct create_mxac_req {__le64 Timestamp; } __packed; +/* See MS-SMB2 2.2.13.2.11 */ +struct durable_context_v2_req { +__le32 Timeout; +__le32 Flags;/* see SMB2_DHANDLE_FLAG_PERSISTENT */ +__u64 Reserved; +__u8 CreateGuid[16 ]; +} __packed; + +struct create_durable_req_v2 { +struct create_context_hdr ccontext; +__u8 Name[8 ]; +struct durable_context_v2_req dcontext; +} __packed; +/* See MS-SMB2 2.2.14.2.5 */ struct create_mxac_rsp {struct create_context_hdr ccontext;
fs/smb/server/smb2pdu.c +4 -4
@@ -2816,7 +2816,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work, durable_v2_blob = (struct create_durable_req_v2 *)context;ksmbd_debug (SMB ,"Request for durable v2 open\n" ); - dh_info->fp =ksmbd_lookup_fd_cguid (durable_v2_blob->CreateGuid); + dh_info->fp =ksmbd_lookup_fd_cguid (durable_v2_blob->dcontext.CreateGuid);if (dh_info->fp) {if (!memcmp (conn->ClientGUID, dh_info->fp->client_guid,SMB2_CLIENT_GUID_SIZE )) {
@@ -2834,11 +2834,11 @@ static int parse_durable_handle_context(struct ksmbd_work *work,if ((lc && (lc->req_state &SMB2_LEASE_HANDLE_CACHING_LE )) || req_op_level ==SMB2_OPLOCK_LEVEL_BATCH ) { dh_info->CreateGuid = - durable_v2_blob->CreateGuid; + durable_v2_blob->dcontext.CreateGuid; dh_info->persistent = -le32_to_cpu (durable_v2_blob->Flags); +le32_to_cpu (durable_v2_blob->dcontext.Flags); dh_info->timeout = -le32_to_cpu (durable_v2_blob->Timeout); +le32_to_cpu (durable_v2_blob->dcontext.Timeout); dh_info->type = dh_idx; }break ;
fs/smb/server/smb2pdu.h +0 -9
@@ -66,15 +66,6 @@ struct preauth_integrity_info {/* Apple Defined Contexts */ #define SMB2_CREATE_AAPL "AAPL" -struct create_durable_req_v2 { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -__le32 Timeout; -__le32 Flags; -__u8 Reserved[8 ]; -__u8 CreateGuid[16 ]; -} __packed; -#define DURABLE_HANDLE_MAX_TIMEOUT 300000struct create_durable_reconn_req {
Signature · 1 line
2.43.0
PATCH v5 4/14 smb: move create_durable_handle_reconnect_v2 to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Modify the following places:
- some fields in "struct create_durable_reconn_v2_req" -> struct durable_reconnect_context_v2
- create_durable_reconn_v2_req -> create_durable_handle_reconnect_v2
Then move duplicate definitions to common header file.
--- fs/smb/client/smb2pdu.h | 17 ----------------- fs/smb/common/smb2pdu.h | 16 ++++++++++++++++ fs/smb/server/smb2pdu.c | 10 +++++----- fs/smb/server/smb2pdu.h | 11 ----------- 4 files changed, 21 insertions(+), 33 deletions(-)
fs/smb/client/smb2pdu.h +0 -17
@@ -138,29 +138,12 @@ struct share_redirect_error_context_rsp {/* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* See MS-SMB2 2.2.13.2.12 */ -struct durable_reconnect_context_v2 { -struct { -__u64 PersistentFileId; -__u64 VolatileFileId; - } Fid; -__u8 CreateGuid[16 ]; -__le32 Flags;/* see above DHANDLE_FLAG_PERSISTENT */ -} __packed; -/* See MS-SMB2 2.2.14.2.12 */ struct durable_reconnect_context_v2_rsp {__le32 Timeout;__le32 Flags;/* see above DHANDLE_FLAG_PERSISTENT */ } __packed; -struct create_durable_handle_reconnect_v2 { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -struct durable_reconnect_context_v2 dcontext; -__u8 Pad[4 ]; -} __packed; -/* See MS-SMB2 2.2.13.2.5 */ struct crt_twarp_ctxt {struct create_context_hdr ccontext;
fs/smb/common/smb2pdu.h +16 -0
@@ -1304,6 +1304,22 @@ struct create_durable_req_v2 {struct durable_context_v2_req dcontext; } __packed; +/* See MS-SMB2 2.2.13.2.12 */ +struct durable_reconnect_context_v2 { +struct { +__u64 PersistentFileId; +__u64 VolatileFileId; + } Fid; +__u8 CreateGuid[16 ]; +__le32 Flags;/* see SMB2_DHANDLE_FLAG_PERSISTENT */ +} __packed; + +struct create_durable_handle_reconnect_v2 { +struct create_context_hdr ccontext; +__u8 Name[8 ]; +struct durable_reconnect_context_v2 dcontext; +} __packed; +/* See MS-SMB2 2.2.14.2.5 */ struct create_mxac_rsp {struct create_context_hdr ccontext;
fs/smb/server/smb2pdu.c +5 -5
@@ -2726,7 +2726,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work,switch (dh_idx) {case DURABLE_RECONN_V2 : { -struct create_durable_reconn_v2_req *recon_v2; +struct create_durable_handle_reconnect_v2 *recon_v2;if (dh_info->type ==DURABLE_RECONN || dh_info->type ==DURABLE_REQ_V2 ) {
@@ -2736,13 +2736,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,if (le16_to_cpu (context->DataOffset) +le32_to_cpu (context->DataLength) < -sizeof (struct create_durable_reconn_v2_req )) { +sizeof (struct create_durable_handle_reconnect_v2 )) { err = -EINVAL ; goto out; } - recon_v2 = (struct create_durable_reconn_v2_req *)context; - persistent_id = recon_v2->Fid.PersistentFileId; + recon_v2 = (struct create_durable_handle_reconnect_v2 *)context; + persistent_id = recon_v2->dcontext.Fid.PersistentFileId; dh_info->fp =ksmbd_lookup_durable_fd (persistent_id);if (!dh_info->fp) {ksmbd_debug (SMB ,"Failed to get durable handle state\n" );
@@ -2750,7 +2750,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work, goto out; } -if (memcmp (dh_info->fp->create_guid, recon_v2->CreateGuid, +if (memcmp (dh_info->fp->create_guid, recon_v2->dcontext.CreateGuid,SMB2_CREATE_GUID_SIZE )) { err = -EBADF ;ksmbd_put_durable_fd (dh_info->fp);
fs/smb/server/smb2pdu.h +0 -11
@@ -80,17 +80,6 @@ struct create_durable_reconn_req { } Data; } __packed; -struct create_durable_reconn_v2_req { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -struct { -__u64 PersistentFileId; -__u64 VolatileFileId; - } Fid; -__u8 CreateGuid[16 ]; -__le32 Flags; -} __packed; -struct create_alloc_size_req {struct create_context_hdr ccontext;__u8 Name[8 ];
Signature · 1 line
2.43.0
PATCH v5 5/14 smb: move create_durable_rsp_v2 to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Modify the following places:
- some fields in "struct create_durable_v2_rsp" -> struct durable_context_v2_rsp
- durable_reconnect_context_v2_rsp -> durable_context_v2_rsp
- create_durable_v2_rsp -> create_durable_rsp_v2
Then move them to common header file.
--- fs/smb/client/smb2pdu.h | 6 ------ fs/smb/common/smb2pdu.h | 12 ++++++++++++ fs/smb/server/oplock.c | 8 ++++---- fs/smb/server/smb2ops.c | 6 +++--- fs/smb/server/smb2pdu.h | 6 ------ 5 files changed, 19 insertions(+), 19 deletions(-)
fs/smb/client/smb2pdu.h +0 -6
@@ -138,12 +138,6 @@ struct share_redirect_error_context_rsp {/* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* See MS-SMB2 2.2.14.2.12 */ -struct durable_reconnect_context_v2_rsp { -__le32 Timeout; -__le32 Flags;/* see above DHANDLE_FLAG_PERSISTENT */ -} __packed; -/* See MS-SMB2 2.2.13.2.5 */ struct crt_twarp_ctxt {struct create_context_hdr ccontext;
fs/smb/common/smb2pdu.h +12 -0
@@ -1320,6 +1320,18 @@ struct create_durable_handle_reconnect_v2 {struct durable_reconnect_context_v2 dcontext; } __packed; +/* See MS-SMB2 2.2.14.2.12 */ +struct durable_context_v2_rsp { +__le32 Timeout; +__le32 Flags;/* see SMB2_DHANDLE_FLAG_PERSISTENT */ +} __packed; + +struct create_durable_rsp_v2 { +struct create_context_hdr ccontext; +__u8 Name[8 ]; +struct durable_context_v2_rsp dcontext; +} __packed; +/* See MS-SMB2 2.2.14.2.5 */ struct create_mxac_rsp {struct create_context_hdr ccontext;
fs/smb/server/oplock.c +4 -4
@@ -1617,9 +1617,9 @@ void create_durable_rsp_buf(char *cc)*/ void create_durable_v2_rsp_buf (char *cc,struct ksmbd_file *fp) { -struct create_durable_v2_rsp *buf; +struct create_durable_rsp_v2 *buf; - buf = (struct create_durable_v2_rsp *)cc; + buf = (struct create_durable_rsp_v2 *)cc;memset (buf,0 ,sizeof (struct create_durable_rsp )); buf->ccontext.DataOffset =cpu_to_le16 (offsetof (struct create_durable_rsp , Data));
@@ -1633,9 +1633,9 @@ void create_durable_v2_rsp_buf(char *cc, struct ksmbd_file *fp) buf->Name[2 ] ='2' ; buf->Name[3 ] ='Q' ; - buf->Timeout =cpu_to_le32 (fp->durable_timeout); + buf->dcontext.Timeout =cpu_to_le32 (fp->durable_timeout);if (fp->is_persistent) - buf->Flags =cpu_to_le32 (SMB2_DHANDLE_FLAG_PERSISTENT ); + buf->dcontext.Flags =cpu_to_le32 (SMB2_DHANDLE_FLAG_PERSISTENT ); }/**
fs/smb/server/smb2ops.c +3 -3
@@ -59,7 +59,7 @@ static struct smb_version_values smb30_server_values = { .cap_large_files = SMB2_LARGE_FILES, .create_lease_size = sizeof(struct create_lease_v2), .create_durable_size = sizeof(struct create_durable_rsp), - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), .create_mxac_size = sizeof(struct create_mxac_rsp), .create_disk_id_size = sizeof(struct create_disk_id_rsp), .create_posix_size = sizeof(struct create_posix_rsp),
@@ -86,7 +86,7 @@ static struct smb_version_values smb302_server_values = { .cap_large_files = SMB2_LARGE_FILES, .create_lease_size = sizeof(struct create_lease_v2), .create_durable_size = sizeof(struct create_durable_rsp), - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), .create_mxac_size = sizeof(struct create_mxac_rsp), .create_disk_id_size = sizeof(struct create_disk_id_rsp), .create_posix_size = sizeof(struct create_posix_rsp),
@@ -113,7 +113,7 @@ static struct smb_version_values smb311_server_values = { .cap_large_files = SMB2_LARGE_FILES, .create_lease_size = sizeof(struct create_lease_v2), .create_durable_size = sizeof(struct create_durable_rsp), - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), .create_mxac_size = sizeof(struct create_mxac_rsp), .create_disk_id_size = sizeof(struct create_disk_id_rsp), .create_posix_size = sizeof(struct create_posix_rsp),
fs/smb/server/smb2pdu.h +0 -6
@@ -98,12 +98,6 @@ struct create_durable_rsp {/* See MS-SMB2 2.2.13.2.11 */ /* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -struct create_durable_v2_rsp { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -__le32 Timeout; -__le32 Flags; -} __packed;/* equivalent of the contents of SMB3.1.1 POSIX open context response */ struct create_posix_rsp {
Signature · 1 line
2.43.0
PATCH v5 6/14 smb/server: remove create_durable_reconn_req
In reply to [email protected]From: ChenXiaoSong <[email protected]>
The fields in struct create_durable_reconn_req and struct create_durable are exactly the same.
The documentation references are:
- SMB2_CREATE_DURABLE_HANDLE_REQUEST in MS-SMB2 2.2.13.2.3
- SMB2_CREATE_DURABLE_HANDLE_RECONNECT in MS-SMB2 2.2.13.2.4
- SMB2_FILEID in MS-SMB2 2.2.14.1
We can give these two structs a uniform name: create_durable.
Descriptions of the struct fields:
- __u8 Reserved[16]: DurableRequest field of SMB2_CREATE_DURABLE_HANDLE_REQUEST. A 16-byte field that MUST be reserved.
- __u64 PersistentFileId: Persistent field of 2.2.14.1 SMB2_FILEID
- __u64 VolatileFileId: Volatile field of 2.2.14.1 SMB2_FILEID
- struct Fid: Data field of SMB2_CREATE_DURABLE_HANDLE_RECONNECT.
An SMB2_FILEID structure, as specified in section 2.2.14.1.
--- fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb2pdu.h | 12 ------------ 2 files changed, 3 insertions(+), 15 deletions(-)
fs/smb/server/smb2pdu.c +3 -3
@@ -2766,7 +2766,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work, }case DURABLE_RECONN : { -struct create_durable_reconn_req *recon; +struct create_durable *recon;if (dh_info->type ==DURABLE_RECONN_V2 || dh_info->type ==DURABLE_REQ_V2 ) {
@@ -2776,12 +2776,12 @@ static int parse_durable_handle_context(struct ksmbd_work *work,if (le16_to_cpu (context->DataOffset) +le32_to_cpu (context->DataLength) < -sizeof (struct create_durable_reconn_req )) { +sizeof (struct create_durable )) { err = -EINVAL ; goto out; } - recon = (struct create_durable_reconn_req *)context; + recon = (struct create_durable *)context; persistent_id = recon->Data.Fid.PersistentFileId; dh_info->fp =ksmbd_lookup_durable_fd (persistent_id);if (!dh_info->fp) {
fs/smb/server/smb2pdu.h +0 -12
@@ -68,18 +68,6 @@ struct preauth_integrity_info {#define DURABLE_HANDLE_MAX_TIMEOUT 300000 -struct create_durable_reconn_req { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -union { -__u8 Reserved[16 ]; -struct { -__u64 PersistentFileId; -__u64 VolatileFileId; - } Fid; - } Data; -} __packed; -struct create_alloc_size_req {struct create_context_hdr ccontext;__u8 Name[8 ];
Signature · 1 line
2.43.0
Namjae Jeon
maintainerRe: [PATCH v5 06/14] smb/server: remove create_durable_reconn_req
Quoted 6 lines · On Sun, Nov 2, 2025 at 4:32 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
The fields in struct
create_durable_reconn_reqand structcreate_durableare exactly the same.
Quoted 7 lines
The documentation references are:
-
SMB2_CREATE_DURABLE_HANDLE_REQUESTin MS-SMB2 2.2.13.2.3
-SMB2_CREATE_DURABLE_HANDLE_RECONNECTin MS-SMB2 2.2.13.2.4
-SMB2_FILEIDin MS-SMB2 2.2.14.1We can give these two structs a uniform name:
create_durable.
Please use typedef to define multiple aliases for a single struct. typedef struct {
...
} create_durable, create_durable_reconn_req;
Thanks.
ChenXiaoSong
reviewerRe: [PATCH v5 06/14] smb/server: remove create_durable_reconn_req
Okay, I'll make the changes.
Once you've applied some of the patches from this version, I'll immediately send the next version.
Thanks,
ChenXiaoSong.
Quoted 20 lines · Namjae Jeon
Quoted 6 lines · On Sun, Nov 2, 2025 at 4:32 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
The fields in struct
create_durable_reconn_reqand structcreate_durableare exactly the same.Quoted 7 lines
The documentation references are:
-
SMB2_CREATE_DURABLE_HANDLE_REQUESTin MS-SMB2 2.2.13.2.3
-SMB2_CREATE_DURABLE_HANDLE_RECONNECTin MS-SMB2 2.2.13.2.4
-SMB2_FILEIDin MS-SMB2 2.2.14.1We can give these two structs a uniform name:
create_durable.Please use typedef to define multiple aliases for a single struct.
typedef struct { ... } create_durable, create_durable_reconn_req;Thanks.
Re: [PATCH v5 06/14] smb/server: remove create_durable_reconn_req
Quoted 5 lines · ChenXiaoSong
Okay, I'll make the changes.
Once you've applied some of the patches from this version, I'll immediately send the next version.
I have applied all patches except 0006, 0012 patches to #ksmbd-for-next-next. Thanks!
Quoted 26 lines
Thanks,
ChenXiaoSong.Quoted 20 lines · Namjae Jeon
Quoted 6 lines · On Sun, Nov 2, 2025 at 4:32 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
The fields in struct
create_durable_reconn_reqand structcreate_durableare exactly the same.Quoted 7 lines
The documentation references are:
-
SMB2_CREATE_DURABLE_HANDLE_REQUESTin MS-SMB2 2.2.13.2.3
-SMB2_CREATE_DURABLE_HANDLE_RECONNECTin MS-SMB2 2.2.13.2.4
-SMB2_FILEIDin MS-SMB2 2.2.14.1We can give these two structs a uniform name:
create_durable.Please use typedef to define multiple aliases for a single struct.
typedef struct { ... } create_durable, create_durable_reconn_req;Thanks.
ChenXiaoSong
reviewerRe: [PATCH v5 06/14] smb/server: remove create_durable_reconn_req
Hi Namjae,
Please do not apply patch 0007 yet.
The struct smb_hdr seems to be used only by SMB1, while SMB2 and SMB3 use smb2_hdr.
Should we move smb_hdr to a new common/smb1pdu.h?
Thanks,
ChenXiaoSong.
Quoted 35 lines · Namjae Jeon
Quoted 5 lines · ChenXiaoSong
Okay, I'll make the changes.
Once you've applied some of the patches from this version, I'll immediately send the next version.
I have applied all patches except 0006, 0012 patches to #ksmbd-for-next-next. Thanks!
Quoted 26 lines
Thanks,
ChenXiaoSong.Quoted 20 lines · Namjae Jeon
Quoted 6 lines · On Sun, Nov 2, 2025 at 4:32 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
The fields in struct
create_durable_reconn_reqand structcreate_durableare exactly the same.Quoted 7 lines
The documentation references are:
-
SMB2_CREATE_DURABLE_HANDLE_REQUESTin MS-SMB2 2.2.13.2.3
-SMB2_CREATE_DURABLE_HANDLE_RECONNECTin MS-SMB2 2.2.13.2.4
-SMB2_FILEIDin MS-SMB2 2.2.14.1We can give these two structs a uniform name:
create_durable.Please use typedef to define multiple aliases for a single struct.
typedef struct { ... } create_durable, create_durable_reconn_req;Thanks.
PATCH v5 7/14 smb: move some duplicate definitions to common/smb2pdu.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to common header file.
There are only 4 different definitions, the client uses cpu_to_le16() but the server does not:
- RSS_CAPABLE
- RDMA_CAPABLE
- INTERNETWORK
- INTERNETWORKV6
The other definitions are exactly the same on both client and server.
The struct smb_hdr is defined in MS-CIFS and MS-SMB, but it's also used by SMB2 and SMB3, so move it to the common smb2pdu.h.
--- fs/smb/client/cifspdu.h | 135 +---------------------------- fs/smb/client/smb2pdu.h | 21 ----- fs/smb/common/smb2pdu.h | 172 +++++++++++++++++++++++++++++++++++-- fs/smb/server/smb2pdu.c | 8 +- fs/smb/server/smb2pdu.h | 19 ---- fs/smb/server/smb_common.h | 75 +--------------- 6 files changed, 173 insertions(+), 257 deletions(-)
fs/smb/client/cifspdu.h +2 -133
@@ -12,6 +12,7 @@#include <net/sock.h> #include <linux/unaligned.h> #include "../common/smbfsctl.h" +#include "../common/smb2pdu.h" #define CIFS_PROT 0#define POSIX_PROT (CIFS_PROT+1)
@@ -179,98 +180,7 @@#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)#define SMBFLG2_UNICODE cpu_to_le16(0x8000) -/* -* These are the file access permission bits defined in CIFS for the -* NTCreateAndX as well as the level 0x107 -* TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO -* responds with the AccessFlags. -* The AccessFlags specifies the access permissions a caller has to the -* file and can have any suitable combination of the following values: -*/ - -#define FILE_READ_DATA 0x00000001/* Data can be read from the file */ -/* or directory child entries can */ -/* be listed together with the */ -/* associated child attributes */ -/* (so the FILE_READ_ATTRIBUTES on */ -/* the child entry is not needed) */ -#define FILE_WRITE_DATA 0x00000002/* Data can be written to the file */ -/* or new file can be created in */ -/* the directory */ -#define FILE_APPEND_DATA 0x00000004/* Data can be appended to the file */ -/* (for non-local files over SMB it */ -/* is same as FILE_WRITE_DATA) */ -/* or new subdirectory can be */ -/* created in the directory */ -#define FILE_READ_EA 0x00000008/* Extended attributes associated */ -/* with the file can be read */ -#define FILE_WRITE_EA 0x00000010/* Extended attributes associated */ -/* with the file can be written */ -#define FILE_EXECUTE 0x00000020/*Data can be read into memory from */ -/* the file using system paging I/O */ -/* for executing the file / script */ -/* or right to traverse directory */ -/* (but by default all users have */ -/* directory bypass traverse */ -/* privilege and do not need this */ -/* permission on directories at all)*/ -#define FILE_DELETE_CHILD 0x00000040/* Child entry can be deleted from */ -/* the directory (so the DELETE on */ -/* the child entry is not needed) */ -#define FILE_READ_ATTRIBUTES 0x00000080/* Attributes associated with the */ -/* file or directory can be read */ -#define FILE_WRITE_ATTRIBUTES 0x00000100/* Attributes associated with the */ -/* file or directory can be written */ -#define DELETE 0x00010000/* The file or dir can be deleted */ -#define READ_CONTROL 0x00020000/* The discretionary access control */ -/* list and ownership associated */ -/* with the file or dir can be read */ -#define WRITE_DAC 0x00040000/* The discretionary access control */ -/* list associated with the file or */ -/* directory can be written */ -#define WRITE_OWNER 0x00080000/* Ownership information associated */ -/* with the file/dir can be written */ -#define SYNCHRONIZE 0x00100000/* The file handle can waited on to */ -/* synchronize with the completion */ -/* of an input/output request */ -#define SYSTEM_SECURITY 0x01000000/* The system access control list */ -/* associated with the file or */ -/* directory can be read or written */ -/* (cannot be in DACL, can in SACL) */ -#define MAXIMUM_ALLOWED 0x02000000/* Maximal subset of GENERIC_ALL */ -/* permissions which can be granted */ -/* (cannot be in DACL nor SACL) */ -#define GENERIC_ALL 0x10000000/* Same as: GENERIC_EXECUTE | */ -/* GENERIC_WRITE | */ -/* GENERIC_READ | */ -/* FILE_DELETE_CHILD | */ -/* DELETE | */ -/* WRITE_DAC | */ -/* WRITE_OWNER */ -/* So GENERIC_ALL contains all bits */ -/* mentioned above except these two */ -/* SYSTEM_SECURITY MAXIMUM_ALLOWED */ -#define GENERIC_EXECUTE 0x20000000/* Same as: FILE_EXECUTE | */ -/* FILE_READ_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ -#define GENERIC_WRITE 0x40000000/* Same as: FILE_WRITE_DATA | */ -/* FILE_APPEND_DATA | */ -/* FILE_WRITE_EA | */ -/* FILE_WRITE_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ -#define GENERIC_READ 0x80000000/* Same as: FILE_READ_DATA | */ -/* FILE_READ_EA | */ -/* FILE_READ_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ - -#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES) -#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ - | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) -#define FILE_EXEC_RIGHTS (FILE_EXECUTE) - +/* Combinations of file access permission bits */ #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \ | FILE_READ_ATTRIBUTES \ | FILE_WRITE_ATTRIBUTES \
@@ -282,15 +192,6 @@ | FILE_WRITE_ATTRIBUTES \ |DELETE |READ_CONTROL |WRITE_DAC \ | WRITE_OWNER | SYNCHRONIZE) -#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ - | FILE_READ_ATTRIBUTES \ - | FILE_WRITE_ATTRIBUTES \ - | DELETE | READ_CONTROL | WRITE_DAC \ - | WRITE_OWNER | SYNCHRONIZE) - -#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ - | READ_CONTROL | SYNCHRONIZE) -/* * Invalid readdir handle
@@ -416,38 +317,6 @@#define GETU16 (var) (*((__u16 *)var))/* BB check for endian issues */ #define GETU32 (var) (*((__u32 *)var))/* BB check for endian issues */ -struct smb_hdr { -__be32 smb_buf_length;/* BB length is only two (rarely three) bytes, -with one or two byte "type" preceding it that will be -zero - we could mask the type byte off */ -__u8 Protocol[4 ]; -__u8 Command; -union { -struct { -__u8 ErrorClass; -__u8 Reserved; -__le16 Error; - } __attribute__((packed)) DosError; -__le32 CifsError; - } __attribute__((packed)) Status; -__u8 Flags; -__le16 Flags2;/* note: le */ -__le16 PidHigh; -union { -struct { -__le32 SequenceNumber;/* le */ -__u32 Reserved;/* zero */ - } __attribute__((packed)) Sequence; -__u8 SecuritySignature[8 ];/* le */ - } __attribute__((packed)) Signature; -__u8 pad[2 ]; -__u16 Tid; -__le16 Pid; -__u16 Uid; -__le16 Mid; -__u8 WordCount; -} __attribute__((packed)); -/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */ static inline void *BCC (struct smb_hdr *smb)
fs/smb/client/smb2pdu.h +0 -21
@@ -133,11 +133,6 @@ struct share_redirect_error_context_rsp {#define SMB2_LEASE_HANDLE_CACHING_HE 0x02#define SMB2_LEASE_WRITE_CACHING_HE 0x04 - -/* See MS-SMB2 2.2.13.2.11 */ -/* Flags */ -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* See MS-SMB2 2.2.13.2.5 */ struct crt_twarp_ctxt {struct create_context_hdr ccontext;
@@ -198,22 +193,6 @@ struct network_resiliency_req { } __packed;/* There is no buffer for the response ie no struct network_resiliency_rsp */ -#define RSS_CAPABLE cpu_to_le32(0x00000001) -#define RDMA_CAPABLE cpu_to_le32(0x00000002) - -#define INTERNETWORK cpu_to_le16(0x0002) -#define INTERNETWORKV6 cpu_to_le16(0x0017) - -struct network_interface_info_ioctl_rsp { -__le32 Next;/* next interface. zero if this is last one */ -__le32 IfIndex; -__le32 Capability;/* RSS or RDMA Capable */ -__le32 Reserved; -__le64 LinkSpeed; -__le16 Family; -__u8 Buffer[126 ]; -} __packed; -#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL/* general ioctls to srv not to file */ struct compress_ioctl {
fs/smb/common/smb2pdu.h +166 -6
196 lines not on this page · raw message
fs/smb/server/smb2pdu.c +4 -4
@@ -7876,9 +7876,9 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, nii_rsp->Capability =0 ;if (netdev->real_num_tx_queues >1 ) - nii_rsp->Capability |=cpu_to_le32 (RSS_CAPABLE ); + nii_rsp->Capability |=RSS_CAPABLE ;if (ksmbd_rdma_capable_netdev (netdev)) - nii_rsp->Capability |=cpu_to_le32 (RDMA_CAPABLE ); + nii_rsp->Capability |=RDMA_CAPABLE ; nii_rsp->Next =cpu_to_le32 (152 ); nii_rsp->Reserved =0 ;
@@ -7904,7 +7904,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,if (!ipv4_set) {struct in_device *idev; - sockaddr_storage->Family =cpu_to_le16 (INTERNETWORK ); + sockaddr_storage->Family =INTERNETWORK ; sockaddr_storage->addr4.Port =0 ; idev =__in_dev_get_rtnl (netdev);
@@ -7920,7 +7920,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,struct inet6_ifaddr *ifa;__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address; - sockaddr_storage->Family =cpu_to_le16 (INTERNETWORKV6 ); + sockaddr_storage->Family =INTERNETWORKV6 ; sockaddr_storage->addr6.Port =0 ; sockaddr_storage->addr6.FlowInfo =0 ;
fs/smb/server/smb2pdu.h +0 -19
@@ -83,10 +83,6 @@ struct create_durable_rsp { } Data; } __packed; -/* See MS-SMB2 2.2.13.2.11 */ -/* Flags */ -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* equivalent of the contents of SMB3.1.1 POSIX open context response */ struct create_posix_rsp {struct create_context_hdr ccontext;
@@ -100,9 +96,6 @@ struct create_posix_rsp {#define SMB2_0_IOCTL_IS_FSCTL 0x00000001 -#define INTERNETWORK 0x0002 -#define INTERNETWORKV6 0x0017 -struct sockaddr_storage_rsp {__le16 Family;union {
@@ -111,18 +104,6 @@ struct sockaddr_storage_rsp { }; } __packed; -#define RSS_CAPABLE 0x00000001 -#define RDMA_CAPABLE 0x00000002 - -struct network_interface_info_ioctl_rsp { -__le32 Next;/* next interface. zero if this is last one */ -__le32 IfIndex; -__le32 Capability;/* RSS or RDMA Capable */ -__le32 Reserved; -__le64 LinkSpeed; -char SockAddr_Storage[128 ]; -} __packed; -struct file_object_buf_type1_ioctl_rsp {__u8 ObjectId[16 ];__u8 BirthVolumeId[16 ];
fs/smb/server/smb_common.h +1 -74
93 lines not on this page · raw message
Signature · 1 line
2.43.0
ChenXiaoSong
reviewerRe: [PATCH v5 07/14] smb: move some duplicate definitions to common/smb2pdu.h
The struct smb_hdr seems to be used only by SMB1, while SMB2 and SMB3 use smb2_hdr.
Therefore, smb_hdr should be moved to a new common/smb1pdu.h.
Thanks,
ChenXiaoSong.
Quoted 618 lines · On 11/2/25 15:30, [email protected] wrote:
From: ZhangGuoDong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to common header file.
There are only 4 different definitions, the client uses
cpu_to_le16()but the server does not:-
RSS_CAPABLE
-RDMA_CAPABLE
- INTERNETWORK
- INTERNETWORKV6The other definitions are exactly the same on both client and server.
The struct
smb_hdris defined in MS-CIFS and MS-SMB, but it's also used by SMB2 and SMB3, so move it to the commonsmb2pdu.h.Co-developed-by ChenXiaoSong <[email protected]>Signed-off-by ChenXiaoSong <[email protected]>Signed-off-by ZhangGuoDong <[email protected]>--- fs/smb/client/cifspdu.h | 135 +---------------------------- fs/smb/client/smb2pdu.h | 21 ----- fs/smb/common/smb2pdu.h | 172 +++++++++++++++++++++++++++++++++++-- fs/smb/server/smb2pdu.c | 8 +- fs/smb/server/smb2pdu.h | 19 ---- fs/smb/server/smb_common.h | 75 +--------------- 6 files changed, 173 insertions(+), 257 deletions(-)fs/smb/client/cifspdu.h +2
-133@@ -12,6 +12,7 @@#include <net/sock.h> #include <linux/unaligned.h> #include "../common/smbfsctl.h" +#include "../common/smb2pdu.h" #define CIFS_PROT 0#define POSIX_PROT (CIFS_PROT+1)@@ -179,98 +180,7 @@#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)#define SMBFLG2_UNICODE cpu_to_le16(0x8000) -/* -* These are the file access permission bits defined in CIFS for the -* NTCreateAndX as well as the level 0x107 -* TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO -* responds with the AccessFlags. -* The AccessFlags specifies the access permissions a caller has to the -* file and can have any suitable combination of the following values: -*/ - -#define FILE_READ_DATA 0x00000001/* Data can be read from the file */ -/* or directory child entries can */ -/* be listed together with the */ -/* associated child attributes */ -/* (so the FILE_READ_ATTRIBUTES on */ -/* the child entry is not needed) */ -#define FILE_WRITE_DATA 0x00000002/* Data can be written to the file */ -/* or new file can be created in */ -/* the directory */ -#define FILE_APPEND_DATA 0x00000004/* Data can be appended to the file */ -/* (for non-local files over SMB it */ -/* is same as FILE_WRITE_DATA) */ -/* or new subdirectory can be */ -/* created in the directory */ -#define FILE_READ_EA 0x00000008/* Extended attributes associated */ -/* with the file can be read */ -#define FILE_WRITE_EA 0x00000010/* Extended attributes associated */ -/* with the file can be written */ -#define FILE_EXECUTE 0x00000020/*Data can be read into memory from */ -/* the file using system paging I/O */ -/* for executing the file / script */ -/* or right to traverse directory */ -/* (but by default all users have */ -/* directory bypass traverse */ -/* privilege and do not need this */ -/* permission on directories at all)*/ -#define FILE_DELETE_CHILD 0x00000040/* Child entry can be deleted from */ -/* the directory (so the DELETE on */ -/* the child entry is not needed) */ -#define FILE_READ_ATTRIBUTES 0x00000080/* Attributes associated with the */ -/* file or directory can be read */ -#define FILE_WRITE_ATTRIBUTES 0x00000100/* Attributes associated with the */ -/* file or directory can be written */ -#define DELETE 0x00010000/* The file or dir can be deleted */ -#define READ_CONTROL 0x00020000/* The discretionary access control */ -/* list and ownership associated */ -/* with the file or dir can be read */ -#define WRITE_DAC 0x00040000/* The discretionary access control */ -/* list associated with the file or */ -/* directory can be written */ -#define WRITE_OWNER 0x00080000/* Ownership information associated */ -/* with the file/dir can be written */ -#define SYNCHRONIZE 0x00100000/* The file handle can waited on to */ -/* synchronize with the completion */ -/* of an input/output request */ -#define SYSTEM_SECURITY 0x01000000/* The system access control list */ -/* associated with the file or */ -/* directory can be read or written */ -/* (cannot be in DACL, can in SACL) */ -#define MAXIMUM_ALLOWED 0x02000000/* Maximal subset of GENERIC_ALL */ -/* permissions which can be granted */ -/* (cannot be in DACL nor SACL) */ -#define GENERIC_ALL 0x10000000/* Same as: GENERIC_EXECUTE | */ -/* GENERIC_WRITE | */ -/* GENERIC_READ | */ -/* FILE_DELETE_CHILD | */ -/* DELETE | */ -/* WRITE_DAC | */ -/* WRITE_OWNER */ -/* So GENERIC_ALL contains all bits */ -/* mentioned above except these two */ -/* SYSTEM_SECURITY MAXIMUM_ALLOWED */ -#define GENERIC_EXECUTE 0x20000000/* Same as: FILE_EXECUTE | */ -/* FILE_READ_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ -#define GENERIC_WRITE 0x40000000/* Same as: FILE_WRITE_DATA | */ -/* FILE_APPEND_DATA | */ -/* FILE_WRITE_EA | */ -/* FILE_WRITE_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ -#define GENERIC_READ 0x80000000/* Same as: FILE_READ_DATA | */ -/* FILE_READ_EA | */ -/* FILE_READ_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ - -#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES) -#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ - | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) -#define FILE_EXEC_RIGHTS (FILE_EXECUTE) - +/* Combinations of file access permission bits */ #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \ | FILE_READ_ATTRIBUTES \ | FILE_WRITE_ATTRIBUTES \@@ -282,15 +192,6 @@ | FILE_WRITE_ATTRIBUTES \ |DELETE |READ_CONTROL |WRITE_DAC \ | WRITE_OWNER | SYNCHRONIZE) -#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ - | FILE_READ_ATTRIBUTES \ - | FILE_WRITE_ATTRIBUTES \ - | DELETE | READ_CONTROL | WRITE_DAC \ - | WRITE_OWNER | SYNCHRONIZE) - -#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ - | READ_CONTROL | SYNCHRONIZE) -/* * Invalid readdir handle @@ -416,38 +317,6 @@#define GETU16 (var) (*((__u16 *)var))/* BB check for endian issues */ #define GETU32 (var) (*((__u32 *)var))/* BB check for endian issues */ -struct smb_hdr { -__be32 smb_buf_length;/* BB length is only two (rarely three) bytes, -with one or two byte "type" preceding it that will be -zero - we could mask the type byte off */ -__u8 Protocol[4 ]; -__u8 Command; -union { -struct { -__u8 ErrorClass; -__u8 Reserved; -__le16 Error; - } __attribute__((packed)) DosError; -__le32 CifsError; - } __attribute__((packed)) Status; -__u8 Flags; -__le16 Flags2;/* note: le */ -__le16 PidHigh; -union { -struct { -__le32 SequenceNumber;/* le */ -__u32 Reserved;/* zero */ - } __attribute__((packed)) Sequence; -__u8 SecuritySignature[8 ];/* le */ - } __attribute__((packed)) Signature; -__u8 pad[2 ]; -__u16 Tid; -__le16 Pid; -__u16 Uid; -__le16 Mid; -__u8 WordCount; -} __attribute__((packed)); -/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */ static inline void *BCC (struct smb_hdr *smb)fs/smb/client/smb2pdu.h +0
-21@@ -133,11 +133,6 @@ struct share_redirect_error_context_rsp {#define SMB2_LEASE_HANDLE_CACHING_HE 0x02#define SMB2_LEASE_WRITE_CACHING_HE 0x04 - -/* See MS-SMB2 2.2.13.2.11 */ -/* Flags */ -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* See MS-SMB2 2.2.13.2.5 */ struct crt_twarp_ctxt {struct create_context_hdr ccontext;@@ -198,22 +193,6 @@ struct network_resiliency_req { } __packed;/* There is no buffer for the response ie no struct network_resiliency_rsp */ -#define RSS_CAPABLE cpu_to_le32(0x00000001) -#define RDMA_CAPABLE cpu_to_le32(0x00000002) - -#define INTERNETWORK cpu_to_le16(0x0002) -#define INTERNETWORKV6 cpu_to_le16(0x0017) - -struct network_interface_info_ioctl_rsp { -__le32 Next;/* next interface. zero if this is last one */ -__le32 IfIndex; -__le32 Capability;/* RSS or RDMA Capable */ -__le32 Reserved; -__le64 LinkSpeed; -__le16 Family; -__u8 Buffer[126 ]; -} __packed; -#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL/* general ioctls to srv not to file */ struct compress_ioctl {fs/smb/common/smb2pdu.h +166
-6@@ -1149,12 +1149,6 @@ struct smb2_server_client_notification {#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)#define FILE_CREATE_MASK_LE cpu_to_le32(0x00000007) -#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ - | FILE_READ_ATTRIBUTES) -#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ - | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) -#define FILE_EXEC_RIGHTS (FILE_EXECUTE) -/* CreateOptions Flags */ #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ @@ -1290,6 +1284,14 @@ struct create_mxac_req {__le64 Timestamp; } __packed; +/* +* Flags +* See MS-SMB2 2.2.13.2.11 +* MS-SMB2 2.2.13.2.12 +* MS-SMB2 2.2.14.2.12 +*/ +#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 +/* See MS-SMB2 2.2.13.2.11 */ struct durable_context_v2_req {__le32 Timeout;@@ -1500,6 +1502,26 @@ struct smb_sockaddr_in6 {__be32 ScopeId; } __packed; +/* See MS-SMB2 2.2.32.5 and MS-SMB2 2.2.32.5.1 */ +#define RSS_CAPABLE cpu_to_le32(0x00000001) +#define RDMA_CAPABLE cpu_to_le32(0x00000002) +#define INTERNETWORK cpu_to_le16(0x0002) +#define INTERNETWORKV6 cpu_to_le16(0x0017) +struct network_interface_info_ioctl_rsp { +__le32 Next;/* next interface. zero if this is last one */ +__le32 IfIndex; +__le32 Capability;/* RSS or RDMA Capable */ +__le32 Reserved; +__le64 LinkSpeed; +union { +char SockAddr_Storage[128 ]; +struct { +__le16 Family; +__u8 Buffer[126 ]; + }; + }; +} __packed; +/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ struct file_zero_data_information {__le64 FileOffset;@@ -1989,6 +2011,144 @@ struct smb2_lease_ack {__le64 LeaseDuration; } __packed; +/* +* See MS-CIFS 2.2.3.1 +* MS-SMB 2.2.3.1 +*/ +struct smb_hdr { +__be32 smb_buf_length;/* BB length is only two (rarely three) bytes, +with one or two byte "type" preceding it that will be +zero - we could mask the type byte off */ +__u8 Protocol[4 ]; +__u8 Command; +union { +struct { +__u8 ErrorClass; +__u8 Reserved; +__le16 Error; + } __packed DosError; +__le32 CifsError; + } __packed Status; +__u8 Flags; +__le16 Flags2;/* note: le */ +__le16 PidHigh; +union { +struct { +__le32 SequenceNumber;/* le */ +__u32 Reserved;/* zero */ + } __packed Sequence; +__u8 SecuritySignature[8 ];/* le */ + } __packed Signature; +__u8 pad[2 ]; +__u16 Tid; +__le16 Pid; +__u16 Uid; +__le16 Mid; +__u8 WordCount; +} __packed; +#define OP_BREAK_STRUCT_SIZE_20 24#define OP_BREAK_STRUCT_SIZE_21 36 + +/* +* See MS-SMB2 2.2.13.1.1 +* MS-SMB 2.2.1.4.1 +* These are the file access permission bits defined in CIFS for the +* NTCreateAndX as well as the level 0x107 +* TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO +* responds with the AccessFlags. +* The AccessFlags specifies the access permissions a caller has to the +* file and can have any suitable combination of the following values: +*/ +#define FILE_READ_DATA 0x00000001/* Data can be read from the file */ +/* or directory child entries can */ +/* be listed together with the */ +/* associated child attributes */ +/* (so the FILE_READ_ATTRIBUTES on */ +/* the child entry is not needed) */ +#define FILE_WRITE_DATA 0x00000002/* Data can be written to the file */ +/* or new file can be created in */ +/* the directory */ +#define FILE_APPEND_DATA 0x00000004/* Data can be appended to the file */ +/* (for non-local files over SMB it */ +/* is same as FILE_WRITE_DATA) */ +/* or new subdirectory can be */ +/* created in the directory */ +#define FILE_READ_EA 0x00000008/* Extended attributes associated */ +/* with the file can be read */ +#define FILE_WRITE_EA 0x00000010/* Extended attributes associated */ +/* with the file can be written */ +#define FILE_EXECUTE 0x00000020/*Data can be read into memory from */ +/* the file using system paging I/O */ +/* for executing the file / script */ +/* or right to traverse directory */ +/* (but by default all users have */ +/* directory bypass traverse */ +/* privilege and do not need this */ +/* permission on directories at all)*/ +#define FILE_DELETE_CHILD 0x00000040/* Child entry can be deleted from */ +/* the directory (so the DELETE on */ +/* the child entry is not needed) */ +#define FILE_READ_ATTRIBUTES 0x00000080/* Attributes associated with the */ +/* file or directory can be read */ +#define FILE_WRITE_ATTRIBUTES 0x00000100/* Attributes associated with the */ +/* file or directory can be written */ +#define DELETE 0x00010000/* The file or dir can be deleted */ +#define READ_CONTROL 0x00020000/* The discretionary access control */ +/* list and ownership associated */ +/* with the file or dir can be read */ +#define WRITE_DAC 0x00040000/* The discretionary access control */ +/* list associated with the file or */ +/* directory can be written */ +#define WRITE_OWNER 0x00080000/* Ownership information associated */ +/* with the file/dir can be written */ +#define SYNCHRONIZE 0x00100000/* The file handle can waited on to */ +/* synchronize with the completion */ +/* of an input/output request */ +#define SYSTEM_SECURITY 0x01000000/* The system access control list */ +/* associated with the file or */ +/* directory can be read or written */ +/* (cannot be in DACL, can in SACL) */ +#define MAXIMUM_ALLOWED 0x02000000/* Maximal subset of GENERIC_ALL */ +/* permissions which can be granted */ +/* (cannot be in DACL nor SACL) */ +#define GENERIC_ALL 0x10000000/* Same as: GENERIC_EXECUTE | */ +/* GENERIC_WRITE | */ +/* GENERIC_READ | */ +/* FILE_DELETE_CHILD | */ +/* DELETE | */ +/* WRITE_DAC | */ +/* WRITE_OWNER */ +/* So GENERIC_ALL contains all bits */ +/* mentioned above except these two */ +/* SYSTEM_SECURITY MAXIMUM_ALLOWED */ +#define GENERIC_EXECUTE 0x20000000/* Same as: FILE_EXECUTE | */ +/* FILE_READ_ATTRIBUTES | */ +/* READ_CONTROL | */ +/* SYNCHRONIZE */ +#define GENERIC_WRITE 0x40000000/* Same as: FILE_WRITE_DATA | */ +/* FILE_APPEND_DATA | */ +/* FILE_WRITE_EA | */ +/* FILE_WRITE_ATTRIBUTES | */ +/* READ_CONTROL | */ +/* SYNCHRONIZE */ +#define GENERIC_READ 0x80000000/* Same as: FILE_READ_DATA | */ +/* FILE_READ_EA | */ +/* FILE_READ_ATTRIBUTES | */ +/* READ_CONTROL | */ +/* SYNCHRONIZE */ + +/* Combinations of file access permission bits */ +#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES) +#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ + | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) +#define FILE_EXEC_RIGHTS (FILE_EXECUTE) +#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ + | FILE_READ_ATTRIBUTES \ + | FILE_WRITE_ATTRIBUTES \ + | DELETE | READ_CONTROL | WRITE_DAC \ + | WRITE_OWNER | SYNCHRONIZE) +#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ + | READ_CONTROL | SYNCHRONIZE) +#endif /* _COMMON_SMB2PDU_H */ fs/smb/server/smb2pdu.c +4
-4@@ -7876,9 +7876,9 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, nii_rsp->Capability =0 ;if (netdev->real_num_tx_queues >1 ) - nii_rsp->Capability |=cpu_to_le32 (RSS_CAPABLE ); + nii_rsp->Capability |=RSS_CAPABLE ;if (ksmbd_rdma_capable_netdev (netdev)) - nii_rsp->Capability |=cpu_to_le32 (RDMA_CAPABLE ); + nii_rsp->Capability |=RDMA_CAPABLE ; nii_rsp->Next =cpu_to_le32 (152 ); nii_rsp->Reserved =0 ;@@ -7904,7 +7904,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,if (!ipv4_set) {struct in_device *idev; - sockaddr_storage->Family =cpu_to_le16 (INTERNETWORK ); + sockaddr_storage->Family =INTERNETWORK ; sockaddr_storage->addr4.Port =0 ; idev =__in_dev_get_rtnl (netdev);@@ -7920,7 +7920,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,struct inet6_ifaddr *ifa;__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address; - sockaddr_storage->Family =cpu_to_le16 (INTERNETWORKV6 ); + sockaddr_storage->Family =INTERNETWORKV6 ; sockaddr_storage->addr6.Port =0 ; sockaddr_storage->addr6.FlowInfo =0 ;fs/smb/server/smb2pdu.h +0
-19@@ -83,10 +83,6 @@ struct create_durable_rsp { } Data; } __packed; -/* See MS-SMB2 2.2.13.2.11 */ -/* Flags */ -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* equivalent of the contents of SMB3.1.1 POSIX open context response */ struct create_posix_rsp {struct create_context_hdr ccontext;@@ -100,9 +96,6 @@ struct create_posix_rsp {#define SMB2_0_IOCTL_IS_FSCTL 0x00000001 -#define INTERNETWORK 0x0002 -#define INTERNETWORKV6 0x0017 -struct sockaddr_storage_rsp {__le16 Family;union {@@ -111,18 +104,6 @@ struct sockaddr_storage_rsp { }; } __packed; -#define RSS_CAPABLE 0x00000001 -#define RDMA_CAPABLE 0x00000002 - -struct network_interface_info_ioctl_rsp { -__le32 Next;/* next interface. zero if this is last one */ -__le32 IfIndex; -__le32 Capability;/* RSS or RDMA Capable */ -__le32 Reserved; -__le64 LinkSpeed; -char SockAddr_Storage[128 ]; -} __packed; -struct file_object_buf_type1_ioctl_rsp {__u8 ObjectId[16 ];__u8 BirthVolumeId[16 ];fs/smb/server/smb_common.h +1
-74@@ -75,42 +75,7 @@#define FILE_CASE_PRESERVED_NAMES 0x00000002#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 -#define FILE_READ_DATA 0x00000001/* Data can be read from the file */ -#define FILE_WRITE_DATA 0x00000002/* Data can be written to the file */ -#define FILE_APPEND_DATA 0x00000004/* Data can be appended to the file */ -#define FILE_READ_EA 0x00000008/* Extended attributes associated */ -/* with the file can be read */ -#define FILE_WRITE_EA 0x00000010/* Extended attributes associated */ -/* with the file can be written */ -#define FILE_EXECUTE 0x00000020/*Data can be read into memory from */ -/* the file using system paging I/O */ -#define FILE_DELETE_CHILD 0x00000040 -#define FILE_READ_ATTRIBUTES 0x00000080/* Attributes associated with the */ -/* file can be read */ -#define FILE_WRITE_ATTRIBUTES 0x00000100/* Attributes associated with the */ -/* file can be written */ -#define DELETE 0x00010000/* The file can be deleted */ -#define READ_CONTROL 0x00020000/* The access control list and */ -/* ownership associated with the */ -/* file can be read */ -#define WRITE_DAC 0x00040000/* The access control list and */ -/* ownership associated with the */ -/* file can be written. */ -#define WRITE_OWNER 0x00080000/* Ownership information associated */ -/* with the file can be written */ -#define SYNCHRONIZE 0x00100000/* The file handle can waited on to */ -/* synchronize with the completion */ -/* of an input/output request */ -#define GENERIC_ALL 0x10000000 -#define GENERIC_EXECUTE 0x20000000 -#define GENERIC_WRITE 0x40000000 -#define GENERIC_READ 0x80000000 -/* In summary - Relevant file */ -/* access flags from CIFS are */ -/* file_read_data, file_write_data */ -/* file_execute, file_read_attributes*/ -/* write_dac, and delete. */ - +/* Combinations of file access permission bits */ #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ | FILE_READ_ATTRIBUTES \ | DELETE | READ_CONTROL | WRITE_DAC \@@ -121,14 +86,6 @@ | FILE_WRITE_ATTRIBUTES \ | DELETE | READ_CONTROL | WRITE_DAC \ | WRITE_OWNER | SYNCHRONIZE) -#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ - | FILE_READ_ATTRIBUTES \ - | FILE_WRITE_ATTRIBUTES \ - | DELETE | READ_CONTROL | WRITE_DAC \ - | WRITE_OWNER | SYNCHRONIZE) - -#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ - | READ_CONTROL | SYNCHRONIZE)/* generic flags for file open */ #define GENERIC_READ_FLAGS (READ_CONTROL | FILE_READ_DATA | \@@ -159,36 +116,6 @@#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)#define SMBFLG2_UNICODE cpu_to_le16(0x8000) -struct smb_hdr { -__be32 smb_buf_length; -__u8 Protocol[4 ]; -__u8 Command; -union { -struct { -__u8 ErrorClass; -__u8 Reserved; -__le16 Error; - } __packed DosError; -__le32 CifsError; - } __packed Status; -__u8 Flags; -__le16 Flags2;/* note: le */ -__le16 PidHigh; -union { -struct { -__le32 SequenceNumber;/* le */ -__u32 Reserved;/* zero */ - } __packed Sequence; -__u8 SecuritySignature[8 ];/* le */ - } __packed Signature; -__u8 pad[2 ]; -__le16 Tid; -__le16 Pid; -__le16 Uid; -__le16 Mid; -__u8 WordCount; -} __packed; -struct smb_negotiate_req {struct smb_hdr hdr;/* wct = 0 */ __le16 ByteCount;
PATCH v5 8/14 smb: move SMB_NEGOTIATE_REQ to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Modify the following places:
- negotiate_req -> smb_negotiate_req
- NEGOTIATE_REQ -> SMB_NEGOTIATE_REQ
- negotiate_rsp -> smb_negotiate_rsp
- NEGOTIATE_RSP -> SMB_NEGOTIATE_RSP
Then move SMB_NEGOTIATE_REQ to common header file.
--- fs/smb/client/cifspdu.h | 12 ++++-------- fs/smb/client/cifssmb.c | 6 +++--- fs/smb/common/smb2pdu.h | 7 +++++++ fs/smb/server/smb_common.h | 7 +------ 4 files changed, 15 insertions(+), 17 deletions(-)
fs/smb/client/cifspdu.h +4 -8
@@ -388,19 +388,15 @@ put_bcc(__u16 count, struct smb_hdr *hdr)* */ -typedef struct negotiate_req { -struct smb_hdr hdr;/* wct = 0 */ -__le16 ByteCount; -unsigned char DialectsArray[]; -} __attribute__((packed))NEGOTIATE_REQ ; -#define MIN_TZ_ADJ (15 * 60)/* minimum grid for timezones in seconds */ #define READ_RAW_ENABLE 1#define WRITE_RAW_ENABLE 2#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)#define SMB1_CLIENT_GUID_SIZE (16) -typedef struct negotiate_rsp { + +/* See MS-CIFS 2.2.4.52.2 */ +typedef struct smb_negotiate_rsp { struct smb_hdr hdr; /* wct = 17 */ __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */ __u8 SecurityMode;
@@ -426,7 +422,7 @@ typedef struct negotiate_rsp {unsigned char SecurityBlob[]; } __attribute__((packed)) extended_response; } __attribute__((packed)) u; -} __attribute__((packed)) NEGOTIATE_RSP; +}__packed SMB_NEGOTIATE_RSP ;/* SecurityMode bits */ #define SECMODE_USER 0x01/* off indicates share level security */
fs/smb/client/cifssmb.c +3 -3
@@ -361,7 +361,7 @@ static int validate_t2(struct smb_t2_rsp *pSMB) }static int -decode_ext_sec_blob (struct cifs_ses *ses,NEGOTIATE_RSP *pSMBr) +decode_ext_sec_blob (struct cifs_ses *ses,SMB_NEGOTIATE_RSP *pSMBr) {int rc =0 ;u16 count;
@@ -419,8 +419,8 @@ CIFSSMBNegotiate(const unsigned int xid,struct cifs_ses *ses, struct TCP_Server_Info *server) { - NEGOTIATE_REQ *pSMB; -NEGOTIATE_RSP *pSMBr; + SMB_NEGOTIATE_REQ *pSMB; +SMB_NEGOTIATE_RSP *pSMBr;int rc =0 ;int bytes_returned;int i;
fs/smb/common/smb2pdu.h +7 -0
@@ -2151,4 +2151,11 @@ struct smb_hdr {#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ | READ_CONTROL | SYNCHRONIZE) +/* See MS-CIFS 2.2.4.52.1 */ +typedef struct smb_negotiate_req { +struct smb_hdr hdr;/* wct = 0 */ +__le16 ByteCount; +unsigned char DialectsArray[]; +} __packed SMB_NEGOTIATE_REQ; +#endif /* _COMMON_SMB2PDU_H */
fs/smb/server/smb_common.h +1 -6
@@ -116,12 +116,7 @@#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)#define SMBFLG2_UNICODE cpu_to_le16(0x8000) -struct smb_negotiate_req { -struct smb_hdr hdr;/* wct = 0 */ -__le16 ByteCount; -unsigned char DialectsArray[]; -} __packed; - +/* See MS-CIFS 2.2.4.52.2 */ struct smb_negotiate_rsp {struct smb_hdr hdr;/* wct = 17 */ __le16 DialectIndex;/* 0xFFFF = no dialect acceptable */
Signature · 1 line
2.43.0
PATCH v5 9/14 smb: move list of FileSystemAttributes to common/fscc.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
These definitions are exactly the same on both client and server, so move them to new common header file.
--- fs/smb/client/cifsglob.h | 1 + fs/smb/client/cifspdu.h | 27 ------------------------ fs/smb/common/fscc.h | 42 ++++++++++++++++++++++++++++++++++++++ fs/smb/server/smb_common.h | 28 +------------------------ 4 files changed, 44 insertions(+), 54 deletions(-) create mode 100644 fs/smb/common/fscc.h
fs/smb/client/cifsglob.h +1 -0
@@ -26,6 +26,7 @@#include <uapi/linux/cifs/cifs_mount.h> #include "../common/smbglob.h" #include "../common/smb2pdu.h" +#include "../common/fscc.h" #include "smb2pdu.h" #include <linux/filelock.h>
fs/smb/client/cifspdu.h +0 -27
@@ -2100,33 +2100,6 @@ typedef struct {/* minimum includes first three fields, and empty FS Name */ #define MIN_FS_ATTR_INFO_SIZE 12 - -/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */ -#define FILE_SUPPORTS_SPARSE_VDL 0x10000000/* faster nonsparse extend */ -#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000/* allow ioctl dup extents */ -#define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000 -#define FILE_SUPPORTS_USN_JOURNAL 0x02000000 -#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 -#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 -#define FILE_SUPPORTS_HARD_LINKS 0x00400000 -#define FILE_SUPPORTS_TRANSACTIONS 0x00200000 -#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 -#define FILE_READ_ONLY_VOLUME 0x00080000 -#define FILE_NAMED_STREAMS 0x00040000 -#define FILE_SUPPORTS_ENCRYPTION 0x00020000 -#define FILE_SUPPORTS_OBJECT_IDS 0x00010000 -#define FILE_VOLUME_IS_COMPRESSED 0x00008000 -#define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400 -#define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200 -#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 -#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 -#define FILE_SUPPORTS_SPARSE_FILES 0x00000040 -#define FILE_VOLUME_QUOTAS 0x00000020 -#define FILE_FILE_COMPRESSION 0x00000010 -#define FILE_PERSISTENT_ACLS 0x00000008 -#define FILE_UNICODE_ON_DISK 0x00000004 -#define FILE_CASE_PRESERVED_NAMES 0x00000002 -#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 typedef struct { __le32 Attributes; __le32 MaxPathNameComponentLength;
fs/smb/common/fscc.h new file +42 -0
42 lines not on this page · raw message
fs/smb/server/smb_common.h +1 -27
@@ -12,6 +12,7 @@#include "nterr.h" #include "../common/smbglob.h" #include "../common/smb2pdu.h" +#include "../common/fscc.h" #include "smb2pdu.h" /* ksmbd's Specific ERRNO */
@@ -48,33 +49,6 @@#define ATTR_NO_BUFFERING 0x20000000#define ATTR_WRITE_THROUGH 0x80000000 -/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */ -#define FILE_SUPPORTS_SPARSE_VDL 0x10000000/* faster nonsparse extend */ -#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000/* allow ioctl dup extents */ -#define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000 -#define FILE_SUPPORTS_USN_JOURNAL 0x02000000 -#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 -#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 -#define FILE_SUPPORTS_HARD_LINKS 0x00400000 -#define FILE_SUPPORTS_TRANSACTIONS 0x00200000 -#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 -#define FILE_READ_ONLY_VOLUME 0x00080000 -#define FILE_NAMED_STREAMS 0x00040000 -#define FILE_SUPPORTS_ENCRYPTION 0x00020000 -#define FILE_SUPPORTS_OBJECT_IDS 0x00010000 -#define FILE_VOLUME_IS_COMPRESSED 0x00008000 -#define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400 -#define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200 -#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 -#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 -#define FILE_SUPPORTS_SPARSE_FILES 0x00000040 -#define FILE_VOLUME_QUOTAS 0x00000020 -#define FILE_FILE_COMPRESSION 0x00000010 -#define FILE_PERSISTENT_ACLS 0x00000008 -#define FILE_UNICODE_ON_DISK 0x00000004 -#define FILE_CASE_PRESERVED_NAMES 0x00000002 -#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 -/* Combinations of file access permission bits */ #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ | FILE_READ_ATTRIBUTES \
Signature · 1 line
2.43.0
PATCH v5 10/14 smb: move some duplicate struct definitions to common/fscc.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Modify the following places:
- smb2_file_ntwrk_info -> smb2_file_network_open_info
- struct filesystem_device_info -> FILE_SYSTEM_DEVICE_INFO
- struct file_directory_info -> FILE_DIRECTORY_INFO
- struct file_full_directory_info -> FILE_FULL_DIRECTORY_INFO
- struct file_both_directory_info -> FILE_BOTH_DIRECTORY_INFO
- struct file_id_full_dir_info -> FILE_ID_FULL_DIR_INFO
- struct filesystem_posix_info -> FILE_SYSTEM_POSIX_INFO
The fields of these structures are exactly the same on both client and server, so move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 91 ----------------------------- fs/smb/client/inode.c | 4 +- fs/smb/client/readdir.c | 2 +- fs/smb/client/smb2pdu.c | 2 +- fs/smb/client/smb2pdu.h | 13 ----- fs/smb/common/fscc.h | 115 +++++++++++++++++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 72 +++++++++++------------ fs/smb/server/smb2pdu.h | 11 ---- fs/smb/server/smb_common.h | 92 ----------------------------- fs/smb/server/vfs.c | 2 +- 10 files changed, 156 insertions(+), 248 deletions(-)
fs/smb/client/cifspdu.h +0 -91
@@ -2036,28 +2036,6 @@ typedef struct {#define CIFS_POSIX_EXTENSIONS 0x00000010/* support for new QFSInfo */ -typedef struct { -/* For undefined recommended transfer size return -1 in that field */ -__le32 OptimalTransferSize;/* bsize on some os, iosize on other os */ -__le32 BlockSize; -/* The next three fields are in terms of the block size. -(above). If block size is unknown, 4096 would be a -reasonable block size for a server to report. -Note that returning the blocks/blocksavail removes need -to make a second call (to QFSInfo level 0x103 to get this info. -UserBlockAvail is typically less than or equal to BlocksAvail, -if no distinction is made return the same value in each */ -__le64 TotalBlocks; -__le64 BlocksAvail;/* bfree */ -__le64 UserBlocksAvail;/* bavail */ -/* For undefined Node fields or FSID return -1 */ -__le64 TotalFileNodes; -__le64 FreeFileNodes; -__le64 FileSysIdentifier;/* fsid */ -/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ -/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ -} __attribute__((packed))FILE_SYSTEM_POSIX_INFO ; -/* DeviceType Flags */ #define FILE_DEVICE_CD_ROM 0x00000002#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
@@ -2092,11 +2070,6 @@ typedef struct {#define FILE_PORTABLE_DEVICE 0x00004000#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000 -typedef struct { -__le32 DeviceType; -__le32 DeviceCharacteristics; -} __attribute__((packed))FILE_SYSTEM_DEVICE_INFO ;/* device info level 0x104 */ -/* minimum includes first three fields, and empty FS Name */ #define MIN_FS_ATTR_INFO_SIZE 12
@@ -2332,70 +2305,6 @@ typedef struct { }; } __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */ -typedef struct { -__le32 NextEntryOffset; -__u32 FileIndex; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 ExtFileAttributes; -__le32 FileNameLength; -char FileName[]; -} __attribute__((packed))FILE_DIRECTORY_INFO ;/* level 0x101 FF resp data */ - -typedef struct { -__le32 NextEntryOffset; -__u32 FileIndex; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 ExtFileAttributes; -__le32 FileNameLength; -__le32 EaSize;/* length of the xattrs */ -char FileName[]; -} __attribute__((packed))FILE_FULL_DIRECTORY_INFO ;/* level 0x102 rsp data */ - -typedef struct { -__le32 NextEntryOffset; -__u32 FileIndex; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 ExtFileAttributes; -__le32 FileNameLength; -__le32 EaSize;/* EA size */ -__le32 Reserved; -__le64 UniqueId;/* inode num - le since Samba puts ino in low 32 bit*/ -char FileName[]; -} __attribute__((packed))SEARCH_ID_FULL_DIR_INFO ;/* level 0x105 FF rsp data */ - -typedef struct { -__le32 NextEntryOffset; -__u32 FileIndex; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 ExtFileAttributes; -__le32 FileNameLength; -__le32 EaSize;/* length of the xattrs */ -__u8 ShortNameLength; -__u8 Reserved; -__u8 ShortName[24 ]; -char FileName[]; -} __attribute__((packed))FILE_BOTH_DIRECTORY_INFO ;/* level 0x104 FFrsp data */ - typedef struct { __u32 ResumeKey; __le16 CreationDate; /* SMB Date */
fs/smb/client/inode.c +2 -2
@@ -1328,7 +1328,7 @@ static int cifs_get_fattr(struct cifs_open_info_data *data,/* for easier reading */ FILE_ALL_INFO *fi;FILE_DIRECTORY_INFO *fdi; -SEARCH_ID_FULL_DIR_INFO *si; +FILE_ID_FULL_DIR_INFO *si; rc = cifs_backup_query_path_info(xid, tcon, sb, full_path,
@@ -1339,7 +1339,7 @@ static int cifs_get_fattr(struct cifs_open_info_data *data,move_cifs_info_to_smb2 (&data->fi, fi); fdi = (FILE_DIRECTORY_INFO *)fi; - si = (SEARCH_ID_FULL_DIR_INFO *)fi; + si = (FILE_ID_FULL_DIR_INFO *)fi;cifs_dir_info_to_fattr (fattr, fdi, cifs_sb); fattr->cf_uniqueid =le64_to_cpu (si->UniqueId);
fs/smb/client/readdir.c +1 -1
@@ -548,7 +548,7 @@ static void cifs_fill_dirent_full(struct cifs_dirent *de, }static void cifs_fill_dirent_search (struct cifs_dirent *de, -const SEARCH_ID_FULL_DIR_INFO *info) +const FILE_ID_FULL_DIR_INFO *info) { de->name = &info->FileName[0 ]; de->namelen =le32_to_cpu (info->FileNameLength);
fs/smb/client/smb2pdu.c +1 -1
@@ -5451,7 +5451,7 @@ smb2_parse_query_directory(struct cifs_tcon *tcon, info_buf_size =sizeof (FILE_DIRECTORY_INFO );break ;case SMB_FIND_FILE_ID_FULL_DIR_INFO : - info_buf_size =sizeof (SEARCH_ID_FULL_DIR_INFO ); + info_buf_size =sizeof (FILE_ID_FULL_DIR_INFO );break ;case SMB_FIND_FILE_POSIX_INFO :/* note that posix payload are variable size */
fs/smb/client/smb2pdu.h +0 -13
@@ -224,19 +224,6 @@ struct smb2_file_reparse_point_info {__le32 Tag; } __packed; -struct smb2_file_network_open_info { - struct_group_attr(network_open_info, __packed, - __le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 AllocationSize; -__le64 EndOfFile; -__le32 Attributes; - ); -__le32 Reserved; -} __packed;/* level 34 Query also similar returned in close rsp and open rsp */ -/* See MS-FSCC 2.4.21 */ struct smb2_file_id_information {__le64 VolumeSerialNumber;
fs/smb/common/fscc.h +115 -0
125 lines not on this page · raw message
fs/smb/server/smb2pdu.c +36 -36
210 lines not on this page · raw message
fs/smb/server/smb2pdu.h +0 -11
@@ -205,17 +205,6 @@ struct smb2_file_stream_info {char StreamName[]; } __packed; -struct smb2_file_ntwrk_info { -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 AllocationSize; -__le64 EndOfFile; -__le32 Attributes; -__le32 Reserved; -} __packed; -struct smb2_file_standard_info {__le64 AllocationSize;__le64 EndOfFile;
fs/smb/server/smb_common.h +0 -92
116 lines not on this page · raw message
fs/smb/server/vfs.c +1 -1
@@ -1654,7 +1654,7 @@ int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,*/ void *ksmbd_vfs_init_kstat (char **p,struct ksmbd_kstat *ksmbd_kstat) { -struct file_directory_info *info = (struct file_directory_info *)(*p); +FILE_DIRECTORY_INFO *info = (FILE_DIRECTORY_INFO *)(*p);struct kstat *kstat = ksmbd_kstat->kstat;u64 time;
Signature · 1 line
2.43.0
PATCH v5 11/14 smb: move FILE_SYSTEM_SIZE_INFO to common/fscc.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename the following places:
- struct filesystem_info -> FILE_SYSTEM_SIZE_INFO
- FILE_SYSTEM_INFO -> FILE_SYSTEM_SIZE_INFO
- FreeAllocationUnits -> AvailableAllocationUnits: consistent with MS-FSCC 2.5.8
Then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 7 ------- fs/smb/client/cifssmb.c | 6 +++--- fs/smb/common/fscc.h | 8 ++++++++ fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb_common.h | 7 ------- 5 files changed, 14 insertions(+), 20 deletions(-)
fs/smb/client/cifspdu.h +0 -7
@@ -1982,13 +1982,6 @@ struct aliasInfo92 {int shareNameOffset; } __attribute__((packed)); -typedef struct { -__le64 TotalAllocationUnits; -__le64 FreeAllocationUnits; -__le32 SectorsPerAllocationUnit; -__le32 BytesPerSector; -} __attribute__((packed))FILE_SYSTEM_INFO ;/* size info, level 0x103 */ - typedef struct { __le32 fsid; __le32 SectorsPerAllocationUnit;
fs/smb/client/cifssmb.c +3 -3
@@ -4724,7 +4724,7 @@ CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,/* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ TRANSACTION2_QFSI_REQ *pSMB =NULL ;TRANSACTION2_QFSI_RSP *pSMBr =NULL ; -FILE_SYSTEM_INFO *response_data; +FILE_SYSTEM_SIZE_INFO *response_data;int rc =0 ;int bytes_returned =0 ;__u16 params, byte_count;
@@ -4772,7 +4772,7 @@ CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,__u16 data_offset =le16_to_cpu (pSMBr->t2.DataOffset); response_data = - (FILE_SYSTEM_INFO + (FILE_SYSTEM_SIZE_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); FSData->f_bsize =
@@ -4789,7 +4789,7 @@ CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon, FSData->f_blocks =le64_to_cpu (response_data->TotalAllocationUnits); FSData->f_bfree = FSData->f_bavail = -le64_to_cpu (response_data->FreeAllocationUnits); +le64_to_cpu (response_data->AvailableAllocationUnits); cifs_dbg(FYI, "Blocks: %lld Free: %lld Block size %ld\n", (unsigned long long)FSData->f_blocks, (unsigned long long)FSData->f_bfree,
fs/smb/common/fscc.h +8 -0
@@ -121,6 +121,14 @@ struct smb2_file_network_open_info {#define FILE_CASE_PRESERVED_NAMES 0x00000002#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 +/* See MS-FSCC 2.5.8 */ +typedef struct { +__le64 TotalAllocationUnits; +__le64 AvailableAllocationUnits; +__le32 SectorsPerAllocationUnit; +__le32 BytesPerSector; +} __packed FILE_SYSTEM_SIZE_INFO; /* size info, level 0x103 */ +/* See MS-FSCC 2.5.10 */ typedef struct { __le32 DeviceType;
fs/smb/server/smb2pdu.c +3 -3
@@ -5546,11 +5546,11 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_SIZE_INFORMATION : { -struct filesystem_info *info; +FILE_SYSTEM_SIZE_INFO *info; - info = (struct filesystem_info *)(rsp->Buffer); + info = (FILE_SYSTEM_SIZE_INFO *)(rsp->Buffer); info->TotalAllocationUnits =cpu_to_le64 (stfs.f_blocks); - info->FreeAllocationUnits =cpu_to_le64 (stfs.f_bfree); + info->AvailableAllocationUnits =cpu_to_le64 (stfs.f_bfree); info->SectorsPerAllocationUnit =cpu_to_le32 (1 ); info->BytesPerSector =cpu_to_le32 (stfs.f_bsize); rsp->OutputBufferLength =cpu_to_le32 (24 );
fs/smb/server/smb_common.h +0 -7
@@ -112,13 +112,6 @@ struct filesystem_vol_info {__le16 VolumeLabel[]; } __packed; -struct filesystem_info { -__le64 TotalAllocationUnits; -__le64 FreeAllocationUnits; -__le32 SectorsPerAllocationUnit; -__le32 BytesPerSector; -} __packed;/* size info, level 0x103 */ -#define EXTENDED_INFO_MAGIC 0x43667364/* Cfsd */ #define STRING_LENGTH 28
Signature · 1 line
2.43.0
PATCH v5 12/14 smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO", then move them to common header file.
Calculate the minimum size of FileFsAttributeInformation using offsetof().
On the server, replace original "sizeof(struct filesystem_attribute_info)" with "MIN_FS_ATTR_INFO_SIZE".
--- fs/smb/client/cifspdu.h | 10 ---------- fs/smb/common/fscc.h | 14 ++++++++++++++ fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb_common.h | 7 ------- 4 files changed, 17 insertions(+), 20 deletions(-)
fs/smb/client/cifspdu.h +0 -10
@@ -2063,16 +2063,6 @@ typedef struct {#define FILE_PORTABLE_DEVICE 0x00004000#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000 -/* minimum includes first three fields, and empty FS Name */ -#define MIN_FS_ATTR_INFO_SIZE 12 - -typedef struct { -__le32 Attributes; -__le32 MaxPathNameComponentLength; -__le32 FileSystemNameLen; -char FileSystemName[52 ];/* do not have to save this - get subset? */ -} __attribute__((packed))FILE_SYSTEM_ATTRIBUTE_INFO ; -/******************************************************************************/ /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */ /******************************************************************************/
fs/smb/common/fscc.h +14 -0
@@ -94,6 +94,20 @@ struct smb2_file_network_open_info {__le32 Reserved; } __packed;/* level 34 Query also similar returned in close rsp and open rsp */ +/* See FS-FSCC 2.5.1 */ +typedef struct { +__le32 Attributes; +__le32 MaxPathNameComponentLength; +__le32 FileSystemNameLen; +__le16 FileSystemName[52 ];/* do not have to save this - get subset? */ +} __packed FILE_SYSTEM_ATTRIBUTE_INFO; + +/* +* minimum size of FileFsAttributeInformation +* includes first three fields, and empty FS Name +*/ +#define MIN_FS_ATTR_INFO_SIZE offsetof(FILE_SYSTEM_ATTRIBUTE_INFO, FileSystemName) +/* List of FileSystemAttributes - see MS-FSCC 2.5.1 */ #define FILE_SUPPORTS_SPARSE_VDL 0x10000000/* faster nonsparse extend */ #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000/* allow ioctl dup extents */
fs/smb/server/smb2pdu.c +3 -3
@@ -5492,10 +5492,10 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_ATTRIBUTE_INFORMATION : { -struct filesystem_attribute_info *info; +FILE_SYSTEM_ATTRIBUTE_INFO *info;size_t sz; - info = (struct filesystem_attribute_info *)rsp->Buffer; + info = (FILE_SYSTEM_ATTRIBUTE_INFO *)rsp->Buffer; info->Attributes = cpu_to_le32(FILE_SUPPORTS_OBJECT_IDS | FILE_PERSISTENT_ACLS | FILE_UNICODE_ON_DISK |
@@ -5514,7 +5514,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, "NTFS", PATH_MAX, conn->local_nls, 0); len = len *2 ; info->FileSystemNameLen =cpu_to_le32 (len); - sz =sizeof (struct filesystem_attribute_info ) + len; + sz =MIN_FS_ATTR_INFO_SIZE + len; rsp->OutputBufferLength =cpu_to_le32 (sz);break ; }
fs/smb/server/smb_common.h +0 -7
@@ -97,13 +97,6 @@ struct smb_negotiate_rsp {__le16 ByteCount; } __packed; -struct filesystem_attribute_info { -__le32 Attributes; -__le32 MaxPathNameComponentLength; -__le32 FileSystemNameLen; -__le16 FileSystemName[];/* do not have to save this - get subset? */ -} __packed; -struct filesystem_vol_info {__le64 VolumeCreationTime;__le32 SerialNumber;
Signature · 1 line
2.43.0
Namjae Jeon
maintainerRe: [PATCH v5 12/14] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
Quoted 45 lines · On Sun, Nov 2, 2025 at 4:32 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO", then move them to common header file.Calculate the minimum size of FileFsAttributeInformation using
offsetof().On the server, replace original "
sizeof(struct filesystem_attribute_info)" with "MIN_FS_ATTR_INFO_SIZE".Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 10 ---------- fs/smb/common/fscc.h | 14 ++++++++++++++ fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb_common.h | 7 ------- 4 files changed, 17 insertions(+), 20 deletions(-)fs/smb/client/cifspdu.h +0
-10@@ -2063,16 +2063,6 @@ typedef struct {#define FILE_PORTABLE_DEVICE 0x00004000#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000 -/* minimum includes first three fields, and empty FS Name */ -#define MIN_FS_ATTR_INFO_SIZE 12 - -typedef struct { -__le32 Attributes; -__le32 MaxPathNameComponentLength; -__le32 FileSystemNameLen; -char FileSystemName[52 ];/* do not have to save this - get subset? */ -} __attribute__((packed))FILE_SYSTEM_ATTRIBUTE_INFO ; -/******************************************************************************/ /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */ /******************************************************************************/ fs/smb/common/fscc.h +0
-0
fs/smb/common/fscc.h struct smb2_file_network_open_info { · line 102
Quoted 9 lines
fs/smb/common/fscc.h +6
-0@@ -94,6 +94,20 @@ struct smb2_file_network_open_info {__le32 Reserved; } __packed;/* level 34 Query also similar returned in close rsp and open rsp */ +/* See FS-FSCC 2.5.1 */ +typedef struct { + __le32 Attributes; + __le32 MaxPathNameComponentLength; + __le32 FileSystemNameLen; + __le16 FileSystemName[52]; /* do not have to save this - get subset? */
Is there any reason why we can not use flex-array ? Thanks.
ChenXiaoSong
reviewerRe: [PATCH v5 12/14] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
In the client-side code, SMB2_QFS_attr() needs to get the maximum and minimum lengths of the FileFsAttributeInformation. Using a flexible array would require more extensive changes.
Thanks,
ChenXiaoSong.
Quoted 2 lines · Namjae Jeon
Is there any reason why we can not use flex-array ? Thanks.
ChenXiaoSong
reviewerRe: [PATCH v5 12/14] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
It seems that the client side does not use FileSystemName[52], so I will try modifying it to use a flexible array.
Thanks,
ChenXiaoSong.
Quoted 9 lines · ChenXiaoSong
In the client-side code,
SMB2_QFS_attr()needs to get the maximum and minimum lengths of the FileFsAttributeInformation. Using a flexible array would require more extensive changes.Thanks,
ChenXiaoSong.Quoted 2 lines · Namjae Jeon
Is there any reason why we can not use flex-array ? Thanks.
PATCH v5 13/14 smb: do some cleanups
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Modify the following places:
- Add documentation references
- ATTR_REPARSE -> ATTR_REPARSE_POINT: consistent with MS-SMB 2.2.1.2.1
- Remove unused File Attribute flags from server, if the server uses them in the future, we can move the client-side definitions to common
- Remove unused SMB1_CLIENT_GUID_SIZE from server
--- fs/smb/client/cifspdu.h | 51 +++++++++++++++++++++----------------- fs/smb/client/readdir.c | 10 ++++---- fs/smb/client/reparse.h | 8 +++--- fs/smb/client/smb1ops.c | 2 +- fs/smb/client/smb2inode.c | 2 +- fs/smb/server/smb_common.h | 19 +++++--------- 6 files changed, 45 insertions(+), 47 deletions(-)
fs/smb/client/cifspdu.h +28 -23
@@ -19,6 +19,7 @@#define BAD_PROT 0xFFFF/* SMB command codes: +* See MS-CIFS 2.2.2.1 * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses * (ie which include no useful data other than the SMB error code itself). * This can allow us to avoid response buffer allocations and copy in some cases
@@ -152,6 +153,7 @@/* * SMB flag definitions +* See MS-CIFS 2.2.3.1 */ #define SMBFLG_EXTD_LOCK 0x01/* server supports lock-read write-unlock smb */ #define SMBFLG_RCV_POSTED 0x02/* obsolete */
@@ -165,6 +167,8 @@/* * SMB flag2 definitions +* See MS-CIFS 2.2.3.1 +* MS-SMB 2.2.3.1 */ #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)/* can send long (non-8.3) path names in response */
@@ -225,29 +229,30 @@/* * File Attribute flags */ -#define ATTR_READONLY 0x0001 -#define ATTR_HIDDEN 0x0002 -#define ATTR_SYSTEM 0x0004 -#define ATTR_VOLUME 0x0008 -#define ATTR_DIRECTORY 0x0010 -#define ATTR_ARCHIVE 0x0020 -#define ATTR_DEVICE 0x0040 -#define ATTR_NORMAL 0x0080 -#define ATTR_TEMPORARY 0x0100 -#define ATTR_SPARSE 0x0200 -#define ATTR_REPARSE 0x0400 -#define ATTR_COMPRESSED 0x0800 -#define ATTR_OFFLINE 0x1000/* ie file not immediately available - -on offline storage */ -#define ATTR_NOT_CONTENT_INDEXED 0x2000 -#define ATTR_ENCRYPTED 0x4000 -#define ATTR_POSIX_SEMANTICS 0x01000000 -#define ATTR_BACKUP_SEMANTICS 0x02000000 -#define ATTR_DELETE_ON_CLOSE 0x04000000 -#define ATTR_SEQUENTIAL_SCAN 0x08000000 -#define ATTR_RANDOM_ACCESS 0x10000000 -#define ATTR_NO_BUFFERING 0x20000000 -#define ATTR_WRITE_THROUGH 0x80000000 +#define ATTR_READONLY 0x0001/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_HIDDEN 0x0002/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_SYSTEM 0x0004/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_VOLUME 0x0008 +#define ATTR_DIRECTORY 0x0010/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_ARCHIVE 0x0020/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_DEVICE 0x0040 +#define ATTR_NORMAL 0x0080/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_TEMPORARY 0x0100/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_SPARSE 0x0200/* See MS-SMB 2.2.1.2.1 */ +#define ATTR_REPARSE_POINT 0x0400/* See MS-SMB 2.2.1.2.1 */ +#define ATTR_COMPRESSED 0x0800/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_OFFLINE 0x1000/* See MS-SMB 2.2.1.2.1 +ie file not immediately available - +on offline storage */ +#define ATTR_NOT_CONTENT_INDEXED 0x2000/* See MS-SMB 2.2.1.2.1 */ +#define ATTR_ENCRYPTED 0x4000/* See MS-SMB 2.2.1.2.1 */ +#define ATTR_POSIX_SEMANTICS 0x0100000/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_BACKUP_SEMANTICS 0x0200000/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_DELETE_ON_CLOSE 0x0400000/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_SEQUENTIAL_SCAN 0x0800000/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_RANDOM_ACCESS 0x1000000/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_NO_BUFFERING 0x2000000/* See MS-CIFS 2.2.1.2.3 */ +#define ATTR_WRITE_THROUGH 0x8000000/* See MS-CIFS 2.2.1.2.3 */ /* ShareAccess flags */ #define FILE_NO_SHARE 0x00000000
fs/smb/client/readdir.c +5 -5
@@ -98,7 +98,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,default :break ; } - }else if (fattr->cf_cifsattrs &ATTR_REPARSE ) { + }else if (fattr->cf_cifsattrs &ATTR_REPARSE_POINT ) { reparse_need_reval = true; }
@@ -138,7 +138,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,* reparse tag and ctime haven't changed. */ rc =0 ; -if (fattr->cf_cifsattrs &ATTR_REPARSE ) { +if (fattr->cf_cifsattrs &ATTR_REPARSE_POINT ) {if (likely (reparse_inode_match (inode, fattr))) { fattr->cf_mode = inode->i_mode; fattr->cf_rdev = inode->i_rdev;
@@ -190,7 +190,7 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)* TODO: go through all documented reparse tags to see if we can * reasonably map some of them to directories vs. files vs. symlinks */ -if ((fattr->cf_cifsattrs &ATTR_REPARSE ) && +if ((fattr->cf_cifsattrs &ATTR_REPARSE_POINT ) &&cifs_reparse_point_to_fattr (cifs_sb, fattr, &data)) goto out_reparse;
@@ -258,7 +258,7 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info, fattr->cf_nlink =le32_to_cpu (info->HardLinks); fattr->cf_cifsattrs =le32_to_cpu (info->DosAttributes); -if (fattr->cf_cifsattrs &ATTR_REPARSE ) +if (fattr->cf_cifsattrs &ATTR_REPARSE_POINT ) fattr->cf_cifstag =le32_to_cpu (info->ReparseTag);/* The Mode field in the response can now include the file type as well */
@@ -316,7 +316,7 @@ static void cifs_fulldir_info_to_fattr(struct cifs_fattr *fattr,__dir_info_to_fattr (fattr, info);/* See MS-FSCC 2.4.14, 2.4.19 */ -if (fattr->cf_cifsattrs &ATTR_REPARSE ) +if (fattr->cf_cifsattrs &ATTR_REPARSE_POINT ) fattr->cf_cifstag =le32_to_cpu (di->EaSize);cifs_fill_common_info (fattr, cifs_sb); }
fs/smb/client/reparse.h +4 -4
@@ -93,7 +93,7 @@ static inline bool reparse_inode_match(struct inode *inode,if (cinode->reparse_tag !=IO_REPARSE_TAG_INTERNAL && cinode->reparse_tag != fattr->cf_cifstag)return false; -return (cinode->cifsAttrs &ATTR_REPARSE ) && +return (cinode->cifsAttrs &ATTR_REPARSE_POINT ) &×pec64_equal (&ctime, &fattr->cf_ctime); }
@@ -107,7 +107,7 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data) attrs =le32_to_cpu (fi->DosAttributes);if (data->reparse_point) { - attrs |=ATTR_REPARSE ; + attrs |=ATTR_REPARSE_POINT ; fi->DosAttributes =cpu_to_le32 (attrs); }
@@ -116,12 +116,12 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data) attrs =le32_to_cpu (fi->Attributes);if (data->reparse_point) { - attrs |=ATTR_REPARSE ; + attrs |=ATTR_REPARSE_POINT ; fi->Attributes =cpu_to_le32 (attrs); } } - ret = attrs &ATTR_REPARSE ; + ret = attrs &ATTR_REPARSE_POINT ;return ret; }
fs/smb/client/smb1ops.c +1 -1
@@ -647,7 +647,7 @@ static int cifs_query_path_info(const unsigned int xid,if (!rc) {move_cifs_info_to_smb2 (&data->fi, &fi); - data->reparse_point =le32_to_cpu (fi.Attributes) &ATTR_REPARSE ; + data->reparse_point =le32_to_cpu (fi.Attributes) &ATTR_REPARSE_POINT ; }#ifdef CONFIG_CIFS_XATTR
fs/smb/client/smb2inode.c +1 -1
@@ -50,7 +50,7 @@ static inline __u32 file_create_options(struct dentry *dentry)if (dentry) { ci =CIFS_I (d_inode (dentry)); -if (ci->cifsAttrs &ATTR_REPARSE ) +if (ci->cifsAttrs &ATTR_REPARSE_POINT )return OPEN_REPARSE_POINT ; }return 0 ;
fs/smb/server/smb_common.h +6 -13
@@ -38,17 +38,6 @@#define F_CREATED 2#define F_OVERWRITTEN 3 -/* -* File Attribute flags -*/ -#define ATTR_POSIX_SEMANTICS 0x01000000 -#define ATTR_BACKUP_SEMANTICS 0x02000000 -#define ATTR_DELETE_ON_CLOSE 0x04000000 -#define ATTR_SEQUENTIAL_SCAN 0x08000000 -#define ATTR_RANDOM_ACCESS 0x10000000 -#define ATTR_NO_BUFFERING 0x20000000 -#define ATTR_WRITE_THROUGH 0x80000000 -/* Combinations of file access permission bits */ #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ | FILE_READ_ATTRIBUTES \
@@ -80,11 +69,15 @@ FILE_EXECUTE | FILE_DELETE_CHILD | \ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) -#define SMB_COM_NEGOTIATE 0x72 -#define SMB1_CLIENT_GUID_SIZE (16) +#define SMB_COM_NEGOTIATE 0x72/* See MS-CIFS 2.2.2.1 */ +/* See MS-CIFS 2.2.3.1 */ #define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ +/* +* See MS-CIFS 2.2.3.1 +* MS-SMB 2.2.3.1 +*/ #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
Signature · 1 line
2.43.0
PATCH v5 14/14 smb: fix some warnings reported by scripts/checkpatch.pl
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Fix the following warnings:
WARNING: __always_unused or __maybe_unused is preferred over \
__attribute__((__unused__))
WARNING: Prefer __packed over __attribute__((packed))--- fs/smb/client/cifspdu.h | 250 ++++++++++++++++++------------------- fs/smb/client/connect.c | 4 +- fs/smb/client/ntlmssp.h | 8 +- fs/smb/client/rfc1002pdu.h | 8 +- fs/smb/common/smbacl.h | 8 +- 5 files changed, 139 insertions(+), 139 deletions(-)
fs/smb/client/cifspdu.h +125 -125
@@ -425,8 +425,8 @@ typedef struct smb_negotiate_rsp {struct {unsigned char GUID[SMB1_CLIENT_GUID_SIZE ];unsigned char SecurityBlob[]; - } __attribute__((packed)) extended_response; - } __attribute__((packed)) u; + } __packed extended_response; + }__packed u; }__packed SMB_NEGOTIATE_RSP ;/* SecurityMode bits */
@@ -474,7 +474,7 @@ typedef union smb_com_session_setup_andx {unsigned char SecurityBlob[];/* followed by */ /* STRING NativeOS */ /* STRING NativeLanMan */ - } __attribute__((packed)) req; /* NTLM request format (with + }__packed req;/* NTLM request format (with extended security */ struct {/* request format */
@@ -497,7 +497,7 @@ typedef union smb_com_session_setup_andx {/* STRING PrimaryDomain */ /* STRING NativeOS */ /* STRING NativeLanMan */ - } __attribute__((packed)) req_no_secext; /* NTLM request format (without + }__packed req_no_secext;/* NTLM request format (without extended security */ struct {/* default (NTLM) response format */
@@ -512,7 +512,7 @@ typedef union smb_com_session_setup_andx {/* unsigned char * NativeOS; */ /* unsigned char * NativeLanMan; */ /* unsigned char * PrimaryDomain; */ - } __attribute__((packed)) resp; /* NTLM response + }__packed resp;/* NTLM response (with or without extended sec) */ struct {/* request format */
@@ -532,7 +532,7 @@ typedef union smb_com_session_setup_andx {/* STRING PrimaryDomain */ /* STRING NativeOS */ /* STRING NativeLanMan */ - } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */ + }__packed old_req;/* pre-NTLM (LANMAN2.1) req format */ struct {/* default (NTLM) response format */ struct smb_hdr hdr;/* wct = 3 */
@@ -544,8 +544,8 @@ typedef union smb_com_session_setup_andx {unsigned char NativeOS[];/* followed by */ /* unsigned char * NativeLanMan; */ /* unsigned char * PrimaryDomain; */ - } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */ -} __attribute__((packed)) SESSION_SETUP_ANDX; + }__packed old_resp;/* pre-NTLM (LANMAN2.1) response */ +}__packed SESSION_SETUP_ANDX ;/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
@@ -559,7 +559,7 @@ struct ntlmssp2_name {__le16 type;__le16 length;__u8 data[]; -} __attribute__((packed)); +} __packed; struct ntlmv2_resp { union {
@@ -567,15 +567,15 @@ struct ntlmv2_resp {struct {__u8 reserved[8 ];__u8 key[CIFS_SERVER_CHALLENGE_SIZE ]; - } __attribute__((packed)) challenge; - } __attribute__((packed)); + } __packed challenge; + } __packed;__le32 blob_signature;__u32 reserved;__le64 time;__u64 client_chal;/* random */ __u32 reserved2;/* array of name entries could follow ending in minimum 4 byte struct */ -} __attribute__((packed)); +} __packed;#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
@@ -610,7 +610,7 @@ typedef struct smb_com_tconx_req {unsigned char Password[];/* followed by */ /* STRING Path *//* \\server\share name */ /* STRING Service */ -} __attribute__((packed)) TCONX_REQ; +}__packed TCONX_REQ ; typedef struct smb_com_tconx_rsp { struct smb_hdr hdr; /* wct = 3 , not extended response */
@@ -621,7 +621,7 @@ typedef struct smb_com_tconx_rsp {__u16 ByteCount;unsigned char Service[];/* always ASCII, not Unicode */ /* STRING NativeFileSystem */ -} __attribute__((packed)) TCONX_RSP; +}__packed TCONX_RSP ; typedef struct smb_com_tconx_rsp_ext { struct smb_hdr hdr; /* wct = 7, extended response */
@@ -634,7 +634,7 @@ typedef struct smb_com_tconx_rsp_ext {__u16 ByteCount;unsigned char Service[];/* always ASCII, not Unicode */ /* STRING NativeFileSystem */ -} __attribute__((packed)) TCONX_RSP_EXT; +}__packed TCONX_RSP_EXT ;/* tree connect Flags */
@@ -670,14 +670,14 @@ typedef struct smb_com_echo_req {__le16 EchoCount;__le16 ByteCount;char Data[]; -} __attribute__((packed)) ECHO_REQ; +}__packed ECHO_REQ ;typedef struct smb_com_echo_rsp {struct smb_hdr hdr;__le16 SequenceNumber;__le16 ByteCount;char Data[]; -} __attribute__((packed))ECHO_RSP ; +} __packed ECHO_RSP; typedef struct smb_com_logoff_andx_req { struct smb_hdr hdr; /* wct = 2 */
@@ -685,7 +685,7 @@ typedef struct smb_com_logoff_andx_req {__u8 AndXReserved;__u16 AndXOffset;__u16 ByteCount; -} __attribute__((packed)) LOGOFF_ANDX_REQ; +}__packed LOGOFF_ANDX_REQ ; typedef struct smb_com_logoff_andx_rsp { struct smb_hdr hdr; /* wct = 2 */
@@ -693,7 +693,7 @@ typedef struct smb_com_logoff_andx_rsp {__u8 AndXReserved;__u16 AndXOffset;__u16 ByteCount; -} __attribute__((packed)) LOGOFF_ANDX_RSP; +}__packed LOGOFF_ANDX_RSP ; typedef union smb_com_tree_disconnect { /* as an alternative can use flag on tree_connect PDU to effect disconnect */
@@ -701,36 +701,36 @@ typedef union smb_com_tree_disconnect { /* as an alternative can use flag onstruct {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bcc = 0 */ - } __attribute__((packed)) req; + } __packed req;struct {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bcc = 0 */ - } __attribute__((packed)) resp; -} __attribute__((packed)) TREE_DISCONNECT; + } __packed resp; +}__packed TREE_DISCONNECT ;typedef struct smb_com_close_req {struct smb_hdr hdr;/* wct = 3 */ __u16 FileID;__u32 LastWriteTime;/* should be zero or -1 */ __u16 ByteCount;/* 0 */ -} __attribute__((packed))CLOSE_REQ ; +} __packed CLOSE_REQ;typedef struct smb_com_close_rsp {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bct = 0 */ -} __attribute__((packed))CLOSE_RSP ; +} __packed CLOSE_RSP;typedef struct smb_com_flush_req {struct smb_hdr hdr;/* wct = 1 */ __u16 FileID;__u16 ByteCount;/* 0 */ -} __attribute__((packed))FLUSH_REQ ; +} __packed FLUSH_REQ;typedef struct smb_com_findclose_req {struct smb_hdr hdr;/* wct = 1 */ __u16 FileID;__u16 ByteCount;/* 0 */ -} __attribute__((packed))FINDCLOSE_REQ ; +} __packed FINDCLOSE_REQ;/* OpenFlags */ #define REQ_MORE_INFO 0x00000001/* legacy (OPEN_AND_X) only */
@@ -777,7 +777,7 @@ typedef struct smb_com_open_req { /* also handles create */__u8 SecurityFlags;__le16 ByteCount;char fileName[]; -} __attribute__((packed)) OPEN_REQ; +}__packed OPEN_REQ ;/* open response: oplock levels */ #define OPLOCK_NONE 0
@@ -809,7 +809,7 @@ typedef struct smb_com_open_rsp {__le16 DeviceState;__u8 DirectoryFlag;__u16 ByteCount;/* bct = 0 */ -} __attribute__((packed)) OPEN_RSP; +}__packed OPEN_RSP ; typedef struct smb_com_open_rsp_ext { struct smb_hdr hdr; /* wct = 42 but meaningless due to MS bug? */
@@ -834,7 +834,7 @@ typedef struct smb_com_open_rsp_ext {__le32 MaximalAccessRights;__le32 GuestMaximalAccessRights;__u16 ByteCount;/* bct = 0 */ -} __attribute__((packed)) OPEN_RSP_EXT; +}__packed OPEN_RSP_EXT ;/* format of legacy open request */
@@ -854,7 +854,7 @@ typedef struct smb_com_openx_req {__le32 Reserved;__le16 ByteCount;/* file name follows */ char fileName[]; -} __attribute__((packed)) OPENX_REQ; +}__packed OPENX_REQ ; typedef struct smb_com_openx_rsp { struct smb_hdr hdr; /* wct = 15 */
@@ -872,7 +872,7 @@ typedef struct smb_com_openx_rsp {__u32 FileId;__u16 Reserved;__u16 ByteCount; -} __attribute__((packed)) OPENX_RSP; +}__packed OPENX_RSP ;/* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
@@ -894,7 +894,7 @@ typedef struct smb_com_writex_req {__u8 Pad;/* BB check for whether padded to DWORD boundary and optimum performance here */ char Data[]; -} __attribute__((packed)) WRITEX_REQ; +}__packed WRITEX_REQ ; typedef struct smb_com_write_req { struct smb_hdr hdr; /* wct = 14 */
@@ -914,7 +914,7 @@ typedef struct smb_com_write_req {__u8 Pad;/* BB check for whether padded to DWORD boundary and optimum performance here */ char Data[]; -} __attribute__((packed)) WRITE_REQ; +}__packed WRITE_REQ ; typedef struct smb_com_write_rsp { struct smb_hdr hdr; /* wct = 6 */
@@ -926,7 +926,7 @@ typedef struct smb_com_write_rsp {__le16 CountHigh;__u16 Reserved;__u16 ByteCount; -} __attribute__((packed)) WRITE_RSP; +}__packed WRITE_RSP ;/* legacy read request for older servers */ typedef struct smb_com_readx_req {
@@ -941,7 +941,7 @@ typedef struct smb_com_readx_req {__le32 Reserved;__le16 Remaining;__le16 ByteCount; -} __attribute__((packed)) READX_REQ; +}__packed READX_REQ ; typedef struct smb_com_read_req { struct smb_hdr hdr; /* wct = 12 */
@@ -956,7 +956,7 @@ typedef struct smb_com_read_req {__le16 Remaining;__le32 OffsetHigh;__le16 ByteCount; -} __attribute__((packed)) READ_REQ; +}__packed READ_REQ ; typedef struct smb_com_read_rsp { struct smb_hdr hdr; /* wct = 12 */
@@ -972,7 +972,7 @@ typedef struct smb_com_read_rsp {__u64 Reserved2;__u16 ByteCount;/* read response data immediately follows */ -} __attribute__((packed)) READ_RSP; +}__packed READ_RSP ; typedef struct locking_andx_range { __le16 Pid;
@@ -981,7 +981,7 @@ typedef struct locking_andx_range {__le32 OffsetLow;__le32 LengthHigh;__le32 LengthLow; -} __attribute__((packed)) LOCKING_ANDX_RANGE; +}__packed LOCKING_ANDX_RANGE ;#define LOCKING_ANDX_SHARED_LOCK 0x01#define LOCKING_ANDX_OPLOCK_RELEASE 0x02
@@ -1002,7 +1002,7 @@ typedef struct smb_com_lock_req {__le16 NumberOfLocks;__le16 ByteCount;LOCKING_ANDX_RANGE Locks[]; -} __attribute__((packed)) LOCK_REQ; +}__packed LOCK_REQ ;/* lock type */ #define CIFS_RDLCK 0
@@ -1015,7 +1015,7 @@ typedef struct cifs_posix_lock {__le64 start;__le64 length;/* BB what about additional owner info to identify network client */ -} __attribute__((packed)) CIFS_POSIX_LOCK; +}__packed CIFS_POSIX_LOCK ; typedef struct smb_com_lock_rsp { struct smb_hdr hdr; /* wct = 2 */
@@ -1023,7 +1023,7 @@ typedef struct smb_com_lock_rsp {__u8 AndXReserved;__le16 AndXOffset;__u16 ByteCount; -} __attribute__((packed)) LOCK_RSP; +}__packed LOCK_RSP ; typedef struct smb_com_rename_req { struct smb_hdr hdr; /* wct = 1 */
@@ -1033,7 +1033,7 @@ typedef struct smb_com_rename_req {unsigned char OldFileName[];/* followed by __u8 BufferFormat2 */ /* followed by NewFileName */ -} __attribute__((packed)) RENAME_REQ; +}__packed RENAME_REQ ;/* copy request flags */ #define COPY_MUST_BE_FILE 0x0001
@@ -1053,7 +1053,7 @@ typedef struct smb_com_copy_req {unsigned char OldFileName[];/* followed by __u8 BufferFormat2 */ /* followed by NewFileName string */ -} __attribute__((packed)) COPY_REQ; +}__packed COPY_REQ ; typedef struct smb_com_copy_rsp { struct smb_hdr hdr; /* wct = 1 */
@@ -1061,7 +1061,7 @@ typedef struct smb_com_copy_rsp {__u16 ByteCount;/* may be zero */ __u8 BufferFormat;/* 0x04 - only present if errored file follows */ unsigned char ErrorFileName[];/* only present if error in copy */ -} __attribute__((packed)) COPY_RSP; +}__packed COPY_RSP ;#define CREATE_HARD_LINK 0x103#define MOVEFILE_COPY_ALLOWED 0x0002
@@ -1077,12 +1077,12 @@ typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */unsigned char OldFileName[];/* followed by __u8 BufferFormat2 */ /* followed by NewFileName */ -} __attribute__((packed)) NT_RENAME_REQ; +}__packed NT_RENAME_REQ ;typedef struct smb_com_rename_rsp {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bct = 0 */ -} __attribute__((packed))RENAME_RSP ; +} __packed RENAME_RSP; typedef struct smb_com_delete_file_req { struct smb_hdr hdr; /* wct = 1 */
@@ -1090,43 +1090,43 @@ typedef struct smb_com_delete_file_req {__le16 ByteCount;__u8 BufferFormat;/* 4 = ASCII */ unsigned char fileName[]; -} __attribute__((packed)) DELETE_FILE_REQ; +}__packed DELETE_FILE_REQ ;typedef struct smb_com_delete_file_rsp {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bct = 0 */ -} __attribute__((packed))DELETE_FILE_RSP ; +} __packed DELETE_FILE_RSP;typedef struct smb_com_delete_directory_req {struct smb_hdr hdr;/* wct = 0 */ __le16 ByteCount;__u8 BufferFormat;/* 4 = ASCII */ unsigned char DirName[]; -} __attribute__((packed))DELETE_DIRECTORY_REQ ; +} __packed DELETE_DIRECTORY_REQ;typedef struct smb_com_delete_directory_rsp {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bct = 0 */ -} __attribute__((packed))DELETE_DIRECTORY_RSP ; +} __packed DELETE_DIRECTORY_RSP;typedef struct smb_com_create_directory_req {struct smb_hdr hdr;/* wct = 0 */ __le16 ByteCount;__u8 BufferFormat;/* 4 = ASCII */ unsigned char DirName[]; -} __attribute__((packed))CREATE_DIRECTORY_REQ ; +} __packed CREATE_DIRECTORY_REQ;typedef struct smb_com_create_directory_rsp {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bct = 0 */ -} __attribute__((packed))CREATE_DIRECTORY_RSP ; +} __packed CREATE_DIRECTORY_RSP;typedef struct smb_com_query_information_req {struct smb_hdr hdr;/* wct = 0 */ __le16 ByteCount;/* 1 + namelen + 1 */ __u8 BufferFormat;/* 4 = ASCII */ unsigned char FileName[]; -} __attribute__((packed))QUERY_INFORMATION_REQ ; +} __packed QUERY_INFORMATION_REQ; typedef struct smb_com_query_information_rsp { struct smb_hdr hdr; /* wct = 10 */
@@ -1135,7 +1135,7 @@ typedef struct smb_com_query_information_rsp {__le32 size;__u16 reserved[5 ];__le16 ByteCount;/* bcc = 0 */ -} __attribute__((packed)) QUERY_INFORMATION_RSP; +}__packed QUERY_INFORMATION_RSP ; typedef struct smb_com_setattr_req { struct smb_hdr hdr; /* wct = 8 */
@@ -1145,12 +1145,12 @@ typedef struct smb_com_setattr_req {__le16 ByteCount;__u8 BufferFormat;/* 4 = ASCII */ unsigned char fileName[]; -} __attribute__((packed)) SETATTR_REQ; +}__packed SETATTR_REQ ;typedef struct smb_com_setattr_rsp {struct smb_hdr hdr;/* wct = 0 */ __u16 ByteCount;/* bct = 0 */ -} __attribute__((packed))SETATTR_RSP ; +} __packed SETATTR_RSP;/* empty wct response to setattr */
@@ -1178,7 +1178,7 @@ typedef struct smb_com_ntransact_req {__le16 ByteCount;__u8 Pad[3 ];__u8 Parms[]; -} __attribute__((packed)) NTRANSACT_REQ; +}__packed NTRANSACT_REQ ; typedef struct smb_com_ntransact_rsp { struct smb_hdr hdr; /* wct = 18 */
@@ -1195,7 +1195,7 @@ typedef struct smb_com_ntransact_rsp {__u16 ByteCount;/* __u8 Pad[3]; */ /* parms and data follow */ -} __attribute__((packed)) NTRANSACT_RSP; +}__packed NTRANSACT_RSP ; typedef struct smb_com_transaction_ioctl_req { struct smb_hdr hdr; /* wct = 23 */
@@ -1219,7 +1219,7 @@ typedef struct smb_com_transaction_ioctl_req {__le16 ByteCount;__u8 Pad[3 ];__u8 Data[]; -} __attribute__((packed)) TRANSACT_IOCTL_REQ; +}__packed TRANSACT_IOCTL_REQ ; typedef struct smb_com_transaction_compr_ioctl_req { struct smb_hdr hdr; /* wct = 23 */
@@ -1243,7 +1243,7 @@ typedef struct smb_com_transaction_compr_ioctl_req {__le16 ByteCount;__u8 Pad[3 ];__le16 compression_state;/* See below for valid flags */ -} __attribute__((packed)) TRANSACT_COMPR_IOCTL_REQ; +}__packed TRANSACT_COMPR_IOCTL_REQ ;/* compression state flags */ #define COMPRESSION_FORMAT_NONE 0x0000
@@ -1264,7 +1264,7 @@ typedef struct smb_com_transaction_ioctl_rsp {__u8 SetupCount;/* 1 */ __le16 ReturnedDataLen;__le16 ByteCount; -} __attribute__((packed)) TRANSACT_IOCTL_RSP; +}__packed TRANSACT_IOCTL_RSP ;#define CIFS_ACL_OWNER 1#define CIFS_ACL_GROUP 2
@@ -1291,7 +1291,7 @@ typedef struct smb_com_transaction_qsec_req {__u16 Fid;__u16 Reserved2;__le32 AclFlags; -} __attribute__((packed)) QUERY_SEC_DESC_REQ; +}__packed QUERY_SEC_DESC_REQ ; typedef struct smb_com_transaction_ssec_req {
@@ -1314,7 +1314,7 @@ typedef struct smb_com_transaction_ssec_req {__u16 Fid;__u16 Reserved2;__le32 AclFlags; -} __attribute__((packed)) SET_SEC_DESC_REQ; +}__packed SET_SEC_DESC_REQ ; typedef struct smb_com_transaction_change_notify_req { struct smb_hdr hdr; /* wct = 23 */
@@ -1338,7 +1338,7 @@ typedef struct smb_com_transaction_change_notify_req {__le16 ByteCount;/* __u8 Pad[3];*/ /* __u8 Data[];*/ -} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ; +}__packed TRANSACT_CHANGE_NOTIFY_REQ ;/* BB eventually change to use generic ntransact rsp struct and validation routine */
@@ -1356,7 +1356,7 @@ typedef struct smb_com_transaction_change_notify_rsp {__u8 SetupCount;/* 0 */ __u16 ByteCount;/* __u8 Pad[3]; */ -} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP; +}__packed TRANSACT_CHANGE_NOTIFY_RSP ;/* Completion Filter flags for Notify */ #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
@@ -1387,7 +1387,7 @@ struct file_notify_information {__le32 Action;__le32 FileNameLength;__u8 FileName[]; -} __attribute__((packed)); +} __packed;struct cifs_quota_data {__u32 rsrvd1;/* 0 */
@@ -1397,7 +1397,7 @@ struct cifs_quota_data {__u64 soft_limit;__u64 hard_limit;char sid[];/* variable size? */ -} __attribute__((packed)); +} __packed;/* quota sub commands */ #define QUOTA_LIST_CONTINUE 0
@@ -1423,12 +1423,12 @@ struct trans2_req {__u8 Reserved3;__le16 SubCommand;/* 1st setup word - SetupCount words follow */ __le16 ByteCount; -} __attribute__((packed)); +} __packed;struct smb_t2_req {struct smb_hdr hdr;struct trans2_req t2_req; -} __attribute__((packed)); +} __packed;struct trans2_resp {/* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
@@ -1447,12 +1447,12 @@ struct trans2_resp {__u16 ByteCount; __u16 Reserved2;*/ /* data area follows */ -} __attribute__((packed)); +} __packed;struct smb_t2_rsp {struct smb_hdr hdr;struct trans2_resp t2_rsp; -} __attribute__((packed)); +} __packed;/* PathInfo/FileInfo infolevels */ #define SMB_INFO_STANDARD 1
@@ -1549,14 +1549,14 @@ typedef struct smb_com_transaction2_qpi_req {__le16 InformationLevel;__u32 Reserved4;char FileName[]; -} __attribute__((packed)) TRANSACTION2_QPI_REQ; +}__packed TRANSACTION2_QPI_REQ ;typedef struct smb_com_transaction2_qpi_rsp {struct smb_hdr hdr;/* wct = 10 + SetupCount */ struct trans2_resp t2;__u16 ByteCount;__u16 Reserved2;/* parameter word is present for infolevels > 100 */ -} __attribute__((packed))TRANSACTION2_QPI_RSP ; +} __packed TRANSACTION2_QPI_RSP; typedef struct smb_com_transaction2_spi_req { struct smb_hdr hdr; /* wct = 15 */
@@ -1582,21 +1582,21 @@ typedef struct smb_com_transaction2_spi_req {__le16 InformationLevel;__u32 Reserved4;char FileName[]; -} __attribute__((packed)) TRANSACTION2_SPI_REQ; +}__packed TRANSACTION2_SPI_REQ ;typedef struct smb_com_transaction2_spi_rsp {struct smb_hdr hdr;/* wct = 10 + SetupCount */ struct trans2_resp t2;__u16 ByteCount;__u16 Reserved2;/* parameter word is present for infolevels > 100 */ -} __attribute__((packed))TRANSACTION2_SPI_RSP ; +} __packed TRANSACTION2_SPI_RSP;struct set_file_rename {__le32 overwrite;/* 1 = overwrite dest */ __u32 root_fid;/* zero */ __le32 target_name_len;char target_name[];/* Must be unicode */ -} __attribute__((packed)); +} __packed;struct smb_com_transaction2_sfi_req {struct smb_hdr hdr;/* wct = 15 */
@@ -1623,14 +1623,14 @@ struct smb_com_transaction2_sfi_req {__le16 InformationLevel;__u16 Reserved4;__u8 payload[]; -} __attribute__((packed)); +} __packed;struct smb_com_transaction2_sfi_rsp {struct smb_hdr hdr;/* wct = 10 + SetupCount */ struct trans2_resp t2;__u16 ByteCount;__u16 Reserved2;/* parameter word reserved - present for infolevels > 100 */ -} __attribute__((packed)); +} __packed;struct smb_t2_qfi_req {struct smb_hdr hdr;
@@ -1638,14 +1638,14 @@ struct smb_t2_qfi_req {__u8 Pad;__u16 Fid;__le16 InformationLevel; -} __attribute__((packed)); +} __packed;struct smb_t2_qfi_rsp {struct smb_hdr hdr;/* wct = 10 + SetupCount */ struct trans2_resp t2;__u16 ByteCount;__u16 Reserved2;/* parameter word reserved - present for infolevels > 100 */ -} __attribute__((packed)); +} __packed;/* * Flags on T2 FINDFIRST and FINDNEXT
@@ -1687,13 +1687,13 @@ typedef struct smb_com_transaction2_ffirst_req {__le16 InformationLevel;__le32 SearchStorageType;char FileName[]; -} __attribute__((packed)) TRANSACTION2_FFIRST_REQ; +}__packed TRANSACTION2_FFIRST_REQ ;typedef struct smb_com_transaction2_ffirst_rsp {struct smb_hdr hdr;/* wct = 10 */ struct trans2_resp t2;__u16 ByteCount; -} __attribute__((packed))TRANSACTION2_FFIRST_RSP ; +} __packed TRANSACTION2_FFIRST_RSP; typedef struct smb_com_transaction2_ffirst_rsp_parms { __u16 SearchHandle;
@@ -1701,7 +1701,7 @@ typedef struct smb_com_transaction2_ffirst_rsp_parms {__le16 EndofSearch;__le16 EAErrorOffset;__le16 LastNameOffset; -} __attribute__((packed)) T2_FFIRST_RSP_PARMS; +}__packed T2_FFIRST_RSP_PARMS ; typedef struct smb_com_transaction2_fnext_req { struct smb_hdr hdr; /* wct = 15 */
@@ -1729,20 +1729,20 @@ typedef struct smb_com_transaction2_fnext_req {__u32 ResumeKey;__le16 SearchFlags;char ResumeFileName[]; -} __attribute__((packed)) TRANSACTION2_FNEXT_REQ; +}__packed TRANSACTION2_FNEXT_REQ ;typedef struct smb_com_transaction2_fnext_rsp {struct smb_hdr hdr;/* wct = 10 */ struct trans2_resp t2;__u16 ByteCount; -} __attribute__((packed))TRANSACTION2_FNEXT_RSP ; +} __packed TRANSACTION2_FNEXT_RSP;typedef struct smb_com_transaction2_fnext_rsp_parms {__le16 SearchCount;__le16 EndofSearch;__le16 EAErrorOffset;__le16 LastNameOffset; -} __attribute__((packed))T2_FNEXT_RSP_PARMS ; +} __packed T2_FNEXT_RSP_PARMS;/* QFSInfo Levels */ #define SMB_INFO_ALLOCATION 1
@@ -1786,14 +1786,14 @@ typedef struct smb_com_transaction2_qfsi_req {__le16 ByteCount;__u8 Pad;__le16 InformationLevel; -} __attribute__((packed)) TRANSACTION2_QFSI_REQ; +}__packed TRANSACTION2_QFSI_REQ ;typedef struct smb_com_transaction_qfsi_rsp {struct smb_hdr hdr;/* wct = 10 + SetupCount */ struct trans2_resp t2;__u16 ByteCount;__u8 Pad;/* may be three bytes? *//* followed by data area */ -} __attribute__((packed))TRANSACTION2_QFSI_RSP ; +} __packed TRANSACTION2_QFSI_RSP; typedef struct whoami_rsp_data { /* Query level 0x202 */ __u32 flags; /* 0 = Authenticated user 1 = GUEST */
@@ -1806,7 +1806,7 @@ typedef struct whoami_rsp_data { /* Query level 0x202 */__u32 pad;/* reserved - MBZ */ /* __u64 gid_array[0]; */ /* may be empty */ /* __u8 * psid_list */ /* may be empty */ -} __attribute__((packed)) WHOAMI_RSP_DATA; +}__packed WHOAMI_RSP_DATA ;/* SETFSInfo Levels */ #define SMB_SET_CIFS_UNIX_INFO 0x200
@@ -1839,7 +1839,7 @@ typedef struct smb_com_transaction2_setfsi_req {__le16 ClientUnixMajor;/* Data start. */ __le16 ClientUnixMinor;__le64 ClientUnixCap;/* Data end */ -} __attribute__((packed)) TRANSACTION2_SETFSI_REQ; +}__packed TRANSACTION2_SETFSI_REQ ;/* level 0x203 request structure follows */ typedef struct smb_com_transaction2_setfs_enc_req {
@@ -1865,14 +1865,14 @@ typedef struct smb_com_transaction2_setfs_enc_req {__u16 Reserved4;/* Parameters start. */ __le16 InformationLevel;/* Parameters end. */ /* NTLMSSP Blob, Data start. */ -} __attribute__((packed)) TRANSACTION2_SETFSI_ENC_REQ; +}__packed TRANSACTION2_SETFSI_ENC_REQ ;/* response for setfsinfo levels 0x200 and 0x203 */ typedef struct smb_com_transaction2_setfsi_rsp {struct smb_hdr hdr;/* wct = 10 */ struct trans2_resp t2;__u16 ByteCount; -} __attribute__((packed))TRANSACTION2_SETFSI_RSP ; +} __packed TRANSACTION2_SETFSI_RSP; typedef struct smb_com_transaction2_get_dfs_refer_req { struct smb_hdr hdr; /* wct = 15 */
@@ -1898,7 +1898,7 @@ typedef struct smb_com_transaction2_get_dfs_refer_req {seem to matter though */ __le16 MaxReferralLevel;char RequestFileName[]; -} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ; +}__packed TRANSACTION2_GET_DFS_REFER_REQ ;#define DFS_VERSION cpu_to_le16(0x0003)
@@ -1920,7 +1920,7 @@ typedef struct dfs_referral_level_3 { /* version 4 is same, + one flag bit */__le16 DfsAlternatePathOffset;__le16 NetworkAddressOffset;/* offset of the link target */ __u8 ServiceSiteGuid[16 ];/* MBZ, ignored */ -} __attribute__((packed)) REFERRAL3; +}__packed REFERRAL3 ;struct get_dfs_referral_rsp {__le16 PathConsumed;
@@ -1960,7 +1960,7 @@ struct serverInfo {unsigned char versionMinor;unsigned long type;unsigned int commentOffset; -} __attribute__((packed)); +} __packed;/* * The following structure is the format of the data returned on a NetShareEnum
@@ -1972,20 +1972,20 @@ struct shareInfo {char pad;unsigned short type;unsigned int commentOffset; -} __attribute__((packed)); +} __packed;struct aliasInfo {char aliasName[9 ];char pad;unsigned int commentOffset;unsigned char type[2 ]; -} __attribute__((packed)); +} __packed;struct aliasInfo92 {int aliasNameOffset;int serverNameOffset;int shareNameOffset; -} __attribute__((packed)); +} __packed; typedef struct { __le32 fsid;
@@ -1993,13 +1993,13 @@ typedef struct {__le32 TotalAllocationUnits;__le32 FreeAllocationUnits;__le16 BytesPerSector; -} __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO; +}__packed FILE_SYSTEM_ALLOC_INFO ;typedef struct {__le16 MajorVersionNumber;__le16 MinorVersionNumber;__le64 Capability; -} __attribute__((packed))FILE_SYSTEM_UNIX_INFO ;/* Unix extension level 0x200*/ +} __packed FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*//* Version numbers for CIFS UNIX major and minor. */ #define CIFS_UNIX_MAJOR_VERSION 1
@@ -2092,7 +2092,7 @@ typedef struct { /* data block encoding of response to level 263 QPathInfo */char __pad;DECLARE_FLEX_ARRAY (char, FileName); }; -} __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */ +}__packed FILE_ALL_INFO ;/* level 0x107 QPathInfo */ typedef struct { __le64 AllocationSize;
@@ -2101,7 +2101,7 @@ typedef struct {__u8 DeletePending;__u8 Directory;__u16 Pad; -} __attribute__((packed)) FILE_STANDARD_INFO; /* level 0x102 QPathInfo */ +}__packed FILE_STANDARD_INFO ;/* level 0x102 QPathInfo */ /* defines for enumerating possible values of the Unix type field below */
@@ -2126,11 +2126,11 @@ typedef struct {__le64 UniqueId;__le64 Permissions;__le64 Nlinks; -} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */ +}__packed FILE_UNIX_BASIC_INFO ;/* level 0x200 QPathInfo */ typedef struct { DECLARE_FLEX_ARRAY(char, LinkDest); -} __attribute__((packed))FILE_UNIX_LINK_INFO ;/* level 0x201 QPathInfo */ +} __packed FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo *//* The following three structures are needed only for setting time to NT4 and some older servers via
@@ -2139,13 +2139,13 @@ typedef struct { __u16 Day:5; __u16 Month:4; __u16 Year:7; -} __attribute__((packed)) SMB_DATE; +}__packed SMB_DATE ;typedef struct {__u16 TwoSeconds:5 ;__u16 Minutes:6 ;__u16 Hours:5 ; -} __attribute__((packed))SMB_TIME ; +} __packed SMB_TIME; typedef struct { __le16 CreationDate; /* SMB Date see above */
@@ -2158,7 +2158,7 @@ typedef struct {__le32 AllocationSize;__le16 Attributes;/* verify not u32 */ __le32 EASize; -} __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */ +}__packed FILE_INFO_STANDARD ;/* level 1 SetPath/FileInfo */ typedef struct { __le64 CreationTime;
@@ -2167,7 +2167,7 @@ typedef struct {__le64 ChangeTime;__le32 Attributes;__u32 Pad; -} __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */ +}__packed FILE_BASIC_INFO ;/* size info, level 0x101 */ struct file_allocation_info {__le64 AllocationSize;/* Note old Samba srvr rounds this up too much */
@@ -2175,11 +2175,11 @@ struct file_allocation_info {struct file_end_of_file_info {__le64 FileSize;/* offset to end of file */ -} __attribute__((packed));/* size info, level 0x104 for set, 0x106 for query */ +} __packed;/* size info, level 0x104 for set, 0x106 for query */ struct file_alt_name_info { DECLARE_FLEX_ARRAY(__u8, alt_name); -} __attribute__((packed));/* level 0x0108 */ +} __packed;/* level 0x0108 */ struct file_stream_info {__le32 number_of_streams;/* BB check sizes and verify location */
@@ -2196,7 +2196,7 @@ struct file_compression_info {__u8 ch_shift;__u8 cl_shift;__u8 pad[3 ]; -} __attribute__((packed)); /* level 0x10b */ +} __packed;/* level 0x10b */ /* POSIX ACL set/query path info structures */ #define CIFS_ACL_VERSION 1
@@ -2204,7 +2204,7 @@ struct cifs_posix_ace { /* access control entry (ACE) */__u8 cifs_e_tag;__u8 cifs_e_perm;__le64 cifs_uid;/* or gid */ -} __attribute__((packed)); +} __packed;struct cifs_posix_acl {/* access control list (ACL) */ __le16 version;
@@ -2212,7 +2212,7 @@ struct cifs_posix_acl { /* access control list (ACL) */__le16 default_entry_count;/* default ACL - count of entries */ struct cifs_posix_ace ace_array[];/* followed by struct cifs_posix_ace default_ace_array[] */ -} __attribute__((packed)); /* level 0x204 */ +} __packed;/* level 0x204 */ /* types of access control entries already defined in posix_acl.h */ /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
@@ -2247,7 +2247,7 @@ typedef struct {__le32 PosixOpenFlags;__le64 Permissions;__le16 Level;/* reply level requested (see QPathInfo levels) */ -} __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */ +}__packed OPEN_PSX_REQ ;/* level 0x209 SetPathInfo data */ typedef struct { __le16 OplockFlags;
@@ -2256,27 +2256,27 @@ typedef struct {__le16 ReturnedLevel;__le16 Pad;/* struct following varies based on requested level */ -} __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */ +}__packed OPEN_PSX_RSP ;/* level 0x209 SetPathInfo data */ #define SMB_POSIX_UNLINK_FILE_TARGET 0#define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1struct unlink_psx_rq {/* level 0x20a SetPathInfo */ __le16 type; -} __attribute__((packed)); +} __packed;struct file_internal_info {__le64 UniqueId;/* inode number */ -} __attribute__((packed));/* level 0x3ee */ +} __packed;/* level 0x3ee */ struct file_mode_info {__le32 Mode; -} __attribute__((packed));/* level 0x3f8 */ +} __packed;/* level 0x3f8 */ struct file_attrib_tag {__le32 Attribute;__le32 ReparseTag; -} __attribute__((packed));/* level 0x40b */ +} __packed;/* level 0x40b */ /********************************************************/
@@ -2291,7 +2291,7 @@ typedef struct {char __pad;DECLARE_FLEX_ARRAY (char, FileName); }; -} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */ +}__packed FILE_UNIX_INFO ;/* level 0x202 */ typedef struct { __u32 ResumeKey;
@@ -2306,7 +2306,7 @@ typedef struct {__le16 Attributes;/* verify not u32 */ __u8 FileNameLength;char FileName[]; -} __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */ +}__packed FIND_FILE_STANDARD_INFO ;/* level 0x1 FF resp data */ struct fea {
@@ -2315,21 +2315,21 @@ struct fea {__le16 value_len;char name[];/* optionally followed by value */ -} __attribute__((packed)); +} __packed;/* flags for _FEA.fEA */ #define FEA_NEEDEA 0x80/* need EA bit */ struct fealist {__le32 list_len;struct fea list; -} __attribute__((packed)); +} __packed;/* used to hold an arbitrary blob of data */ struct data_blob {__u8 *data;size_t length;void (*free) (struct data_blob *data_blob); -} __attribute__((packed)); +} __packed;#ifdef CONFIG_CIFS_POSIX
@@ -2432,7 +2432,7 @@ struct xsymlink {char cr2;/* \n */ /* if room left, then end with \n then 0x20s by convention but not required */ char path[1024 ]; -} __attribute__((packed)); +} __packed; typedef struct file_xattr_info { /* BB do we need another field for flags? BB */
fs/smb/client/connect.c +2 -2
@@ -2326,8 +2326,8 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses) }#else /* ! CONFIG_KEYS */ static inline int -cifs_set_cifscreds (struct smb3_fs_context *ctx __attribute__((unused)), -struct cifs_ses *ses __attribute__((unused))) +cifs_set_cifscreds (struct smb3_fs_context *ctx__maybe_unused , +struct cifs_ses *ses__maybe_unused ) {return -ENOSYS ; }
fs/smb/client/ntlmssp.h +4 -4
@@ -73,7 +73,7 @@ typedef struct _SECURITY_BUFFER {__le16 Length;__le16 MaximumLength;__le32 BufferOffset;/* offset to buffer */ -} __attribute__((packed)) SECURITY_BUFFER; +}__packed SECURITY_BUFFER ; typedef struct _NEGOTIATE_MESSAGE { __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
@@ -85,7 +85,7 @@ typedef struct _NEGOTIATE_MESSAGE {do not set the version is present flag */ char DomainString[];/* followed by WorkstationString */ -} __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; +}__packed NEGOTIATE_MESSAGE , *PNEGOTIATE_MESSAGE ;#define NTLMSSP_REVISION_W2K3 0x0F
@@ -121,7 +121,7 @@ typedef struct _CHALLENGE_MESSAGE {SECURITY_BUFFER TargetInfoArray;/* SECURITY_BUFFER for version info not present since we do not set the version is present flag */ -} __attribute__((packed)) CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE; +}__packed CHALLENGE_MESSAGE , *PCHALLENGE_MESSAGE ; typedef struct _AUTHENTICATE_MESSAGE { __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
@@ -136,7 +136,7 @@ typedef struct _AUTHENTICATE_MESSAGE {struct ntlmssp_version Version;/* SECURITY_BUFFER */ char UserString[]; -} __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; +}__packed AUTHENTICATE_MESSAGE , *PAUTHENTICATE_MESSAGE ;/* * Size of the session key (crypto key encrypted with the password
fs/smb/client/rfc1002pdu.h +4 -4
@@ -33,17 +33,17 @@ struct rfc1002_session_packet {__u8 calling_len;__u8 calling_name[32 ];__u8 scope2;/* null */ - } __attribute__((packed)) session_req; + }__packed session_req;struct {__be32 retarget_ip_addr;__be16 port; - } __attribute__((packed)) retarget_resp; + } __packed retarget_resp;__u8 neg_ses_resp_error_code;/* POSITIVE_SESSION_RESPONSE packet does not include trailer. SESSION_KEEP_ALIVE packet also does not include a trailer. Trailer for the SESSION_MESSAGE packet is SMB/CIFS header */ - } __attribute__((packed)) trailer; -} __attribute__((packed)); + }__packed trailer; +} __packed;/* Negative Session Response error codes */ #define RFC1002_NOT_LISTENING_CALLED 0x80/* not listening on called name */
fs/smb/common/smbacl.h +4 -4
@@ -92,14 +92,14 @@ struct smb_ntsd {__le32 gsidoffset;__le32 sacloffset;__le32 dacloffset; -} __attribute__((packed)); +} __packed;struct smb_sid {__u8 revision;/* revision level */ __u8 num_subauth;__u8 authority[NUM_AUTHS ];__le32 sub_auth[SID_MAX_SUB_AUTHORITIES ];/* sub_auth[num_subauth] */ -} __attribute__((packed)); +} __packed;/* size of a struct smb_sid, sans sub_auth array */ #define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS)
@@ -109,7 +109,7 @@ struct smb_acl {__le16 size;__le16 num_aces;__le16 reserved; -} __attribute__((packed)); +} __packed;struct smb_ace {__u8 type;/* see above and MS-DTYP 2.4.4.1 */
@@ -117,6 +117,6 @@ struct smb_ace {__le16 size;__le32 access_req; struct smb_sid sid; /* ie UUID of user or group who gets these perms */ -} __attribute__((packed)); +} __packed;#endif /* _COMMON_SMBACL_H */
Signature · 1 line
2.43.0
ChenXiaoSong
reviewerHi Steve and Namjae,
I have tested the following patches using xfstests and smbtorture, no additional failed test cases were observed in the test results.
- [PATCH v2 0/6] smb/server: fix return values of smb2_0_server_cmds proc
- Patches applied to the ksmbd-for-next-next branch
- [PATCH v5 00/14] smb: move duplicate definitions to common header file
The detailed test results can be found in http://chenxiaosong.com/smb-test/20251109
Thanks,
ChenXiaoSong.
Quoted 83 lines · On 11/2/25 3:30 PM, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
The following patches from v3 have already been merged into the mainline:
-
6fced056d2ccsmb/server: fix possible memory leak insmb2_read()
-379510a815cbsmb/server: fix possible refcount leak insmb2_sess_setup()
-d877470b5991smb: move some duplicate definitions tocommon/cifsglob.hThe following patches from v4 have been applied to [the ksmbd-for-next-next branch](https://git.samba.org/?p=ksmbd.git;a=shortlog;h=refs/heads/ksmbd-for-next-next):
- smb: move
resume_key_ioctl_rsptocommon/smb2pdu.h
- smb: move copychunk definitions tocommon/smb2pdu.h
- smb: movesmb_sockaddr_inandsmb_sockaddr_in6tocommon/smb2pdu.h
- smb: moveSMB1_PROTO_NUMBERtocommon/smbglob.h
- smb: moveget_rfc1002_len()tocommon/smbglob.h
- smb: movesmb_version_valuestocommon/smbglob.h
- smb: renamecommon/cifsglob.htocommon/smbglob.hIn order to maintain the code more easily, move some duplicate definitions to common header file.
Add some MS documentation references for macro and struct definitions.
I will test these code changes with smbtorure and xfstests as soon as possible.
By cleaning the common definitions for client and server, I've become more familiar with the MS documentation, which I believe will be very useful for developing SMB features soon.
v4->v5:
- The following modifications were made according to Namjae's and Steve's suggestions.
- Create patch #01 #02 #08.
- Patch #07: move structsmb_hdrtocommon/smb2pdu.h, do not moveSET_FILE_READ_RIGHTSandSET_FILE_WRITE_RIGHTS.
- Patch #09 ~ #12: move definitions tocommon/fscc.h
- Patch #10: include all changes that only rename structures in this patch.
- Patch #11 #12: some cleanups.v4: https://lore.kernel.org/all/[email protected]/
ChenXiaoSong (13):
smb/client: fixCAP_BULK_TRANSFERvalue
smb: moveMAX_CIFS_SMALL_BUFFER_SIZEtocommon/smbglob.h
smb: movecreate_durable_req_v2tocommon/smb2pdu.h
smb: movecreate_durable_handle_reconnect_v2tocommon/smb2pdu.h
smb: movecreate_durable_rsp_v2tocommon/smb2pdu.hsmb/server: removecreate_durable_reconn_req
smb: moveSMB_NEGOTIATE_REQtocommon/smb2pdu.h
smb: move list of FileSystemAttributes tocommon/fscc.h
smb: move some duplicate struct definitions tocommon/fscc.h
smb: moveFILE_SYSTEM_SIZE_INFOtocommon/fscc.h
smb: moveFILE_SYSTEM_ATTRIBUTE_INFOtocommon/fscc.h
smb: do some cleanups
smb: fix some warnings reported byscripts/checkpatch.plZhangGuoDong (1):
smb: move some duplicate definitions tocommon/smb2pdu.hfs/smb/client/cifsglob.h | 1 + fs/smb/client/cifspdu.h | 593 +++++++++++-------------------------- fs/smb/client/cifssmb.c | 12 +- fs/smb/client/connect.c | 4 +- fs/smb/client/inode.c | 4 +- fs/smb/client/ntlmssp.h | 8 +- fs/smb/client/readdir.c | 12 +- fs/smb/client/reparse.h | 8 +- fs/smb/client/rfc1002pdu.h | 8 +- fs/smb/client/smb1ops.c | 2 +- fs/smb/client/smb2inode.c | 2 +- fs/smb/client/smb2pdu.c | 16 +- fs/smb/client/smb2pdu.h | 69 ----- fs/smb/common/fscc.h | 179 +++++++++++ fs/smb/common/smb2pdu.h | 221 +++++++++++++- fs/smb/common/smbacl.h | 8 +- fs/smb/common/smbglob.h | 4 + fs/smb/server/oplock.c | 8 +- fs/smb/server/smb2ops.c | 6 +- fs/smb/server/smb2pdu.c | 116 ++++---- fs/smb/server/smb2pdu.h | 68 ----- fs/smb/server/smb_common.h | 237 +-------------- fs/smb/server/vfs.c | 2 +- 23 files changed, 682 insertions(+), 906 deletions(-)create mode 100644
fs/smb/common/fscc.h