smb: move duplicate definitions to common header file
Subsystems (2)
v4 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:
- smb/server: fix possible memory leak in smb2_read(): https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6fced056d2cc8d01b326e6fcfabaacb9850b71a4
- smb/server: fix possible refcount leak in smb2_sess_setup(): https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=379510a815cb2e64eb0a379cb62295d6ade65df0
- smb: move some duplicate definitions to common/cifsglob.h: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d877470b59910b5c50383d634dda3782386bba51
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.
v3->v4:
- The following modifications were made according to Namjae's suggestions.
- Create patch #01, rename it to "smbglob.h".
- Patch #02 #03 #04: move definitions to common/smbglob.h instead of common/cifsglob.h.
- Patch #05: do not move "BAD_PROT".
- Patch #05 ~ #15: move definitions to common/smb1pdu.h instead of common/cifspdu.h.
- Create #16 ~ #19: move some durable handle structures to common/smb2pdu.h.
- Fix warnings from script checkpatch.pl: WARNING: Prefer __packed over __attribute__((packed)).
- Update some commit message descriptions.
v3: https://lore.kernel.org/all/[email protected]/
ChenXiaoSong (16):
smb: move some duplicate definitions to common/smb1pdu.h
smb: move file access permission bits definitions to common/smb1pdu.h
smb: move SMB frame definitions to common/smb1pdu.h
smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/smb1pdu.h
smb: move FILE_SYSTEM_DEVICE_INFO to common/smb1pdu.h
smb: move FILE_SYSTEM_INFO to common/smb1pdu.h
smb: move FILE_DIRECTORY_INFO to common/smb1pdu.h
smb: move FILE_FULL_DIRECTORY_INFO to common/smb1pdu.h
smb: move FILE_BOTH_DIRECTORY_INFO to common/smb1pdu.h
smb: move SEARCH_ID_FULL_DIR_INFO to common/smb1pdu.h
smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.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 smb2_file_network_open_info to common/smb2pdu.h
ZhangGuoDong (8):
smb: rename common/cifsglob.h to common/smbglob.h
smb: move smb_version_values to common/smbglob.h
smb: move get_rfc1002_len() to common/smbglob.h
smb: move SMB1_PROTO_NUMBER to common/smbglob.h
smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
smb: move copychunk definitions to common/smb2pdu.h
smb: move resume_key_ioctl_rsp to common/smb2pdu.h
smb: move some duplicate definitions to common/smb2pdu.h
fs/smb/client/cifsacl.c | 4 +- fs/smb/client/cifsglob.h | 30 +-- fs/smb/client/cifspdu.h | 435 +------------------------------- fs/smb/client/cifssmb.c | 10 +- fs/smb/client/cifstransport.c | 8 +- fs/smb/client/connect.c | 2 +- fs/smb/client/misc.c | 2 +- fs/smb/client/smb2ops.c | 18 +- fs/smb/client/smb2pdu.c | 14 +- fs/smb/client/smb2pdu.h | 112 --------- fs/smb/common/cifsglob.h | 30 --- fs/smb/common/smb1pdu.h | 462 ++++++++++++++++++++++++++++++++++ fs/smb/common/smb2pdu.h | 144 ++++++++++- fs/smb/common/smbglob.h | 68 +++++ fs/smb/server/oplock.c | 8 +- fs/smb/server/smb2misc.c | 2 +- fs/smb/server/smb2ops.c | 38 +-- fs/smb/server/smb2pdu.c | 136 +++++----- fs/smb/server/smb2pdu.h | 107 -------- fs/smb/server/smb_common.c | 10 +- fs/smb/server/smb_common.h | 291 +-------------------- fs/smb/server/smbacl.c | 2 +- fs/smb/server/vfs.c | 2 +- 23 files changed, 800 insertions(+), 1135 deletions(-) delete mode 100644 fs/smb/common/cifsglob.h create mode 100644 fs/smb/common/smb1pdu.h create mode 100644 fs/smb/common/smbglob.h
Signature · 1 line
2.43.0
PATCH v4 1/24 smb: rename common/cifsglob.h to common/smbglob.h
From: ZhangGuoDong <[email protected]>
"cifs" is a legacy name, rename it to "smbglob.h" according to Namjae's suggestions.
---
fs/smb/client/cifsglob.h | 2 +-
fs/smb/common/{cifsglob.h => smbglob.h} | 6 +++---
fs/smb/server/smb_common.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
rename fs/smb/common/{cifsglob.h => smbglob.h} (89%)fs/smb/client/cifsglob.h +1 -1
@@ -24,7 +24,7 @@#include "cifsacl.h" #include <crypto/internal/hash.h> #include <uapi/linux/cifs/cifs_mount.h> -#include "../common/cifsglob.h" +#include "../common/smbglob.h" #include "../common/smb2pdu.h" #include "smb2pdu.h" #include <linux/filelock.h>
fs/smb/common/smbglob.h renamed from fs/smb/common/cifsglob.h +3 -3
@@ -6,8 +6,8 @@* Jeremy Allison ([email protected]) * */ -#ifndef _COMMON_CIFS_GLOB_H -#define _COMMON_CIFS_GLOB_H +#ifndef _COMMON_SMB_GLOB_H +#define _COMMON_SMB_GLOB_Hstatic inline void inc_rfc1001_len (void *buf,int count) {
@@ -27,4 +27,4 @@ static inline void inc_rfc1001_len(void *buf, int count)#define CIFS_DEFAULT_IOSIZE (1024 * 1024) -#endif /* _COMMON_CIFS_GLOB_H */ +#endif /* _COMMON_SMB_GLOB_H */
fs/smb/server/smb_common.h +1 -1
@@ -10,7 +10,7 @@#include "glob.h" #include "nterr.h" -#include "../common/cifsglob.h" +#include "../common/smbglob.h" #include "../common/smb2pdu.h" #include "smb2pdu.h"
Signature · 1 line
2.43.0
PATCH v4 2/24 smb: move smb_version_values to common/smbglob.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Merge the struct members of the server and the client:
- req_capabilities: from client
- header_preamble_size: from client
- cap_unicode: from client
- capabilities: from server, rename to req_capabilities
- max_read_size: from server
- max_write_size: from server
- max_trans_size: from server
- max_credits: from server
- create_durable_size: from server
- create_durable_v2_size: from server
- create_mxac_size: from server
- create_disk_id_size: from server
- create_posix_size: from server
Then move duplicate definitions to common header file.
--- fs/smb/client/cifsglob.h | 22 ---------------------- fs/smb/common/smbglob.h | 31 +++++++++++++++++++++++++++++++ fs/smb/server/smb2misc.c | 2 +- fs/smb/server/smb2ops.c | 32 ++++++++++++++++---------------- fs/smb/server/smb2pdu.c | 10 +++++----- fs/smb/server/smb_common.h | 29 ----------------------------- 6 files changed, 53 insertions(+), 73 deletions(-)
fs/smb/client/cifsglob.h +0 -22
@@ -633,28 +633,6 @@ struct smb_version_operations { struct kvec *xattr_iov); }; -struct smb_version_values { -char *version_string; -__u16 protocol_id; -__u32 req_capabilities; -__u32 large_lock_type; -__u32 exclusive_lock_type; -__u32 shared_lock_type; -__u32 unlock_lock_type; -size_t header_preamble_size; -size_t header_size; -size_t max_header_size; -size_t read_rsp_size; -__le16 lock_cmd; -unsigned int cap_unix; -unsigned int cap_nt_find; -unsigned int cap_large_files; -unsigned int cap_unicode; -__u16 signing_enabled; -__u16 signing_required; -size_t create_lease_size; -}; -#define HEADER_SIZE (server) (server->vals->header_size)#define MAX_HEADER_SIZE (server) (server->vals->max_header_size)#define HEADER_PREAMBLE_SIZE (server) (server->vals->header_preamble_size)
fs/smb/common/smbglob.h +31 -0
@@ -9,6 +9,37 @@#ifndef _COMMON_SMB_GLOB_H#define _COMMON_SMB_GLOB_H +struct smb_version_values { +char *version_string; +__u16 protocol_id; +__le16 lock_cmd; +__u32 req_capabilities; +__u32 max_read_size; +__u32 max_write_size; +__u32 max_trans_size; +__u32 max_credits; +__u32 large_lock_type; +__u32 exclusive_lock_type; +__u32 shared_lock_type; +__u32 unlock_lock_type; +size_t header_preamble_size; +size_t header_size; +size_t max_header_size; +size_t read_rsp_size; +unsigned int cap_unix; +unsigned int cap_nt_find; +unsigned int cap_large_files; +unsigned int cap_unicode; +__u16 signing_enabled; +__u16 signing_required; +size_t create_lease_size; +size_t create_durable_size; +size_t create_durable_v2_size; +size_t create_mxac_size; +size_t create_disk_id_size; +size_t create_posix_size; +}; +static inline void inc_rfc1001_len (void *buf,int count) {be32_add_cpu ((__be32 *)buf, count);
fs/smb/server/smb2misc.c +1 -1
@@ -460,7 +460,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work) } validate_credit: -if ((work->conn->vals->capabilities &SMB2_GLOBAL_CAP_LARGE_MTU ) && +if ((work->conn->vals->req_capabilities &SMB2_GLOBAL_CAP_LARGE_MTU ) &&smb2_validate_credit_charge (work->conn, hdr))return 1 ;
fs/smb/server/smb2ops.c +16 -16
@@ -15,7 +15,7 @@static struct smb_version_values smb21_server_values = { .version_string =SMB21_VERSION_STRING , .protocol_id =SMB21_PROT_ID , - .capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , + .req_capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , .max_read_size =SMB21_DEFAULT_IOSIZE , .max_write_size =SMB21_DEFAULT_IOSIZE , .max_trans_size =SMB21_DEFAULT_IOSIZE ,
@@ -41,7 +41,7 @@ static struct smb_version_values smb21_server_values = {static struct smb_version_values smb30_server_values = { .version_string =SMB30_VERSION_STRING , .protocol_id =SMB30_PROT_ID , - .capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , + .req_capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , .max_read_size =SMB3_DEFAULT_IOSIZE , .max_write_size =SMB3_DEFAULT_IOSIZE , .max_trans_size =SMB3_DEFAULT_TRANS_SIZE ,
@@ -68,7 +68,7 @@ static struct smb_version_values smb30_server_values = {static struct smb_version_values smb302_server_values = { .version_string =SMB302_VERSION_STRING , .protocol_id =SMB302_PROT_ID , - .capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , + .req_capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , .max_read_size =SMB3_DEFAULT_IOSIZE , .max_write_size =SMB3_DEFAULT_IOSIZE , .max_trans_size =SMB3_DEFAULT_TRANS_SIZE ,
@@ -95,7 +95,7 @@ static struct smb_version_values smb302_server_values = {static struct smb_version_values smb311_server_values = { .version_string =SMB311_VERSION_STRING , .protocol_id =SMB311_PROT_ID , - .capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , + .req_capabilities =SMB2_GLOBAL_CAP_LARGE_MTU , .max_read_size =SMB3_DEFAULT_IOSIZE , .max_write_size =SMB3_DEFAULT_IOSIZE , .max_trans_size =SMB3_DEFAULT_TRANS_SIZE ,
@@ -204,7 +204,7 @@ void init_smb2_1_server(struct ksmbd_conn *conn) conn->signing_algorithm =SIGNING_ALG_HMAC_SHA256_LE ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_LEASES ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_LEASING ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_LEASING ; }/**
@@ -221,20 +221,20 @@ void init_smb3_0_server(struct ksmbd_conn *conn) conn->signing_algorithm =SIGNING_ALG_AES_CMAC_LE ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_LEASES ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_LEASING | + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_LEASING |SMB2_GLOBAL_CAP_DIRECTORY_LEASING ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION && conn->cli_cap &SMB2_GLOBAL_CAP_ENCRYPTION ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_ENCRYPTION ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_ENCRYPTION ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION || (!(server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF ) && conn->cli_cap &SMB2_GLOBAL_CAP_ENCRYPTION )) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_ENCRYPTION ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_ENCRYPTION ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_MULTI_CHANNEL ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_MULTI_CHANNEL ; }/**
@@ -251,19 +251,19 @@ void init_smb3_02_server(struct ksmbd_conn *conn) conn->signing_algorithm =SIGNING_ALG_AES_CMAC_LE ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_LEASES ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_LEASING | + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_LEASING |SMB2_GLOBAL_CAP_DIRECTORY_LEASING ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION || (!(server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF ) && conn->cli_cap &SMB2_GLOBAL_CAP_ENCRYPTION )) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_ENCRYPTION ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_ENCRYPTION ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_MULTI_CHANNEL ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_MULTI_CHANNEL ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_DURABLE_HANDLE ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_PERSISTENT_HANDLES ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_PERSISTENT_HANDLES ; }/**
@@ -280,14 +280,14 @@ int init_smb3_11_server(struct ksmbd_conn *conn) conn->signing_algorithm =SIGNING_ALG_AES_CMAC_LE ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB2_LEASES ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_LEASING | + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_LEASING |SMB2_GLOBAL_CAP_DIRECTORY_LEASING ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_MULTI_CHANNEL ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_MULTI_CHANNEL ;if (server_conf.flags &KSMBD_GLOBAL_FLAG_DURABLE_HANDLE ) - conn->vals->capabilities |=SMB2_GLOBAL_CAP_PERSISTENT_HANDLES ; + conn->vals->req_capabilities |=SMB2_GLOBAL_CAP_PERSISTENT_HANDLES ;INIT_LIST_HEAD (&conn->preauth_sess_table);return 0 ;
fs/smb/server/smb2pdu.c +5 -5
@@ -282,7 +282,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)/* Not setting conn guid rsp->ServerGUID, as it * not used by client for identifying connection */ - rsp->Capabilities =cpu_to_le32 (conn->vals->capabilities); + rsp->Capabilities =cpu_to_le32 (conn->vals->req_capabilities);/* Default Max Message Size till SMB2.0, 64K*/ rsp->MaxTransactSize =cpu_to_le32 (conn->vals->max_trans_size); rsp->MaxReadSize =cpu_to_le32 (conn->vals->max_read_size);
@@ -956,7 +956,7 @@ bool smb3_encryption_negotiated(struct ksmbd_conn *conn)* SMB 3.0 and 3.0.2 dialects use the SMB2_GLOBAL_CAP_ENCRYPTION flag. * SMB 3.1.1 uses the cipher_type field. */ -return (conn->vals->capabilities &SMB2_GLOBAL_CAP_ENCRYPTION ) || +return (conn->vals->req_capabilities &SMB2_GLOBAL_CAP_ENCRYPTION ) || conn->cipher_type; }
@@ -1210,7 +1210,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work) rc = -EINVAL ; goto err_out; } - rsp->Capabilities =cpu_to_le32 (conn->vals->capabilities); + rsp->Capabilities =cpu_to_le32 (conn->vals->req_capabilities);/* For stats */ conn->connection_type = conn->dialect;
@@ -3474,7 +3474,7 @@ int smb2_open(struct ksmbd_work *work) share_ret =ksmbd_smb_check_shared_mode (fp->filp, fp);if (!test_share_config_flag (work->tcon->share_conf,KSMBD_SHARE_FLAG_OPLOCKS ) || (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE && - !(conn->vals->capabilities &SMB2_GLOBAL_CAP_LEASING ))) { + !(conn->vals->req_capabilities &SMB2_GLOBAL_CAP_LEASING ))) {if (share_ret <0 && !S_ISDIR (file_inode (fp->filp)->i_mode)) { rc = share_ret; goto err_out1;
@@ -7984,7 +7984,7 @@ static int fsctl_validate_negotiate_info(struct ksmbd_conn *conn, goto err_out; } - neg_rsp->Capabilities =cpu_to_le32 (conn->vals->capabilities); + neg_rsp->Capabilities =cpu_to_le32 (conn->vals->req_capabilities);memset (neg_rsp->Guid,0 ,SMB2_CLIENT_GUID_SIZE ); neg_rsp->SecurityMode =cpu_to_le16 (conn->srv_sec_mode); neg_rsp->Dialect =cpu_to_le16 (conn->dialect);
fs/smb/server/smb_common.h +0 -29
@@ -338,35 +338,6 @@ struct file_id_full_dir_info {char FileName[]; } __packed;/* level 0x105 FF rsp data */ -struct smb_version_values { -char *version_string; -__u16 protocol_id; -__le16 lock_cmd; -__u32 capabilities; -__u32 max_read_size; -__u32 max_write_size; -__u32 max_trans_size; -__u32 max_credits; -__u32 large_lock_type; -__u32 exclusive_lock_type; -__u32 shared_lock_type; -__u32 unlock_lock_type; -size_t header_size; -size_t max_header_size; -size_t read_rsp_size; -unsigned int cap_unix; -unsigned int cap_nt_find; -unsigned int cap_large_files; -__u16 signing_enabled; -__u16 signing_required; -size_t create_lease_size; -size_t create_durable_size; -size_t create_durable_v2_size; -size_t create_mxac_size; -size_t create_disk_id_size; -size_t create_posix_size; -}; -struct filesystem_posix_info {/* For undefined recommended transfer size return -1 in that field */ __le32 OptimalTransferSize;/* bsize on some os, iosize on other os */
Signature · 1 line
2.43.0
PATCH v4 3/24 smb: move get_rfc1002_len() to common/smbglob.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Rename get_rfc1002_length() to get_rfc1002_len(), then move duplicate definitions to common header file.
--- fs/smb/client/cifsglob.h | 6 ------ fs/smb/client/cifssmb.c | 6 +++--- fs/smb/client/cifstransport.c | 8 ++++---- fs/smb/client/connect.c | 2 +- fs/smb/common/smbglob.h | 5 +++++ fs/smb/server/smb_common.h | 5 ----- 6 files changed, 13 insertions(+), 19 deletions(-)
fs/smb/client/cifsglob.h +0 -6
@@ -670,12 +670,6 @@ struct cifs_mnt_data {int flags; }; -static inline unsigned int -get_rfc1002_length (void *buf) -{ -return be32_to_cpu (*((__be32 *)buf)) &0xffffff ; -} -struct TCP_Server_Info {struct list_head tcp_ses_list;struct list_head smb_ses_list;
fs/smb/client/cifssmb.c +3 -3
@@ -614,7 +614,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server) iov[0 ].iov_len =4 ; iov[0 ].iov_base = smb; - iov[1 ].iov_len =get_rfc1002_length (smb); + iov[1 ].iov_len =get_rfc1002_len (smb); iov[1 ].iov_base = (char *)smb +4 ; rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
@@ -1443,7 +1443,7 @@ cifs_async_readv(struct cifs_io_subrequest *rdata) rdata->iov[0 ].iov_base = smb; rdata->iov[0 ].iov_len =4 ; rdata->iov[1 ].iov_base = (char *)smb +4 ; - rdata->iov[1 ].iov_len =get_rfc1002_length (smb); + rdata->iov[1 ].iov_len =get_rfc1002_len (smb); rc =cifs_call_async (tcon->ses->server, &rqst, cifs_readv_receive, cifs_readv_callback,NULL , rdata,0 ,NULL );
@@ -1808,7 +1808,7 @@ cifs_async_writev(struct cifs_io_subrequest *wdata)/* 4 for RFC1001 length + 1 for BCC */ iov[0 ].iov_len =4 ; iov[0 ].iov_base = smb; - iov[1 ].iov_len =get_rfc1002_length (smb) +1 ; + iov[1 ].iov_len =get_rfc1002_len (smb) +1 ; iov[1 ].iov_base = (char *)smb +4 ; rqst.rq_iov = iov;
fs/smb/client/cifstransport.c +4 -4
@@ -165,7 +165,7 @@ SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,int resp_buf_type; iov[0 ].iov_base = in_buf; - iov[0 ].iov_len =get_rfc1002_length (in_buf) +4 ; + iov[0 ].iov_len =get_rfc1002_len (in_buf) +4 ; flags |=CIFS_NO_RSP_BUF ; rc =SendReceive2 (xid, ses, iov,1 , &resp_buf_type, flags, &rsp_iov);cifs_dbg (NOISY ,"SendRcvNoRsp flags %d rc %d\n" , flags, rc);
@@ -177,7 +177,7 @@ int cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, bool log_error) { - unsigned int len = get_rfc1002_length(mid->resp_buf) + 4; + unsigned int len = get_rfc1002_len(mid->resp_buf) + 4;dump_smb (mid->resp_buf,min_t (u32,92 , len));
@@ -370,7 +370,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, goto out; } - *pbytes_returned =get_rfc1002_length (midQ->resp_buf); + *pbytes_returned =get_rfc1002_len (midQ->resp_buf);memcpy (out_buf, midQ->resp_buf, *pbytes_returned +4 ); rc =cifs_check_receive (midQ, server,0 ); out:
@@ -554,7 +554,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, goto out; } - *pbytes_returned =get_rfc1002_length (midQ->resp_buf); + *pbytes_returned =get_rfc1002_len (midQ->resp_buf);memcpy (out_buf, midQ->resp_buf, *pbytes_returned +4 ); rc =cifs_check_receive (midQ, server,0 ); out:
fs/smb/client/connect.c +1 -1
@@ -1299,7 +1299,7 @@ cifs_demultiplex_thread(void *p)* The right amount was read from socket - 4 bytes, * so we can now interpret the length field. */ - pdu_length =get_rfc1002_length (buf); + pdu_length =get_rfc1002_len (buf);cifs_dbg (FYI ,"RFC1002 header 0x%x\n" , pdu_length);if (!is_smb_response (server, buf[0 ]))
fs/smb/common/smbglob.h +5 -0
@@ -40,6 +40,11 @@ struct smb_version_values {size_t create_posix_size; }; +static inline unsigned int get_rfc1002_len (void *buf) +{ +return be32_to_cpu (*((__be32 *)buf)) &0xffffff ; +} +static inline void inc_rfc1001_len (void *buf,int count) {be32_add_cpu ((__be32 *)buf, count);
fs/smb/server/smb_common.h +0 -5
@@ -423,9 +423,4 @@ unsigned int ksmbd_server_side_copy_max_chunk_size(void);unsigned int ksmbd_server_side_copy_max_total_size (void );bool is_asterisk (char *p);__le32 smb_map_generic_desired_access (__le32 daccess); - -static inline unsigned int get_rfc1002_len (void *buf) -{ -return be32_to_cpu (*((__be32 *)buf)) &0xffffff ; -}#endif /* __SMB_COMMON_H__ */
Signature · 1 line
2.43.0
PATCH v4 4/24 smb: move SMB1_PROTO_NUMBER to common/smbglob.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Replace the constant of client with SMB1_PROTO_NUMBER, then move the macro definition from server/smb_common.h to common/smbglob.h.
--- fs/smb/client/misc.c | 2 +- fs/smb/common/smbglob.h | 2 ++ fs/smb/server/smb_common.h | 1 - 3 files changed, 3 insertions(+), 2 deletions(-)
fs/smb/client/misc.c +1 -1
@@ -318,7 +318,7 @@ static int check_smb_hdr(struct smb_hdr *smb) {/* does it have the right SMB "signature" ? */ -if (*(__le32 *) smb->Protocol !=cpu_to_le32 (0x424d53ff )) { +if (*(__le32 *) smb->Protocol !=SMB1_PROTO_NUMBER ) {cifs_dbg (VFS ,"Bad protocol string signature header 0x%x\n" , *(unsigned int *)smb->Protocol);return 1 ;
fs/smb/common/smbglob.h +2 -0
@@ -9,6 +9,8 @@ #ifndef _COMMON_SMB_GLOB_H #define _COMMON_SMB_GLOB_H +#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff) + struct smb_version_values { char *version_string; __u16 protocol_id;
fs/smb/server/smb_common.h +0 -1
@@ -151,7 +151,6 @@ FILE_EXECUTE | FILE_DELETE_CHILD | \ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) -#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff)#define SMB_COM_NEGOTIATE 0x72#define SMB1_CLIENT_GUID_SIZE (16)
Signature · 1 line
2.43.0
PATCH v4 5/24 smb: move some duplicate definitions to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to new common header file.
--- fs/smb/client/cifspdu.h | 152 +--------------------------------- fs/smb/common/smb1pdu.h | 163 +++++++++++++++++++++++++++++++++++++ fs/smb/server/smb_common.h | 79 +----------------- 3 files changed, 165 insertions(+), 229 deletions(-) create mode 100644 fs/smb/common/smb1pdu.h
fs/smb/client/cifspdu.h +1 -151
@@ -12,44 +12,12 @@#include <net/sock.h> #include <linux/unaligned.h> #include "../common/smbfsctl.h" +#include "../common/smb1pdu.h" #define CIFS_PROT 0#define POSIX_PROT (CIFS_PROT+1)#define BAD_PROT 0xFFFF -/* SMB command codes: -* 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 -*/ -#define SMB_COM_CREATE_DIRECTORY 0x00/* trivial response */ -#define SMB_COM_DELETE_DIRECTORY 0x01/* trivial response */ -#define SMB_COM_CLOSE 0x04/* triv req/rsp, timestamp ignored */ -#define SMB_COM_FLUSH 0x05/* triv req/rsp */ -#define SMB_COM_DELETE 0x06/* trivial response */ -#define SMB_COM_RENAME 0x07/* trivial response */ -#define SMB_COM_QUERY_INFORMATION 0x08/* aka getattr */ -#define SMB_COM_SETATTR 0x09/* trivial response */ -#define SMB_COM_LOCKING_ANDX 0x24/* trivial response */ -#define SMB_COM_COPY 0x29/* trivial rsp, fail filename ignrd*/ -#define SMB_COM_ECHO 0x2B/* echo request */ -#define SMB_COM_OPEN_ANDX 0x2D/* Legacy open for old servers */ -#define SMB_COM_READ_ANDX 0x2E -#define SMB_COM_WRITE_ANDX 0x2F -#define SMB_COM_TRANSACTION2 0x32 -#define SMB_COM_TRANSACTION2_SECONDARY 0x33 -#define SMB_COM_FIND_CLOSE2 0x34/* trivial response */ -#define SMB_COM_TREE_DISCONNECT 0x71/* trivial response */ -#define SMB_COM_NEGOTIATE 0x72 -#define SMB_COM_SESSION_SETUP_ANDX 0x73 -#define SMB_COM_LOGOFF_ANDX 0x74/* trivial response */ -#define SMB_COM_TREE_CONNECT_ANDX 0x75 -#define SMB_COM_NT_TRANSACT 0xA0 -#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 -#define SMB_COM_NT_CREATE_ANDX 0xA2 -#define SMB_COM_NT_CANCEL 0xA4/* no response */ -#define SMB_COM_NT_RENAME 0xA5/* trivial response */ -/* Transact2 subcommand codes */ #define TRANS2_OPEN 0x00#define TRANS2_FIND_FIRST 0x01
@@ -86,7 +54,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 */
@@ -150,36 +117,6 @@#define SMBOPEN_OTRUNC 0x0002#define SMBOPEN_OAPPEND 0x0001 -/* -* SMB flag definitions -*/ -#define SMBFLG_EXTD_LOCK 0x01/* server supports lock-read write-unlock smb */ -#define SMBFLG_RCV_POSTED 0x02/* obsolete */ -#define SMBFLG_RSVD 0x04 -#define SMBFLG_CASELESS 0x08/* all pathnames treated as caseless (off -implies case sensitive file handling request) */ -#define SMBFLG_CANONICAL_PATH_FORMAT 0x10/* obsolete */ -#define SMBFLG_OLD_OPLOCK 0x20/* obsolete */ -#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40/* obsolete */ -#define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ - -/* -* SMB flag2 definitions -*/ -#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)/* can send long (non-8.3) -path names in response */ -#define SMBFLG2_KNOWS_EAS cpu_to_le16(2) -#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4) -#define SMBFLG2_COMPRESSED (8) -#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10) -#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) -#define SMBFLG2_REPARSE_PATH (0x400) -#define SMBFLG2_EXT_SEC cpu_to_le16(0x800) -#define SMBFLG2_DFS cpu_to_le16(0x1000) -#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000) -#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
@@ -292,7 +229,6 @@#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ | READ_CONTROL | SYNCHRONIZE) -/* * Invalid readdir handle */
@@ -322,33 +258,6 @@#define CIFS_ALIAS_TYPE_FILE 0x0001#define CIFS_SHARE_TYPE_FILE 0x0000 -/* -* 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 -/* ShareAccess flags */ #define FILE_NO_SHARE 0x00000000#define FILE_SHARE_READ 0x00000001
@@ -417,38 +326,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)
@@ -2239,33 +2116,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/smb1pdu.h new file +163 -0
163 lines not on this page · raw message
fs/smb/server/smb_common.h +1 -78
105 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 6/24 smb: move file access permission bits definitions to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
There are only 2 different definitions between the client and server:
- SET_FILE_READ_RIGHTS:
- client: rename to CLIENT_SET_FILE_READ_RIGHTS
- server: rename to SERVER_SET_FILE_READ_RIGHTS
- SET_FILE_WRITE_RIGHTS
- client: rename to CLIENT_SET_FILE_WRITE_RIGHTS
- server: rename to SERVER_SET_FILE_WRITE_RIGHTS
Perhaps in the future we can change them to be the same, move them to common header file.
--- fs/smb/client/cifsacl.c | 4 +- fs/smb/client/cifspdu.h | 112 --------------------------------- fs/smb/common/smb1pdu.h | 123 ++++++++++++++++++++++++++++++++++++- fs/smb/common/smb2pdu.h | 6 -- fs/smb/server/smb_common.h | 55 ----------------- fs/smb/server/smbacl.c | 2 +- 6 files changed, 125 insertions(+), 177 deletions(-)
fs/smb/client/cifsacl.c +2 -2
@@ -654,9 +654,9 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,is this but we have cleared all the bits sans RWX for either user or group or other as per bits_to_use */ if (mode &S_IRUGO ) - *pace_flags |=SET_FILE_READ_RIGHTS ; + *pace_flags |=CLIENT_SET_FILE_READ_RIGHTS ;if (mode &S_IWUGO ) - *pace_flags |=SET_FILE_WRITE_RIGHTS ; + *pace_flags |=CLIENT_SET_FILE_WRITE_RIGHTS ;if (mode &S_IXUGO ) *pace_flags |=SET_FILE_EXEC_RIGHTS ;
fs/smb/client/cifspdu.h +0 -112
118 lines not on this page · raw message
fs/smb/common/smb1pdu.h +122 -1
129 lines not on this page · raw message
fs/smb/common/smb2pdu.h +0 -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) */
fs/smb/server/smb_common.h +0 -55
61 lines not on this page · raw message
fs/smb/server/smbacl.c +1 -1
@@ -180,7 +180,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,* either user or group or other as per bits_to_use */ if (mode &0444 ) - *pace_flags |=SET_FILE_READ_RIGHTS ; + *pace_flags |=SERVER_SET_FILE_READ_RIGHTS ;if (mode &0222 ) *pace_flags |=FILE_WRITE_RIGHTS ;if (mode &0111 )
Signature · 1 line
2.43.0
PATCH v4 7/24 smb: move SMB frame definitions to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
The client and server have different struct negotiate_rsp, perhaps in the future we can change them to be the same.
--- fs/smb/client/cifspdu.h | 58 ---------------------------------- fs/smb/client/cifssmb.c | 4 +-- fs/smb/common/smb1pdu.h | 65 ++++++++++++++++++++++++++++++++++++++ fs/smb/server/smb_common.c | 10 +++--- fs/smb/server/smb_common.h | 14 -------- 5 files changed, 72 insertions(+), 79 deletions(-)
fs/smb/client/cifspdu.h +0 -58
@@ -267,64 +267,6 @@ put_bcc(__u16 count, struct smb_hdr *hdr)*/ #define MAX_PATHCONF 256 -/* -* SMB frame definitions (following must be packed structs) -* See the SNIA CIFS Specification for details. -* -* The Naming convention is the lower case version of the -* smb command code name for the struct and this is typedef to the -* uppercase version of the same name with the prefix SMB_ removed -* for brevity. Although typedefs are not commonly used for -* structure definitions in the Linux kernel, their use in the -* CIFS standards document, which this code is based on, may -* make this one of the cases where typedefs for structures make -* sense to improve readability for readers of the standards doc. -* Typedefs can always be removed later if they are too distracting -* and they are only used for the CIFSs PDUs themselves, not -* internal cifs vfs structures -* -*/ - -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 { -struct smb_hdr hdr;/* wct = 17 */ -__le16 DialectIndex;/* 0xFFFF = no dialect acceptable */ -__u8 SecurityMode; -__le16 MaxMpxCount; -__le16 MaxNumberVcs; -__le32 MaxBufferSize; -__le32 MaxRawSize; -__le32 SessionKey; -__le32 Capabilities;/* see below */ -__le32 SystemTimeLow; -__le32 SystemTimeHigh; -__le16 ServerTimeZone; -__u8 EncryptionKeyLength; -__u16 ByteCount; -union { -/* cap extended security off */ - DECLARE_FLEX_ARRAY(unsigned char, EncryptionKey); -/* followed by Domain name - if extended security is off */ -/* followed by 16 bytes of server GUID */ -/* then security blob if cap_extended_security negotiated */ -struct { -unsigned char GUID[SMB1_CLIENT_GUID_SIZE ]; -unsigned char SecurityBlob[]; - } __attribute__((packed)) extended_response; - } __attribute__((packed)) u; -} __attribute__((packed))NEGOTIATE_RSP ; -/* SecurityMode bits */ #define SECMODE_USER 0x01/* off indicates share level security */ #define SECMODE_PW_ENCRYPT 0x02
fs/smb/client/cifssmb.c +2 -2
@@ -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,CLIENT_NEGOTIATE_RSP *pSMBr) {int rc =0 ;u16 count;
@@ -420,7 +420,7 @@ CIFSSMBNegotiate(const unsigned int xid, struct TCP_Server_Info *server) {NEGOTIATE_REQ *pSMB; -NEGOTIATE_RSP *pSMBr; +CLIENT_NEGOTIATE_RSP *pSMBr;int rc =0 ;int bytes_returned;int i;
fs/smb/common/smb1pdu.h +65 -0
71 lines not on this page · raw message
fs/smb/server/smb_common.c +5 -5
@@ -280,13 +280,13 @@ static int ksmbd_negotiate_smb_dialect(void *buf) proto = *(__le32 *)((struct smb_hdr *)buf)->Protocol;if (proto ==SMB1_PROTO_NUMBER ) { -struct smb_negotiate_req *req; +struct negotiate_req *req; - req = (struct smb_negotiate_req *)buf; + req = (struct negotiate_req *)buf;if (le16_to_cpu (req->ByteCount) <2 ) goto err_out; -if (offsetof(struct smb_negotiate_req , DialectsArray) -4 + +if (offsetof(struct negotiate_req , DialectsArray) -4 +le16_to_cpu (req->ByteCount) > smb_buf_length) { goto err_out; }
@@ -572,12 +572,12 @@ static int __smb2_negotiate(struct ksmbd_conn *conn)static int smb_handle_negotiate (struct ksmbd_work *work) { -struct smb_negotiate_rsp *neg_rsp = work->response_buf; +struct server_negotiate_rsp *neg_rsp = work->response_buf;ksmbd_debug (SMB ,"Unsupported SMB1 protocol\n" );if (ksmbd_iov_pin_rsp (work, (void *)neg_rsp +4 , -sizeof (struct smb_negotiate_rsp ) -4 )) +sizeof (struct server_negotiate_rsp ) -4 ))return -ENOMEM ; neg_rsp->hdr.Status.CifsError =STATUS_SUCCESS ;
fs/smb/server/smb_common.h +0 -14
@@ -57,20 +57,6 @@ FILE_EXECUTE | FILE_DELETE_CHILD | \ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) -#define SMB1_CLIENT_GUID_SIZE (16) - -struct smb_negotiate_req { -struct smb_hdr hdr;/* wct = 0 */ -__le16 ByteCount; -unsigned char DialectsArray[]; -} __packed; - -struct smb_negotiate_rsp { -struct smb_hdr hdr;/* wct = 17 */ -__le16 DialectIndex;/* 0xFFFF = no dialect acceptable */ -__le16 ByteCount; -} __packed; - struct filesystem_attribute_info { __le32 Attributes; __le32 MaxPathNameComponentLength;
Signature · 1 line
2.43.0
PATCH v4 8/24 smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 7 ------- fs/smb/common/smb1pdu.h | 8 ++++++++ fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb_common.h | 7 ------- 4 files changed, 11 insertions(+), 17 deletions(-)
fs/smb/client/cifspdu.h +0 -7
@@ -1946,13 +1946,6 @@ typedef struct {/* 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/smb1pdu.h +8 -0
@@ -346,4 +346,12 @@ typedef struct server_negotiate_rsp {#define FILE_CASE_PRESERVED_NAMES 0x00000002#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 +/* See FS-FSCC 2.5.1 */ +typedef struct { +__le32 Attributes; +__le32 MaxPathNameComponentLength; +__le32 FileSystemNameLen; +__le16 FileSystemName[];/* do not have to save this - get subset? */ +} __packed FILE_SYSTEM_ATTRIBUTE_INFO; +#endif /* _COMMON_SMB1_PDU_H */
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 =sizeof (FILE_SYSTEM_ATTRIBUTE_INFO ) + len; rsp->OutputBufferLength =cpu_to_le32 (sz);break ; }
fs/smb/server/smb_common.h +0 -7
@@ -57,13 +57,6 @@ FILE_EXECUTE | FILE_DELETE_CHILD | \ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) -struct filesystem_attribute_info { -__le32 Attributes; -__le32 MaxPathNameComponentLength; -__le32 FileSystemNameLen; -__le16 FileSystemName[];/* do not have to save this - get subset? */ -} __packed; - struct filesystem_device_info { __le32 DeviceType; __le32 DeviceCharacteristics;
Signature · 1 line
2.43.0
PATCH v4 9/24 smb: move FILE_SYSTEM_DEVICE_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct filesystem_device_info" to "FILE_SYSTEM_DEVICE_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 5 ----- fs/smb/common/smb1pdu.h | 6 ++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 5 ----- 4 files changed, 8 insertions(+), 12 deletions(-)
fs/smb/client/cifspdu.h +0 -5
@@ -1938,11 +1938,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
fs/smb/common/smb1pdu.h +6 -0
@@ -319,6 +319,12 @@ typedef struct server_negotiate_rsp {__le16 ByteCount; }__packed SERVER_NEGOTIATE_RSP ; +/* See MS-CIFS 2.2.8.2.5 */ +typedef struct { +__le32 DeviceType; +__le32 DeviceCharacteristics; +} __packed FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */ +/* 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 */
fs/smb/server/smb2pdu.c +2 -2
@@ -5476,9 +5476,9 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,switch (fsinfoclass) {case FS_DEVICE_INFORMATION : { -struct filesystem_device_info *info; +FILE_SYSTEM_DEVICE_INFO *info; - info = (struct filesystem_device_info *)rsp->Buffer; + info = (FILE_SYSTEM_DEVICE_INFO *)rsp->Buffer; info->DeviceType =cpu_to_le32 (FILE_DEVICE_DISK ); info->DeviceCharacteristics =
fs/smb/server/smb_common.h +0 -5
@@ -57,11 +57,6 @@ FILE_EXECUTE | FILE_DELETE_CHILD | \ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) -struct filesystem_device_info { -__le32 DeviceType; -__le32 DeviceCharacteristics; -} __packed;/* device info level 0x104 */ - struct filesystem_vol_info { __le64 VolumeCreationTime; __le32 SerialNumber;
Signature · 1 line
2.43.0
PATCH v4 10/24 smb: move FILE_SYSTEM_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct filesystem_info" to "FILE_SYSTEM_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 7 ------- fs/smb/common/smb1pdu.h | 8 ++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 7 ------- 4 files changed, 10 insertions(+), 16 deletions(-)
fs/smb/client/cifspdu.h +0 -7
@@ -1828,13 +1828,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/common/smb1pdu.h +8 -0
@@ -319,6 +319,14 @@ typedef struct server_negotiate_rsp {__le16 ByteCount; }__packed SERVER_NEGOTIATE_RSP ; +/* See MS-CIFS 2.2.8.2.4 */ +typedef struct { +__le64 TotalAllocationUnits; +__le64 FreeAllocationUnits; +__le32 SectorsPerAllocationUnit; +__le32 BytesPerSector; +} __packed FILE_SYSTEM_INFO; /* size info, level 0x103 */ +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;
fs/smb/server/smb2pdu.c +2 -2
@@ -5546,9 +5546,9 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_SIZE_INFORMATION : { -struct filesystem_info *info; +FILE_SYSTEM_INFO *info; - info = (struct filesystem_info *)(rsp->Buffer); + info = (FILE_SYSTEM_INFO *)(rsp->Buffer); info->TotalAllocationUnits =cpu_to_le64 (stfs.f_blocks); info->FreeAllocationUnits =cpu_to_le64 (stfs.f_bfree); info->SectorsPerAllocationUnit =cpu_to_le32 (1 );
fs/smb/server/smb_common.h +0 -7
@@ -65,13 +65,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 v4 11/24 smb: move FILE_DIRECTORY_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct file_directory_info" to "FILE_DIRECTORY_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 14 -------------- fs/smb/common/smb1pdu.h | 15 +++++++++++++++ fs/smb/server/smb2pdu.c | 16 ++++++++-------- fs/smb/server/smb_common.h | 14 -------------- fs/smb/server/vfs.c | 2 +- 5 files changed, 24 insertions(+), 37 deletions(-)
fs/smb/client/cifspdu.h +0 -14
@@ -2159,20 +2159,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;
fs/smb/common/smb1pdu.h +15 -0
@@ -368,4 +368,19 @@ typedef struct {__le16 FileSystemName[];/* do not have to save this - get subset? */ } __packed FILE_SYSTEM_ATTRIBUTE_INFO; +/* See MS-CIFS 2.2.8.1.4 */ +typedef struct { +__le32 NextEntryOffset; +__u32 FileIndex; +__le64 CreationTime; +__le64 LastAccessTime; +__le64 LastWriteTime; +__le64 ChangeTime; +__le64 EndOfFile; +__le64 AllocationSize; +__le32 ExtFileAttributes; +__le32 FileNameLength; +char FileName[]; +} __packed FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */ +#endif /* _COMMON_SMB1_PDU_H */
fs/smb/server/smb2pdu.c +8 -8
@@ -3800,7 +3800,7 @@ static int readdir_info_level_struct_sz(int info_level)case FILE_BOTH_DIRECTORY_INFORMATION :return sizeof (struct file_both_directory_info );case FILE_DIRECTORY_INFORMATION : -return sizeof (struct file_directory_info ); +return sizeof (FILE_DIRECTORY_INFO );case FILE_NAMES_INFORMATION :return sizeof (struct file_names_info );case FILEID_FULL_DIRECTORY_INFORMATION :
@@ -3839,9 +3839,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level) }case FILE_DIRECTORY_INFORMATION : { -struct file_directory_info *fdinfo; +FILE_DIRECTORY_INFO *fdinfo; - fdinfo = (struct file_directory_info *)d_info->rptr; + fdinfo = (FILE_DIRECTORY_INFO *)d_info->rptr; d_info->rptr +=le32_to_cpu (fdinfo->NextEntryOffset); d_info->name = fdinfo->FileName; d_info->name_len =le32_to_cpu (fdinfo->FileNameLength);
@@ -3978,9 +3978,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, }case FILE_DIRECTORY_INFORMATION : { -struct file_directory_info *fdinfo; +FILE_DIRECTORY_INFO *fdinfo; - fdinfo = (struct file_directory_info *)kstat; + fdinfo = (FILE_DIRECTORY_INFO *)kstat; fdinfo->FileNameLength =cpu_to_le32 (conv_len);if (d_info->hide_dot_file && d_info->name[0 ] =='.' ) fdinfo->ExtFileAttributes |=FILE_ATTRIBUTE_HIDDEN_LE ;
@@ -4228,9 +4228,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, }case FILE_DIRECTORY_INFORMATION : { -struct file_directory_info *fdinfo; +FILE_DIRECTORY_INFO *fdinfo; - fdinfo = (struct file_directory_info *)d_info->wptr; + fdinfo = (FILE_DIRECTORY_INFO *)d_info->wptr;memcpy (fdinfo->FileName, d_info->name, d_info->name_len); fdinfo->FileName[d_info->name_len] =0x00 ; fdinfo->FileNameLength =cpu_to_le32 (d_info->name_len);
@@ -4514,7 +4514,7 @@ int smb2_query_dir(struct ksmbd_work *work) goto err_out; }else { no_buf_len: - ((struct file_directory_info *) + ((FILE_DIRECTORY_INFO *) ((char *)rsp->Buffer + d_info.last_entry_offset)) ->NextEntryOffset =0 ;if (d_info.data_count >= d_info.last_entry_off_align)
fs/smb/server/smb_common.h +0 -14
@@ -81,20 +81,6 @@ struct object_id_info {struct fs_extended_info extended_info; } __packed; -struct file_directory_info { -__le32 NextEntryOffset; -__u32 FileIndex; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 ExtFileAttributes; -__le32 FileNameLength; -char FileName[]; -} __packed;/* level 0x101 FF resp data */ -struct file_names_info {__le32 NextEntryOffset;__u32 FileIndex;
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 v4 12/24 smb: move FILE_FULL_DIRECTORY_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct file_full_directory_info" to "FILE_FULL_DIRECTORY_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 15 --------------- fs/smb/common/smb1pdu.h | 16 ++++++++++++++++ fs/smb/server/smb2pdu.c | 14 +++++++------- fs/smb/server/smb_common.h | 15 --------------- 4 files changed, 23 insertions(+), 37 deletions(-)
fs/smb/client/cifspdu.h +0 -15
@@ -2159,21 +2159,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; -__le32 EaSize;/* length of the xattrs */ -char FileName[]; -} __attribute__((packed))FILE_FULL_DIRECTORY_INFO ;/* level 0x102 rsp data */ - typedef struct { __le32 NextEntryOffset; __u32 FileIndex;
fs/smb/common/smb1pdu.h +16 -0
@@ -383,4 +383,20 @@ typedef struct {char FileName[]; } __packed FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */ +/* See MS-CIFS 2.2.8.1.5 */ +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[]; +} __packed FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */ +#endif /* _COMMON_SMB1_PDU_H */
fs/smb/server/smb2pdu.c +7 -7
@@ -3796,7 +3796,7 @@ static int readdir_info_level_struct_sz(int info_level) {switch (info_level) {case FILE_FULL_DIRECTORY_INFORMATION : -return sizeof (struct file_full_directory_info ); +return sizeof (FILE_FULL_DIRECTORY_INFO );case FILE_BOTH_DIRECTORY_INFORMATION :return sizeof (struct file_both_directory_info );case FILE_DIRECTORY_INFORMATION :
@@ -3819,9 +3819,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level)switch (info_level) {case FILE_FULL_DIRECTORY_INFORMATION : { -struct file_full_directory_info *ffdinfo; +FILE_FULL_DIRECTORY_INFO *ffdinfo; - ffdinfo = (struct file_full_directory_info *)d_info->rptr; + ffdinfo = (FILE_FULL_DIRECTORY_INFO *)d_info->rptr; d_info->rptr +=le32_to_cpu (ffdinfo->NextEntryOffset); d_info->name = ffdinfo->FileName; d_info->name_len =le32_to_cpu (ffdinfo->FileNameLength);
@@ -3944,9 +3944,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,switch (info_level) {case FILE_FULL_DIRECTORY_INFORMATION : { -struct file_full_directory_info *ffdinfo; +FILE_FULL_DIRECTORY_INFO *ffdinfo; - ffdinfo = (struct file_full_directory_info *)kstat; + ffdinfo = (FILE_FULL_DIRECTORY_INFO *)kstat; ffdinfo->FileNameLength =cpu_to_le32 (conv_len); ffdinfo->EaSize =smb2_get_reparse_tag_special_file (ksmbd_kstat->kstat->mode);
@@ -4206,9 +4206,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info,switch (info_level) {case FILE_FULL_DIRECTORY_INFORMATION : { -struct file_full_directory_info *ffdinfo; +FILE_FULL_DIRECTORY_INFO *ffdinfo; - ffdinfo = (struct file_full_directory_info *)d_info->wptr; + ffdinfo = (FILE_FULL_DIRECTORY_INFO *)d_info->wptr;memcpy (ffdinfo->FileName, d_info->name, d_info->name_len); ffdinfo->FileName[d_info->name_len] =0x00 ; ffdinfo->FileNameLength =cpu_to_le32 (d_info->name_len);
fs/smb/server/smb_common.h +0 -15
@@ -88,21 +88,6 @@ struct file_names_info {char FileName[]; } __packed;/* level 0xc FF resp data */ -struct file_full_directory_info { -__le32 NextEntryOffset; -__u32 FileIndex; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 ExtFileAttributes; -__le32 FileNameLength; -__le32 EaSize; -char FileName[]; -} __packed;/* level 0x102 FF resp */ -struct file_both_directory_info {__le32 NextEntryOffset;__u32 FileIndex;
Signature · 1 line
2.43.0
PATCH v4 13/24 smb: move FILE_BOTH_DIRECTORY_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct file_both_directory_info" to "FILE_BOTH_DIRECTORY_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 18 ------------------ fs/smb/common/smb1pdu.h | 19 +++++++++++++++++++ fs/smb/server/smb2pdu.c | 14 +++++++------- fs/smb/server/smb_common.h | 18 ------------------ 4 files changed, 26 insertions(+), 43 deletions(-)
fs/smb/client/cifspdu.h +0 -18
@@ -2176,24 +2176,6 @@ typedef struct {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/common/smb1pdu.h +19 -0
@@ -399,4 +399,23 @@ typedef struct {char FileName[]; } __packed FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */ +/* See MS-CIFS 2.2.8.1.7 */ +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[]; +} __packed FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */ +#endif /* _COMMON_SMB1_PDU_H */
fs/smb/server/smb2pdu.c +7 -7
@@ -3798,7 +3798,7 @@ static int readdir_info_level_struct_sz(int info_level)case FILE_FULL_DIRECTORY_INFORMATION :return sizeof (FILE_FULL_DIRECTORY_INFO );case FILE_BOTH_DIRECTORY_INFORMATION : -return sizeof (struct file_both_directory_info ); +return sizeof (FILE_BOTH_DIRECTORY_INFO );case FILE_DIRECTORY_INFORMATION :return sizeof (FILE_DIRECTORY_INFO );case FILE_NAMES_INFORMATION :
@@ -3829,9 +3829,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level) }case FILE_BOTH_DIRECTORY_INFORMATION : { -struct file_both_directory_info *fbdinfo; +FILE_BOTH_DIRECTORY_INFO *fbdinfo; - fbdinfo = (struct file_both_directory_info *)d_info->rptr; + fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)d_info->rptr; d_info->rptr +=le32_to_cpu (fbdinfo->NextEntryOffset); d_info->name = fbdinfo->FileName; d_info->name_len =le32_to_cpu (fbdinfo->FileNameLength);
@@ -3960,9 +3960,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, }case FILE_BOTH_DIRECTORY_INFORMATION : { -struct file_both_directory_info *fbdinfo; +FILE_BOTH_DIRECTORY_INFO *fbdinfo; - fbdinfo = (struct file_both_directory_info *)kstat; + fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)kstat; fbdinfo->FileNameLength =cpu_to_le32 (conv_len); fbdinfo->EaSize =smb2_get_reparse_tag_special_file (ksmbd_kstat->kstat->mode);
@@ -4217,9 +4217,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, }case FILE_BOTH_DIRECTORY_INFORMATION : { -struct file_both_directory_info *fbdinfo; +FILE_BOTH_DIRECTORY_INFO *fbdinfo; - fbdinfo = (struct file_both_directory_info *)d_info->wptr; + fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)d_info->wptr;memcpy (fbdinfo->FileName, d_info->name, d_info->name_len); fbdinfo->FileName[d_info->name_len] =0x00 ; fbdinfo->FileNameLength =cpu_to_le32 (d_info->name_len);
fs/smb/server/smb_common.h +0 -18
@@ -88,24 +88,6 @@ struct file_names_info {char FileName[]; } __packed;/* level 0xc FF resp data */ -struct file_both_directory_info { -__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[]; -} __packed;/* level 0x104 FFrsp data */ -struct file_id_both_directory_info {__le32 NextEntryOffset;__u32 FileIndex;
Signature · 1 line
2.43.0
PATCH v4 14/24 smb: move SEARCH_ID_FULL_DIR_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct file_id_full_dir_info" to "SEARCH_ID_FULL_DIR_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 17 ----------------- fs/smb/common/smb1pdu.h | 18 ++++++++++++++++++ fs/smb/server/smb2pdu.c | 14 +++++++------- fs/smb/server/smb_common.h | 17 ----------------- 4 files changed, 25 insertions(+), 41 deletions(-)
fs/smb/client/cifspdu.h +0 -17
@@ -2159,23 +2159,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; -__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 { __u32 ResumeKey; __le16 CreationDate; /* SMB Date */
fs/smb/common/smb1pdu.h +18 -0
@@ -399,6 +399,24 @@ typedef struct {char FileName[]; }__packed FILE_FULL_DIRECTORY_INFO ;/* level 0x102 rsp data */ +/* See MS-SMB 2.2.8.1.2 */ +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[]; +} __packed SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ +/* See MS-CIFS 2.2.8.1.7 */ typedef struct { __le32 NextEntryOffset;
fs/smb/server/smb2pdu.c +7 -7
@@ -3804,7 +3804,7 @@ static int readdir_info_level_struct_sz(int info_level)case FILE_NAMES_INFORMATION :return sizeof (struct file_names_info );case FILEID_FULL_DIRECTORY_INFORMATION : -return sizeof (struct file_id_full_dir_info ); +return sizeof (SEARCH_ID_FULL_DIR_INFO );case FILEID_BOTH_DIRECTORY_INFORMATION :return sizeof (struct file_id_both_directory_info );case SMB_FIND_FILE_POSIX_INFO :
@@ -3859,9 +3859,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level) }case FILEID_FULL_DIRECTORY_INFORMATION : { -struct file_id_full_dir_info *dinfo; +SEARCH_ID_FULL_DIR_INFO *dinfo; - dinfo = (struct file_id_full_dir_info *)d_info->rptr; + dinfo = (SEARCH_ID_FULL_DIR_INFO *)d_info->rptr; d_info->rptr +=le32_to_cpu (dinfo->NextEntryOffset); d_info->name = dinfo->FileName; d_info->name_len =le32_to_cpu (dinfo->FileNameLength);
@@ -4000,9 +4000,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, }case FILEID_FULL_DIRECTORY_INFORMATION : { -struct file_id_full_dir_info *dinfo; +SEARCH_ID_FULL_DIR_INFO *dinfo; - dinfo = (struct file_id_full_dir_info *)kstat; + dinfo = (SEARCH_ID_FULL_DIR_INFO *)kstat; dinfo->FileNameLength =cpu_to_le32 (conv_len); dinfo->EaSize =smb2_get_reparse_tag_special_file (ksmbd_kstat->kstat->mode);
@@ -4250,9 +4250,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, }case FILEID_FULL_DIRECTORY_INFORMATION : { -struct file_id_full_dir_info *dinfo; +SEARCH_ID_FULL_DIR_INFO *dinfo; - dinfo = (struct file_id_full_dir_info *)d_info->wptr; + dinfo = (SEARCH_ID_FULL_DIR_INFO *)d_info->wptr;memcpy (dinfo->FileName, d_info->name, d_info->name_len); dinfo->FileName[d_info->name_len] =0x00 ; dinfo->FileNameLength =cpu_to_le32 (d_info->name_len);
fs/smb/server/smb_common.h +0 -17
@@ -108,23 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct file_id_full_dir_info { -__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[]; -} __packed;/* level 0x105 FF rsp data */ -struct filesystem_posix_info {/* For undefined recommended transfer size return -1 in that field */ __le32 OptimalTransferSize;/* bsize on some os, iosize on other os */
Signature · 1 line
2.43.0
PATCH v4 15/24 smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename "struct filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO", then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 22 ---------------------- fs/smb/common/smb1pdu.h | 23 +++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 23 ----------------------- 4 files changed, 25 insertions(+), 47 deletions(-)
fs/smb/client/cifspdu.h +0 -22
@@ -1875,28 +1875,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
fs/smb/common/smb1pdu.h +23 -0
@@ -327,6 +327,29 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_INFO ;/* size info, level 0x103 */ +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 */ +} __packed FILE_SYSTEM_POSIX_INFO; +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;
fs/smb/server/smb2pdu.c +2 -2
@@ -5633,14 +5633,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_POSIX_INFORMATION : { -struct filesystem_posix_info *info; +FILE_SYSTEM_POSIX_INFO *info;if (!work->tcon->posix_extensions) {pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" );path_put (&path);return -EOPNOTSUPP ; }else { - info = (struct filesystem_posix_info *)(rsp->Buffer); + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); info->OptimalTransferSize =cpu_to_le32 (stfs.f_bsize); info->BlockSize =cpu_to_le32 (stfs.f_bsize); info->TotalBlocks =cpu_to_le64 (stfs.f_blocks);
fs/smb/server/smb_common.h +0 -23
@@ -108,29 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct filesystem_posix_info { -/* 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 */ -} __packed; -struct smb_version_ops {u16 (*get_cmd_val)(struct ksmbd_work *swork);int (*init_rsp_hdr)(struct ksmbd_work *swork);
Signature · 1 line
2.43.0
PATCH v4 16/24 smb: move create_durable_req_v2 to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Replace some fields in "struct create_durable_req_v2" with "struct durable_context_v2", rename 2 places:
- 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
@@ -1284,6 +1284,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 v4 17/24 smb: move create_durable_handle_reconnect_v2 to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Replace some fields in "struct create_durable_reconn_v2_req" with "struct durable_reconnect_context_v2", rename "create_durable_reconn_v2_req" to "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
@@ -1298,6 +1298,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 v4 18/24 smb: move create_durable_rsp_v2 to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Replace some fields in "struct create_durable_v2_rsp" with "struct durable_context_v2_rsp", rename 2 places:
- 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
@@ -1314,6 +1314,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 v4 19/24 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.
--- 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
PATCH v4 20/24 smb: move smb2_file_network_open_info to common/smb2pdu.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Rename smb2_file_ntwrk_info to smb2_file_network_open_info, then move duplicate definitions to common header file.
--- fs/smb/client/smb2pdu.h | 13 ------------- fs/smb/common/smb2pdu.h | 14 ++++++++++++++ fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb2pdu.h | 11 ----------- 4 files changed, 17 insertions(+), 27 deletions(-)
fs/smb/client/smb2pdu.h +0 -13
@@ -288,19 +288,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/smb2pdu.h +14 -0
@@ -1929,6 +1929,20 @@ struct smb2_lease_ack {__le64 LeaseDuration; } __packed; +/* See MS-FSCC 2.4.34 */ +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 */ +#define OP_BREAK_STRUCT_SIZE_20 24#define OP_BREAK_STRUCT_SIZE_21 36#endif /* _COMMON_SMB2PDU_H */
fs/smb/server/smb2pdu.c +3 -3
@@ -5133,7 +5133,7 @@ static int get_file_internal_info(struct smb2_query_info_rsp *rsp,static int get_file_network_open_info (struct smb2_query_info_rsp *rsp,struct ksmbd_file *fp,void *rsp_org) { -struct smb2_file_ntwrk_info *file_info; +struct smb2_file_network_open_info *file_info;struct kstat stat;u64 time;int ret;
@@ -5149,7 +5149,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,if (ret)return ret; - file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer; + file_info = (struct smb2_file_network_open_info *)rsp->Buffer; file_info->CreationTime =cpu_to_le64 (fp->create_time); time =ksmbd_UnixTimeToNT (stat.atime);
@@ -5168,7 +5168,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp, } file_info->Reserved =cpu_to_le32 (0 ); rsp->OutputBufferLength = -cpu_to_le32 (sizeof (struct smb2_file_ntwrk_info )); +cpu_to_le32 (sizeof (struct smb2_file_network_open_info ));return 0 ; }
fs/smb/server/smb2pdu.h +0 -11
@@ -263,17 +263,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;
Signature · 1 line
2.43.0
PATCH v4 21/24 smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Rename 4 places:
- iface_info_ipv4 -> smb_sockaddr_in
- iface_info_ipv6 -> smb_sockaddr_in6
- IPv4address -> IPv4Address
- IPv6address -> IPv6Address
Then move duplicate definitions to common header file.
--- fs/smb/client/smb2ops.c | 8 ++++---- fs/smb/client/smb2pdu.h | 13 ------------- fs/smb/common/smb2pdu.h | 15 +++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb2pdu.h | 13 ------------- 5 files changed, 21 insertions(+), 32 deletions(-)
fs/smb/client/smb2ops.c +4 -4
@@ -624,8 +624,8 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,struct network_interface_info_ioctl_rsp *p;struct sockaddr_in *addr4;struct sockaddr_in6 *addr6; -struct iface_info_ipv4 *p4; -struct iface_info_ipv6 *p6; +struct smb_sockaddr_in *p4; +struct smb_sockaddr_in6 *p6;struct cifs_server_iface *info =NULL , *iface =NULL , *niface =NULL ;struct cifs_server_iface tmp_iface;ssize_t bytes_left;
@@ -685,7 +685,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,*/ case INTERNETWORK : addr4 = (struct sockaddr_in *)&tmp_iface.sockaddr; - p4 = (struct iface_info_ipv4 *)p->Buffer; + p4 = (struct smb_sockaddr_in *)p->Buffer; addr4->sin_family =AF_INET ;memcpy (&addr4->sin_addr, &p4->IPv4Address,4 );
@@ -697,7 +697,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,break ;case INTERNETWORKV6 : addr6 = (struct sockaddr_in6 *)&tmp_iface.sockaddr; - p6 = (struct iface_info_ipv6 *)p->Buffer; + p6 = (struct smb_sockaddr_in6 *)p->Buffer; addr6->sin6_family =AF_INET6 ;memcpy (&addr6->sin6_addr, &p6->IPv6Address,16 );
fs/smb/client/smb2pdu.h +0 -13
@@ -244,19 +244,6 @@ struct network_interface_info_ioctl_rsp {__u8 Buffer[126 ]; } __packed; -struct iface_info_ipv4 { -__be16 Port; -__be32 IPv4Address; -__be64 Reserved; -} __packed; - -struct iface_info_ipv6 { -__be16 Port; -__be32 FlowInfo; -__u8 IPv6Address[16 ]; -__be32 ScopeId; -} __packed; -#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL/* general ioctls to srv not to file */ struct compress_ioctl {
fs/smb/common/smb2pdu.h +15 -0
@@ -1440,6 +1440,21 @@ struct smb2_ioctl_rsp {__u8 Buffer[]; } __packed; +/* See MS-SMB2 2.2.32.5.1.1 */ +struct smb_sockaddr_in { +__be16 Port; +__be32 IPv4Address; +__u8 Reserved[8 ]; +} __packed; + +/* See MS-SMB2 2.2.32.5.1.2 */ +struct smb_sockaddr_in6 { +__be16 Port; +__be32 FlowInfo; +__u8 IPv6Address[16 ]; +__be32 ScopeId; +} __packed; +/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ struct file_zero_data_information {__le64 FileOffset;
fs/smb/server/smb2pdu.c +2 -2
@@ -7910,7 +7910,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, idev =__in_dev_get_rtnl (netdev);if (!idev)continue ; - sockaddr_storage->addr4.IPv4address = + sockaddr_storage->addr4.IPv4Address =idev_ipv4_address (idev); nbytes +=sizeof (struct network_interface_info_ioctl_rsp ); ipv4_set = true;
@@ -7918,7 +7918,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, }else {struct inet6_dev *idev6;struct inet6_ifaddr *ifa; -__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6address; +__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address; sockaddr_storage->Family =cpu_to_le16 (INTERNETWORKV6 ); sockaddr_storage->addr6.Port =0 ;
fs/smb/server/smb2pdu.h +0 -13
@@ -100,19 +100,6 @@ struct create_posix_rsp {#define SMB2_0_IOCTL_IS_FSCTL 0x00000001 -struct smb_sockaddr_in { -__be16 Port; -__be32 IPv4address; -__u8 Reserved[8 ]; -} __packed; - -struct smb_sockaddr_in6 { -__be16 Port; -__be32 FlowInfo; -__u8 IPv6address[16 ]; -__be32 ScopeId; -} __packed; -#define INTERNETWORK 0x0002#define INTERNETWORKV6 0x0017
Signature · 1 line
2.43.0
PATCH v4 22/24 smb: move copychunk definitions to common/smb2pdu.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Rename 3 places:
- copychunk_ioctl -> copychunk_ioctl_req
- copychunk -> srv_copychunk
- server: ResumeKey -> SourceKeyU64
Merge the struct members of the server and the client, then move duplicate definitions to common header file.
--- fs/smb/client/cifspdu.h | 8 -------- fs/smb/client/smb2ops.c | 6 +++--- fs/smb/client/smb2pdu.h | 24 ------------------------ fs/smb/common/smb2pdu.h | 29 +++++++++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb2pdu.h | 20 -------------------- 6 files changed, 34 insertions(+), 57 deletions(-)
fs/smb/client/cifspdu.h +0 -8
@@ -1030,14 +1030,6 @@ typedef struct smb_com_ntransact_rsp {/* parms and data follow */ } __attribute__((packed)) NTRANSACT_RSP; -/* See MS-SMB 2.2.7.2.1.1 */ -struct srv_copychunk { -__le64 SourceOffset; -__le64 DestinationOffset; -__le32 CopyLength; -__u32 Reserved; -} __packed; - typedef struct smb_com_transaction_ioctl_req { struct smb_hdr hdr; /* wct = 23 */ __u8 MaxSetupCount;
fs/smb/client/smb2ops.c +3 -3
@@ -1524,7 +1524,7 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,static int SMB2_request_res_key (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid, -struct copychunk_ioctl *pcchunk) +struct copychunk_ioctl_req *pcchunk) {int rc;unsigned int ret_data_len;
@@ -1857,10 +1857,10 @@ smb2_copychunk_range(const unsigned int xid, {int rc =0 ;unsigned int ret_data_len =0 ; -struct copychunk_ioctl *cc_req =NULL ; +struct copychunk_ioctl_req *cc_req =NULL ;struct copychunk_ioctl_rsp *cc_rsp =NULL ;struct cifs_tcon *tcon; -struct copychunk *chunk; +struct srv_copychunk *chunk;u32 chunks, chunk_count, chunk_bytes;u32 copy_bytes, copy_bytes_left;u32 chunks_written, bytes_written;
fs/smb/client/smb2pdu.h +0 -24
@@ -158,36 +158,12 @@ struct crt_sd_ctxt {struct smb3_sd sd; } __packed; - -#define COPY_CHUNK_RES_KEY_SIZE 24struct resume_key_req {char ResumeKey[COPY_CHUNK_RES_KEY_SIZE ];__le32 ContextLength;/* MBZ */ char Context[];/* ignored, Windows sets to 4 bytes of zero */ } __packed; - -struct copychunk { -__le64 SourceOffset; -__le64 TargetOffset; -__le32 Length; -__le32 Reserved; -} __packed; - -/* this goes in the ioctl buffer when doing a copychunk request */ -struct copychunk_ioctl { -char SourceKey[COPY_CHUNK_RES_KEY_SIZE ]; -__le32 ChunkCount; -__le32 Reserved; -struct copychunk Chunks[]; -} __packed; - -struct copychunk_ioctl_rsp { -__le32 ChunksWritten; -__le32 ChunkBytesWritten; -__le32 TotalBytesWritten; -} __packed; -/* See MS-FSCC 2.3.29 and 2.3.30 */ struct get_retrieval_pointer_count_req {__le64 StartingVcn;/* virtual cluster number (signed) */
fs/smb/common/smb2pdu.h +29 -0
@@ -1424,6 +1424,35 @@ struct smb2_ioctl_req {__u8 Buffer[]; } __packed; +/* See MS-SMB2 2.2.31.1.1 */ +struct srv_copychunk { +__le64 SourceOffset; +__le64 TargetOffset; +__le32 Length; +__le32 Reserved; +} __packed; + +#define COPY_CHUNK_RES_KEY_SIZE 24 + +/* See MS-SMB2 2.2.31.1 */ +/* this goes in the ioctl buffer when doing a copychunk request */ +struct copychunk_ioctl_req { +union { +char SourceKey[COPY_CHUNK_RES_KEY_SIZE ]; +__le64 SourceKeyU64[3 ]; + }; +__le32 ChunkCount; +__le32 Reserved; + struct srv_copychunk Chunks[] __counted_by_le(ChunkCount); +} __packed; + +/* See MS-SMB2 2.2.32.1 */ +struct copychunk_ioctl_rsp { +__le32 ChunksWritten; +__le32 ChunkBytesWritten; +__le32 TotalBytesWritten; +} __packed; +struct smb2_ioctl_rsp {struct smb2_hdr hdr;__le16 StructureSize;/* Must be 49 */
fs/smb/server/smb2pdu.c +2 -2
@@ -7764,11 +7764,11 @@ static int fsctl_copychunk(struct ksmbd_work *work, } src_fp =ksmbd_lookup_foreign_fd (work, -le64_to_cpu (ci_req->ResumeKey[0 ])); +le64_to_cpu (ci_req->SourceKeyU64[0 ])); dst_fp =ksmbd_lookup_fd_slow (work, volatile_id, persistent_id); ret = -EINVAL ;if (!src_fp || - src_fp->persistent_id !=le64_to_cpu (ci_req->ResumeKey[1 ])) { + src_fp->persistent_id !=le64_to_cpu (ci_req->SourceKeyU64[1 ])) { rsp->hdr.Status =STATUS_OBJECT_NAME_NOT_FOUND ; goto out; }
fs/smb/server/smb2pdu.h +0 -20
@@ -136,26 +136,6 @@ struct resume_key_ioctl_rsp {__u8 Context[4 ];/* ignored, Windows sets to 4 bytes of zero */ } __packed; -struct srv_copychunk { -__le64 SourceOffset; -__le64 TargetOffset; -__le32 Length; -__le32 Reserved; -} __packed; - -struct copychunk_ioctl_req { -__le64 ResumeKey[3 ]; -__le32 ChunkCount; -__le32 Reserved; - struct srv_copychunk Chunks[] __counted_by_le(ChunkCount); -} __packed; - -struct copychunk_ioctl_rsp { -__le32 ChunksWritten; -__le32 ChunkBytesWritten; -__le32 TotalBytesWritten; -} __packed; -struct file_sparse {__u8 SetSparse; } __packed;
Signature · 1 line
2.43.0
PATCH v4 23/24 smb: move resume_key_ioctl_rsp to common/smb2pdu.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Rename 2 places:
- resume_key_req -> resume_key_ioctl_rsp
- server: ResumeKey -> ResumeKeyU64
Merge the struct members of the server and the client, then move duplicate definitions to common header file.
--- fs/smb/client/smb2ops.c | 4 ++-- fs/smb/client/smb2pdu.h | 6 ------ fs/smb/common/smb2pdu.h | 10 ++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb2pdu.h | 6 ------ 5 files changed, 14 insertions(+), 16 deletions(-)
fs/smb/client/smb2ops.c +2 -2
@@ -1528,7 +1528,7 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon, {int rc;unsigned int ret_data_len; -struct resume_key_req *res_key; +struct resume_key_ioctl_rsp *res_key; rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid, FSCTL_SRV_REQUEST_RESUME_KEY, NULL, 0 /* no input */,
@@ -1541,7 +1541,7 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,cifs_tcon_dbg (VFS ,"refcpy ioctl error %d getting resume key\n" , rc); goto req_res_key_exit; } -if (ret_data_len <sizeof (struct resume_key_req )) { +if (ret_data_len <sizeof (struct resume_key_ioctl_rsp )) {cifs_tcon_dbg (VFS ,"Invalid refcopy resume key length\n" ); rc = -EINVAL ; goto req_res_key_exit;
fs/smb/client/smb2pdu.h +0 -6
@@ -158,12 +158,6 @@ struct crt_sd_ctxt {struct smb3_sd sd; } __packed; -struct resume_key_req { -char ResumeKey[COPY_CHUNK_RES_KEY_SIZE ]; -__le32 ContextLength;/* MBZ */ -char Context[];/* ignored, Windows sets to 4 bytes of zero */ -} __packed; -/* See MS-FSCC 2.3.29 and 2.3.30 */ struct get_retrieval_pointer_count_req {__le64 StartingVcn;/* virtual cluster number (signed) */
fs/smb/common/smb2pdu.h +10 -0
@@ -1453,6 +1453,16 @@ struct copychunk_ioctl_rsp {__le32 TotalBytesWritten; } __packed; +/* See MS-SMB2 2.2.32.3 */ +struct resume_key_ioctl_rsp { +union { +char ResumeKey[COPY_CHUNK_RES_KEY_SIZE ]; +__u64 ResumeKeyU64[3 ]; + }; +__le32 ContextLength;/* MBZ */ +char Context[];/* ignored, Windows sets to 4 bytes of zero */ +} __packed; +struct smb2_ioctl_rsp {struct smb2_hdr hdr;__le16 StructureSize;/* Must be 49 */
fs/smb/server/smb2pdu.c +2 -2
@@ -8122,8 +8122,8 @@ static int fsctl_request_resume_key(struct ksmbd_work *work,return -ENOENT ;memset (key_rsp,0 ,sizeof (*key_rsp)); - key_rsp->ResumeKey[0 ] = req->VolatileFileId; - key_rsp->ResumeKey[1 ] = req->PersistentFileId; + key_rsp->ResumeKeyU64[0 ] = req->VolatileFileId; + key_rsp->ResumeKeyU64[1 ] = req->PersistentFileId;ksmbd_fd_put (work, fp);return 0 ;
fs/smb/server/smb2pdu.h +0 -6
@@ -130,12 +130,6 @@ struct file_object_buf_type1_ioctl_rsp {__u8 DomainId[16 ]; } __packed; -struct resume_key_ioctl_rsp { -__u64 ResumeKey[3 ]; -__le32 ContextLength; -__u8 Context[4 ];/* ignored, Windows sets to 4 bytes of zero */ -} __packed; -struct file_sparse {__u8 SetSparse; } __packed;
Signature · 1 line
2.43.0
PATCH v4 24/24 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.
--- fs/smb/client/smb2pdu.h | 21 --------------------- fs/smb/common/smb2pdu.h | 28 ++++++++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 8 ++++---- fs/smb/server/smb2pdu.h | 19 ------------------- 4 files changed, 32 insertions(+), 44 deletions(-)
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 +28 -0
@@ -1284,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;
@@ -1493,6 +1501,26 @@ struct smb_sockaddr_in6 {__u8 IPv6Address[16 ];__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 {
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 ];
Signature · 1 line
2.43.0
Namjae Jeon
maintainerRe: [PATCH v4 06/24] smb: move file access permission bits definitions to common/smb1pdu.h
In reply to [email protected]Quoted 172 lines · On Mon, Oct 27, 2025 at 4:15 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
There are only 2 different definitions between the client and server:
-
SET_FILE_READ_RIGHTS:
- client: rename toCLIENT_SET_FILE_READ_RIGHTS
- server: rename toSERVER_SET_FILE_READ_RIGHTS
-SET_FILE_WRITE_RIGHTS
- client: rename toCLIENT_SET_FILE_WRITE_RIGHTS
- server: rename toSERVER_SET_FILE_WRITE_RIGHTSPerhaps in the future we can change them to be the same, move them to common header file.
Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifsacl.c | 4 +- fs/smb/client/cifspdu.h | 112 --------------------------------- fs/smb/common/smb1pdu.h | 123 ++++++++++++++++++++++++++++++++++++- fs/smb/common/smb2pdu.h | 6 -- fs/smb/server/smb_common.h | 55 ----------------- fs/smb/server/smbacl.c | 2 +- 6 files changed, 125 insertions(+), 177 deletions(-)fs/smb/client/cifsacl.c +2
-2@@ -654,9 +654,9 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,is this but we have cleared all the bits sans RWX for either user or group or other as per bits_to_use */ if (mode &S_IRUGO ) - *pace_flags |=SET_FILE_READ_RIGHTS ; + *pace_flags |=CLIENT_SET_FILE_READ_RIGHTS ;if (mode &S_IWUGO ) - *pace_flags |=SET_FILE_WRITE_RIGHTS ; + *pace_flags |=CLIENT_SET_FILE_WRITE_RIGHTS ;if (mode &S_IXUGO ) *pace_flags |=SET_FILE_EXEC_RIGHTS ;fs/smb/client/cifspdu.h +0
-112@@ -117,118 +117,6 @@#define SMBOPEN_OTRUNC 0x0002#define SMBOPEN_OAPPEND 0x0001 -/* -* 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) - -#define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \ - | FILE_READ_ATTRIBUTES \ - | FILE_WRITE_ATTRIBUTES \ - | DELETE | READ_CONTROL | WRITE_DAC \ - | WRITE_OWNER | SYNCHRONIZE) -#define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ - | FILE_READ_EA | FILE_WRITE_EA \ - | FILE_READ_ATTRIBUTES \ - | 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 */ fs/smb/common/smb1pdu.h +0
-0@@ -75,7 +75,128 @@#define SMBFLG2_UNICODE cpu_to_le16(0x8000)/*
fs/smb/common/smb1pdu.h line 86
Quoted 10 lines
fs/smb/common/smb1pdu.h +9
-1-* File Attribute flags +* 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 */
Please don't move them to smb1pdu.h.
These are common definitions that are also defined in the smb2 specification.
Quoted 215 lines
fs/smb/common/smb1pdu.h +113
-0+/* 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) + +#define CLIENT_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \ + | FILE_READ_ATTRIBUTES \ + | FILE_WRITE_ATTRIBUTES \ + | DELETE | READ_CONTROL | WRITE_DAC \ + | WRITE_OWNER | SYNCHRONIZE) +#define SERVER_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ + | FILE_READ_ATTRIBUTES \ + | DELETE | READ_CONTROL | WRITE_DAC \ + | WRITE_OWNER | SYNCHRONIZE) +#define CLIENT_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ + | FILE_READ_EA | FILE_WRITE_EA \ + | FILE_READ_ATTRIBUTES \ + | FILE_WRITE_ATTRIBUTES \ + | DELETE | READ_CONTROL | WRITE_DAC \ + | WRITE_OWNER | SYNCHRONIZE) +#define SERVER_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ + | FILE_WRITE_EA \ + | FILE_DELETE_CHILD \ + | 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) + +/* +* File Attribute flags - see MS-SMB 2.2.1.4.1 */ #define ATTR_READONLY 0x0001#define ATTR_HIDDEN 0x0002fs/smb/common/smb2pdu.h +0
-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) */ fs/smb/server/smb_common.h +0
-55@@ -38,61 +38,6 @@#define F_CREATED 2#define F_OVERWRITTEN 3 -#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. */ - -#define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ - | FILE_READ_ATTRIBUTES \ - | DELETE | READ_CONTROL | WRITE_DAC \ - | WRITE_OWNER | SYNCHRONIZE) -#define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ - | FILE_WRITE_EA \ - | FILE_DELETE_CHILD \ - | 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 | \ FILE_READ_ATTRIBUTES | \fs/smb/server/smbacl.c +1
-2@@ -180,7 +180,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,* either user or group or other as per bits_to_use */ if (mode &0444 ) - *pace_flags |=SET_FILE_READ_RIGHTS ; + *pace_flags |=SERVER_SET_FILE_READ_RIGHTS ;if (mode &0222 ) *pace_flags |=FILE_WRITE_RIGHTS ;if (mode &0111 ) --2.43.0
Namjae Jeon
maintainerRe: [PATCH v4 13/24] smb: move FILE_BOTH_DIRECTORY_INFO to common/smb1pdu.h
In reply to [email protected]Quoted 7 lines · On Mon, Oct 27, 2025 at 4:15 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
file_both_directory_info" to "FILE_BOTH_DIRECTORY_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>
file information classes are defined in ms-fscc specification. So we can move them to fscc.h. Please check other your patches also.
Namjae Jeon
maintainerRe: [PATCH v4 05/24] smb: move some duplicate definitions to common/smb1pdu.h
In reply to [email protected]Quoted 8 lines · On Mon, Oct 27, 2025 at 4:15 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to new common header file.
Signed-off-by ChenXiaoSong <[email protected]>Suggested-by Namjae Jeon <[email protected]>
ksmbd does not use all smb1 pdus. Instead of moving all smb1 definitions, move the ones ksmbd uses to smb1pdu.h.
Thanks.
Namjae Jeon
maintainerRe: [PATCH v4 14/24] smb: move SEARCH_ID_FULL_DIR_INFO to common/smb1pdu.h
In reply to [email protected]Quoted 57 lines · On Mon, Oct 27, 2025 at 4:15 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
file_id_full_dir_info" to "SEARCH_ID_FULL_DIR_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 17 ----------------- fs/smb/common/smb1pdu.h | 18 ++++++++++++++++++ fs/smb/server/smb2pdu.c | 14 +++++++------- fs/smb/server/smb_common.h | 17 ----------------- 4 files changed, 25 insertions(+), 41 deletions(-)fs/smb/client/cifspdu.h +0
-17@@ -2159,23 +2159,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; -__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 { __u32 ResumeKey; __le16 CreationDate; /* SMB Date */fs/smb/common/smb1pdu.h +7
-0@@ -399,6 +399,24 @@ typedef struct {char FileName[]; }__packed FILE_FULL_DIRECTORY_INFO ;/* level 0x102 rsp data */ +/* See MS-SMB 2.2.8.1.2 */ +typedef struct { + __le32 NextEntryOffset; + __u32 FileIndex; + __le64 CreationTime; + __le64 LastAccessTime; + __le64 LastWriteTime;
fs/smb/common/smb1pdu.h typedef struct { · line 418
Quoted 10 lines
fs/smb/common/smb1pdu.h +10
-0+__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[]; +}__packed SEARCH_ID_FULL_DIR_INFO ;/* level 0x105 FF rsp data */
Please check if this class name is defined in the fscc specification. Thanks.
Re: [PATCH v4 06/24] smb: move file access permission bits definitions to common/smb1pdu.h
In reply to Namjae JeonYes, maybe I should move them to common/smbglob.h.
Quoted 2 lines · Namjae Jeon
Please don't move them to
smb1pdu.h.
These are common definitions that are also defined in the smb2 specification.
Signature · 2 lines
Thanks, ChenXiaoSong.
Re: [PATCH v4 05/24] smb: move some duplicate definitions to common/smb1pdu.h
In reply to Namjae JeonWould it be harder to maintain if only part of the definitions are moved?
Moving the related definitions together would make maintenance easier, that's just my personal opinion.
Quoted 12 lines · Namjae Jeon
Quoted 8 lines · On Mon, Oct 27, 2025 at 4:15 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to new common header file.
Signed-off-by ChenXiaoSong <[email protected]>Suggested-by Namjae Jeon <[email protected]>ksmbd does not use all smb1 pdus. Instead of moving all smb1 definitions, move the ones ksmbd uses to
smb1pdu.h.
Thanks.
Signature · 2 lines
Thanks, ChenXiaoSong.
Namjae Jeon
maintainerRe: [PATCH v4 05/24] smb: move some duplicate definitions to common/smb1pdu.h
Quoted 5 lines · ChenXiaoSong
Would it be harder to maintain if only part of the definitions are moved?
Moving the related definitions together would make maintenance easier, that's just my personal opinion.
Please check Steve's reply on another mail thread. If you think it looks weird, don't move them.
Quoted 19 lines · Namjae Jeon
Quoted 12 lines · On Mon, Oct 27, 2025 at 4:15 PM <[email protected]> wrote:
Quoted 8 lines
From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to new common header file.
Signed-off-by ChenXiaoSong <[email protected]>Suggested-by Namjae Jeon <[email protected]>ksmbd does not use all smb1 pdus. Instead of moving all smb1 definitions, move the ones ksmbd uses to
smb1pdu.h.
Thanks.--
Thanks,
ChenXiaoSong.
Re: [PATCH v4 13/24] smb: move FILE_BOTH_DIRECTORY_INFO to common/smb1pdu.h
In reply to Namjae JeonOK, I’ll try to create a new common/fscc.h.
Quoted 10 lines · Namjae Jeon
Quoted 7 lines · On Mon, Oct 27, 2025 at 4:15 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
file_both_directory_info" to "FILE_BOTH_DIRECTORY_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>file information classes are defined in ms-fscc specification. So we can move them to
fscc.h. Please check other your patches also.
Signature · 2 lines
Thanks, ChenXiaoSong.
Re: [PATCH v4 06/24] smb: move file access permission bits definitions to common/smb1pdu.h
In reply to a message not in the archiveGot it, thanks for your suggestion.
Quoted 739 lines · Steve French
The goal would be to have things (#defines flags, structs, code) only used by smb1, thus not used by ksmbd (which doesn't support smb1, it is only supported by cifs.ko and even then only when smb1 is enabled in kernel config) in distinct headers (that wouldn't have to be in
fs/smb/common) so we don't ever confuse current secure smb311 code with smb1Thanks,
Steve
On Tue, Oct 28, 2025, 12:11 AM ChenXiaoSong <[email protected] <mailto:[email protected]>> wrote:
Do you mean merging
smb1pdu.handsmb2pdu.hintosmbpdu.h?On 10/28/25 11:54 AM, Steve French wrote:
> We don't want to encourage smb1 so where possible things used for
smb2
> and later especially smb3 and later should never be in something
that
> sounds like smb1. ideally most of smb1 code could be ifdef out
but also
> we don't want to look like we require smb1
>
> Thanks,
>
> Steve
>
> On Mon, Oct 27, 2025, 11:37 PM Namjae Jeon <[email protected]
<mailto:[email protected]>
> <mailto:[email protected] <mailto:[email protected]>>> wrote:
>
> On Mon, Oct 27, 2025 at 4:15 PM
<[email protected] <mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>> wrote:
> >
> > From: ChenXiaoSong <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>>
> >
> > There are only 2 different definitions between the client
and server:
> >
> > -SET_FILE_READ_RIGHTS:
> > - client: rename toCLIENT_SET_FILE_READ_RIGHTS> > - server: rename toSERVER_SET_FILE_READ_RIGHTS> > -SET_FILE_WRITE_RIGHTS
> > - client: rename toCLIENT_SET_FILE_WRITE_RIGHTS> > - server: rename toSERVER_SET_FILE_WRITE_RIGHTS> >
> > Perhaps in the future we can change them to be the same,
move them to
> > common header file.
> >
> > Signed-off-by: ChenXiaoSong <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>>
> > ---
> > fs/smb/client/cifsacl.c | 4 +-
> > fs/smb/client/cifspdu.h | 112
---------------------------------
> > fs/smb/common/smb1pdu.h | 123 ++++++++++++++++++++++++
+++++++
> +++++-
> > fs/smb/common/smb2pdu.h | 6 --
> >fs/smb/server/smb_common.h| 55 ----------------- > > fs/smb/server/smbacl.c | 2 +-
> > 6 files changed, 125 insertions(+), 177 deletions(-) > >
> > diff --gita/fs/smb/client/cifsacl.cb/fs/smb/client/cifsacl.c> > indexce2ebc213a1d..5c3d8eb68868100644
> > ---a/fs/smb/client/cifsacl.c
> > +++b/fs/smb/client/cifsacl.c
> > @@ -654,9 +654,9 @@ static void mode_to_access_flags(umode_t > mode,umode_tbits_to_use,
> > is this but we have cleared all the bits sans
RWX for
> > either user or group or other as perbits_to_use*/ > > if (mode &S_IRUGO)
> > - *pace_flags |=SET_FILE_READ_RIGHTS; > > + *pace_flags |=CLIENT_SET_FILE_READ_RIGHTS; > > if (mode &S_IWUGO)
> > - *pace_flags |=SET_FILE_WRITE_RIGHTS; > > + *pace_flags |=CLIENT_SET_FILE_WRITE_RIGHTS; > > if (mode &S_IXUGO)
> > *pace_flags |=SET_FILE_EXEC_RIGHTS; > >
> > diff --gita/fs/smb/client/cifspdu.hb/fs/smb/client/cifspdu.h> > index86167875574c..a063c98683bc100644
> > ---a/fs/smb/client/cifspdu.h
> > +++b/fs/smb/client/cifspdu.h
> > @@ -117,118 +117,6 @@
> > #define SMBOPEN_OTRUNC0x0002
> > #define SMBOPEN_OAPPEND 0x0001
> >
> > -/*
> > - * These are the file access permission bits defined in
CIFS for the
> > - * NTCreateAndX as well as the level0x107
> > - *TRANS2_QUERY_PATH_INFORMATIONAPI. The level0x107, > 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 */
> > -#defineFILE_WRITE_ATTRIBUTES0x00000100 /* 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 */
> > - /* SoGENERIC_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 */
> > -
> > -#defineFILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA| > FILE_READ_ATTRIBUTES)
> > -#defineFILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_WRITE_EA| > FILE_WRITE_ATTRIBUTES)
> > -#defineFILE_EXEC_RIGHTS(FILE_EXECUTE)
> > -
> > -#defineSET_FILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA| > FILE_WRITE_EA \
> > - |FILE_READ_ATTRIBUTES\
> > - |FILE_WRITE_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|
WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE) > > -#defineSET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_READ_EA|
FILE_WRITE_EA\
> > - |FILE_READ_ATTRIBUTES\
> > - |FILE_WRITE_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|
WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE) > > -#defineSET_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) > > -
> > -#defineSET_MINIMUM_RIGHTS(FILE_READ_EA|
FILE_READ_ATTRIBUTES\
> > - |READ_CONTROL| SYNCHRONIZE) > > -
> > /*
> > * Invalid readdir handle
> > */
> > diff --gita/fs/smb/common/smb1pdu.hb/fs/smb/common/smb1pdu.h> > indexf14d3d9aac22..9fe6fc4b05a7100644
> > ---a/fs/smb/common/smb1pdu.h
> > +++b/fs/smb/common/smb1pdu.h
> > @@ -75,7 +75,128 @@
> > #defineSMBFLG2_UNICODEcpu_to_le16(0x8000)
> >
> > /*
> > - * File Attribute flags
> > + * These are the file access permission bits defined in
CIFS for the
> > + * NTCreateAndX as well as the level0x107
> > + *TRANS2_QUERY_PATH_INFORMATIONAPI. The level0x107, > 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 */
> Please don't move them tosmb1pdu.h.
> These are common definitions that are also defined in the smb2 > specification.
> > + /* 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 */
> > +#defineFILE_WRITE_ATTRIBUTES0x00000100 /* 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 */
> > + /* SoGENERIC_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 */
> > +
> > +#defineFILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA| > FILE_READ_ATTRIBUTES)
> > +#defineFILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > + |FILE_WRITE_EA| > FILE_WRITE_ATTRIBUTES)
> > +#defineFILE_EXEC_RIGHTS(FILE_EXECUTE)
> > +
> > +#defineCLIENT_SET_FILE_READ_RIGHTS(FILE_READ_DATA| > FILE_READ_EA |FILE_WRITE_EA\
> > + |FILE_READ_ATTRIBUTES\
> > + |FILE_WRITE_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE) > > +#defineSERVER_SET_FILE_READ_RIGHTS(FILE_READ_DATA|
FILE_READ_EA\
> > + |FILE_READ_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE) > > +#defineCLIENT_SET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA| > FILE_APPEND_DATA \
> > + |FILE_READ_EA|
FILE_WRITE_EA\
> > + |FILE_READ_ATTRIBUTES\
> > + |FILE_WRITE_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE) > > +#defineSERVER_SET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA| > FILE_APPEND_DATA \
> > + |FILE_WRITE_EA\
> > + |FILE_DELETE_CHILD\
> > + |FILE_WRITE_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE) > > +#defineSET_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) > > +#defineSET_MINIMUM_RIGHTS(FILE_READ_EA|
FILE_READ_ATTRIBUTES\
> > + |READ_CONTROL| SYNCHRONIZE) > > +
> > +/*
> > + * File Attribute flags - see MS-SMB 2.2.1.4.1
> > */
> > #define ATTR_READONLY0x0001
> > #define ATTR_HIDDEN0x0002
> > diff --gita/fs/smb/common/smb2pdu.hb/fs/smb/common/smb2pdu.h> > indexf79a5165a7cc..f2fbd651ab8f100644
> > ---a/fs/smb/common/smb2pdu.h
> > +++b/fs/smb/common/smb2pdu.h
> > @@ -1149,12 +1149,6 @@ struct
smb2_server_client_notification{
> > #defineFILE_OVERWRITE_IF_LEcpu_to_le32(0x00000005)
> > #defineFILE_CREATE_MASK_LEcpu_to_le32(0x00000007)
> >
> > -#defineFILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA\
> > - |FILE_READ_ATTRIBUTES)
> > -#defineFILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_WRITE_EA|
FILE_WRITE_ATTRIBUTES)
> > -#defineFILE_EXEC_RIGHTS(FILE_EXECUTE)
> > -
> > /* CreateOptions Flags */
> > #defineFILE_DIRECTORY_FILE_LEcpu_to_le32(0x00000001)
> > /* same as #defineCREATE_NOT_FILE_LE
cpu_to_le32(0x00000001)*/
> > diff --gita/fs/smb/server/smb_common.hb/fs/smb/server/
smb_common.h
> > index810fad0303d7..df67b370025d100644
> > ---a/fs/smb/server/smb_common.h
> > +++b/fs/smb/server/smb_common.h
> > @@ -38,61 +38,6 @@
> > #define F_CREATED 2
> > #define F_OVERWRITTEN 3
> >
> > -#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 */
> > -#defineFILE_WRITE_ATTRIBUTES0x00000100 /* 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_READ0x80000000
> > -/* In summary - Relevant file */
> > -/* access flags from CIFS are */
> > -/*file_read_data, file_write_data */
> > -/*file_execute, file_read_attributes*/
> > -/*write_dac, and delete. */
> > -
> > -#defineSET_FILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA\
> > - |FILE_READ_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE)
> > -#defineSET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_WRITE_EA\
> > - |FILE_DELETE_CHILD\
> > - |FILE_WRITE_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE)
> > -#defineSET_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)
> > -
> > -#defineSET_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| \
> > FILE_READ_ATTRIBUTES | \
> > diff --gita/fs/smb/server/smbacl.cb/fs/smb/server/smbacl.c> > index5aa7a66334d9..b70ba50f1f10100644
> > ---a/fs/smb/server/smbacl.c
> > +++b/fs/smb/server/smbacl.c
> > @@ -180,7 +180,7 @@ static void mode_to_access_flags(umode_t > mode,umode_tbits_to_use,
> > * either user or group or other as perbits_to_use> > */
> > if (mode & 0444)
> > - *pace_flags |=SET_FILE_READ_RIGHTS; > > + *pace_flags |=SERVER_SET_FILE_READ_RIGHTS; > > if (mode & 0222)
> > *pace_flags |=FILE_WRITE_RIGHTS; > > if (mode & 0111)
> > --
> > 2.43.0
> >
>--
Thanks,
ChenXiaoSong.
Signature · 2 lines
Thanks, ChenXiaoSong.
Re: [PATCH v4 06/24] smb: move file access permission bits definitions to common/smb1pdu.h
One of the problems of course is balancing code readability and minimizing difficult (to rebase on) changes where possible (so we don't mess up backports to stable too much) with "we don't want smb1 confusing highly secure smb3.1.1 code, and want smb1 code to be easy to ignore and compile out"
Quoted 754 lines · ChenXiaoSong
Got it, thanks for your suggestion.
Quoted 741 lines · Steve French
The goal would be to have things (#defines flags, structs, code) only used by smb1, thus not used by ksmbd (which doesn't support smb1, it is only supported by cifs.ko and even then only when smb1 is enabled in kernel config) in distinct headers (that wouldn't have to be in
fs/smb/common) so we don't ever confuse current secure smb311 code with smb1Thanks,
Steve
On Tue, Oct 28, 2025, 12:11 AM ChenXiaoSong <[email protected] <mailto:[email protected]>> wrote:
Do you mean merging
smb1pdu.handsmb2pdu.hintosmbpdu.h?On 10/28/25 11:54 AM, Steve French wrote:
> We don't want to encourage smb1 so where possible things used for
smb2
> and later especially smb3 and later should never be in something
that
> sounds like smb1. ideally most of smb1 code could be ifdef out
but also
> we don't want to look like we require smb1
>
> Thanks,
>
> Steve
>
> On Mon, Oct 27, 2025, 11:37 PM Namjae Jeon <[email protected]
<mailto:[email protected]>
> <mailto:[email protected] <mailto:[email protected]>>> wrote:
>
> On Mon, Oct 27, 2025 at 4:15 PM
<[email protected] <mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>> wrote:
> >
> > From: ChenXiaoSong <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>>
> >
> > There are only 2 different definitions between the client
and server:
> >
> > -SET_FILE_READ_RIGHTS:
> > - client: rename toCLIENT_SET_FILE_READ_RIGHTS
> > - server: rename toSERVER_SET_FILE_READ_RIGHTS
> > -SET_FILE_WRITE_RIGHTS
> > - client: rename toCLIENT_SET_FILE_WRITE_RIGHTS
> > - server: rename toSERVER_SET_FILE_WRITE_RIGHTS
> >
> > Perhaps in the future we can change them to be the same,
move them to
> > common header file.
> >
> > Signed-off-by: ChenXiaoSong <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>>
> > ---
> >fs/smb/client/cifsacl.c| 4 +-
> >fs/smb/client/cifspdu.h| 112
---------------------------------
> >fs/smb/common/smb1pdu.h| 123 ++++++++++++++++++++++++
+++++++
> +++++-
> >fs/smb/common/smb2pdu.h| 6 --
> >fs/smb/server/smb_common.h| 55 -----------------
> >fs/smb/server/smbacl.c| 2 +-
> > 6 files changed, 125 insertions(+), 177 deletions(-)
> >
> > diff --gita/fs/smb/client/cifsacl.cb/fs/smb/client/cifsacl.c
> > indexce2ebc213a1d..5c3d8eb68868100644
> > ---a/fs/smb/client/cifsacl.c
> > +++b/fs/smb/client/cifsacl.c
> > @@ -654,9 +654,9 @@ static void mode_to_access_flags(umode_t
> mode,umode_tbits_to_use,
> > is this but we have cleared all the bits sans
RWX for
> > either user or group or other as perbits_to_use*/
> > if (mode &S_IRUGO)
> > -*pace_flags|=SET_FILE_READ_RIGHTS;
> > +*pace_flags|=CLIENT_SET_FILE_READ_RIGHTS;
> > if (mode &S_IWUGO)
> > -*pace_flags|=SET_FILE_WRITE_RIGHTS;
> > +*pace_flags|=CLIENT_SET_FILE_WRITE_RIGHTS;
> > if (mode &S_IXUGO)
> >*pace_flags|=SET_FILE_EXEC_RIGHTS;
> >
> > diff --gita/fs/smb/client/cifspdu.hb/fs/smb/client/cifspdu.h
> > index86167875574c..a063c98683bc100644
> > ---a/fs/smb/client/cifspdu.h
> > +++b/fs/smb/client/cifspdu.h
> > @@ -117,118 +117,6 @@
> > #defineSMBOPEN_OTRUNC0x0002
> > #defineSMBOPEN_OAPPEND0x0001
> >
> > -/*
> > - * These are the file access permission bits defined in
CIFS for the
> > - * NTCreateAndX as well as the level0x107
> > - *TRANS2_QUERY_PATH_INFORMATIONAPI. The level0x107,
>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:
> > - */
> > -
> > -#defineFILE_READ_DATA0x00000001/* Data can be read
> from the file */
> > - /* or directory
child
> entries can */
> > - /* be listed
together
> with the */
> > - /* associated child
> attributes */
> > - /* (so the
>FILE_READ_ATTRIBUTESon */
> > - /* the child
entry is
> not needed) */
> > -#defineFILE_WRITE_DATA0x00000002/* Data can be
written
> to the file */
> > - /* or new file
can be
> created in */
> > - /* the directory
> */
> > -#defineFILE_APPEND_DATA0x00000004/* 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 */
> > -#defineFILE_READ_EA0x00000008/* Extended
attributes
> associated */
> > - /* with the file
can be
> read */
> > -#defineFILE_WRITE_EA0x00000010/* Extended
attributes
> associated */
> > - /* with the file
can be
> written */
> > -#defineFILE_EXECUTE0x00000020/*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)*/
> > -#defineFILE_DELETE_CHILD0x00000040/* Child entry
can be
> deleted from */
> > - /* the directory (so
> the DELETE on */
> > - /* the child
entry is
> not needed) */
> > -#defineFILE_READ_ATTRIBUTES0x00000080/* Attributes
> associated with the */
> > - /* file or directory
> can be read */
> > -#defineFILE_WRITE_ATTRIBUTES0x00000100/* Attributes
> associated with the */
> > - /* file or directory
> can be written */
> > -#define DELETE0x00010000/* The file or
dir can
> be deleted */
> > -#defineREAD_CONTROL0x00020000/* The
discretionary
> access control */
> > - /* list and
ownership
> associated */
> > - /* with the file
or dir
> can be read */
> > -#defineWRITE_DAC0x00040000/* The
discretionary
> access control */
> > - /* list
associated with
> the file or */
> > - /* directory can be
> written */
> > -#defineWRITE_OWNER0x00080000/* Ownership
> information associated */
> > - /* with the file/dir
> can be written */
> > -#define SYNCHRONIZE0x00100000/* The file
handle can
> waited on to */
> > - /* synchronize
with the
> completion */
> > - /* of an input/
output
> request */
> > -#defineSYSTEM_SECURITY0x01000000/* The system
access
> control list */
> > - /* associated
with the
> file or */
> > - /* directory can be
> read or written */
> > - /* (cannot be in
DACL,
> can in SACL) */
> > -#defineMAXIMUM_ALLOWED0x02000000/* Maximal
subset of
>GENERIC_ALL*/
> > - /* permissions which
> can be granted */
> > - /* (cannot be in
DACL
> nor SACL) */
> > -#defineGENERIC_ALL0x10000000/* Same as:
>GENERIC_EXECUTE| */
> > - /*
>GENERIC_WRITE| */
> > - /*
>GENERIC_READ| */
> > - /*
>FILE_DELETE_CHILD| */
> > - /*
DELETE |
> */
> > - /*
WRITE_DAC|
> */
> > - /*
>WRITE_OWNER*/
> > - /* SoGENERIC_ALL
> contains all bits */
> > - /* mentioned above
> except these two */
> > - /*SYSTEM_SECURITY
>MAXIMUM_ALLOWED*/
> > -#defineGENERIC_EXECUTE0x20000000/* Same as:
>FILE_EXECUTE| */
> > - /*
>FILE_READ_ATTRIBUTES| */
> > - /*
>READ_CONTROL| */
> > - /*
> SYNCHRONIZE */
> > -#defineGENERIC_WRITE0x40000000/* Same as:
>FILE_WRITE_DATA| */
> > - /*
>FILE_APPEND_DATA| */
> > - /*
>FILE_WRITE_EA| */
> > - /*
>FILE_WRITE_ATTRIBUTES| */
> > - /*
>READ_CONTROL| */
> > - /*
> SYNCHRONIZE */
> > -#defineGENERIC_READ0x80000000/* Same as:
>FILE_READ_DATA| */
> > - /*
>FILE_READ_EA| */
> > - /*
>FILE_READ_ATTRIBUTES| */
> > - /*
>READ_CONTROL| */
> > - /*
> SYNCHRONIZE */
> > -
> > -#defineFILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA|
>FILE_READ_ATTRIBUTES)
> > -#defineFILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_WRITE_EA|
>FILE_WRITE_ATTRIBUTES)
> > -#defineFILE_EXEC_RIGHTS(FILE_EXECUTE)
> > -
> > -#defineSET_FILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA|
>FILE_WRITE_EA\
> > - |FILE_READ_ATTRIBUTES\
> > - |FILE_WRITE_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|
WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE)
> > -#defineSET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_READ_EA|
FILE_WRITE_EA\
> > - |FILE_READ_ATTRIBUTES\
> > - |FILE_WRITE_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|
WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE)
> > -#defineSET_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)
> > -
> > -#defineSET_MINIMUM_RIGHTS(FILE_READ_EA|
FILE_READ_ATTRIBUTES\
> > - |READ_CONTROL| SYNCHRONIZE)
> > -
> > /*
> > * Invalid readdir handle
> > */
> > diff --gita/fs/smb/common/smb1pdu.hb/fs/smb/common/smb1pdu.h
> > indexf14d3d9aac22..9fe6fc4b05a7100644
> > ---a/fs/smb/common/smb1pdu.h
> > +++b/fs/smb/common/smb1pdu.h
> > @@ -75,7 +75,128 @@
> > #defineSMBFLG2_UNICODEcpu_to_le16(0x8000)
> >
> > /*
> > - * File Attribute flags
> > + * These are the file access permission bits defined in
CIFS for the
> > + * NTCreateAndX as well as the level0x107
> > + *TRANS2_QUERY_PATH_INFORMATIONAPI. The level0x107,
>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:
> > + */
> > +
> > +#defineFILE_READ_DATA0x00000001/* Data can be read
> from the file */
> Please don't move them tosmb1pdu.h.
> These are common definitions that are also defined in the smb2
> specification.
> > + /* or directory
child
> entries can */
> > + /* be listed
together
> with the */
> > + /* associated child
> attributes */
> > + /* (so the
>FILE_READ_ATTRIBUTESon */
> > + /* the child
entry is
> not needed) */
> > +#defineFILE_WRITE_DATA0x00000002/* Data can be
written
> to the file */
> > + /* or new file
can be
> created in */
> > + /* the directory
> */
> > +#defineFILE_APPEND_DATA0x00000004/* 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 */
> > +#defineFILE_READ_EA0x00000008/* Extended
attributes
> associated */
> > + /* with the file
can be
> read */
> > +#defineFILE_WRITE_EA0x00000010/* Extended
attributes
> associated */
> > + /* with the file
can be
> written */
> > +#defineFILE_EXECUTE0x00000020/*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)*/
> > +#defineFILE_DELETE_CHILD0x00000040/* Child entry
can be
> deleted from */
> > + /* the directory (so
> the DELETE on */
> > + /* the child
entry is
> not needed) */
> > +#defineFILE_READ_ATTRIBUTES0x00000080/* Attributes
> associated with the */
> > + /* file or directory
> can be read */
> > +#defineFILE_WRITE_ATTRIBUTES0x00000100/* Attributes
> associated with the */
> > + /* file or directory
> can be written */
> > +#define DELETE0x00010000/* The file or
dir can
> be deleted */
> > +#defineREAD_CONTROL0x00020000/* The
discretionary
> access control */
> > + /* list and
ownership
> associated */
> > + /* with the file
or dir
> can be read */
> > +#defineWRITE_DAC0x00040000/* The
discretionary
> access control */
> > + /* list
associated with
> the file or */
> > + /* directory can be
> written */
> > +#defineWRITE_OWNER0x00080000/* Ownership
> information associated */
> > + /* with the file/dir
> can be written */
> > +#define SYNCHRONIZE0x00100000/* The file
handle can
> waited on to */
> > + /* synchronize
with the
> completion */
> > + /* of an input/
output
> request */
> > +#defineSYSTEM_SECURITY0x01000000/* The system
access
> control list */
> > + /* associated
with the
> file or */
> > + /* directory can be
> read or written */
> > + /* (cannot be in
DACL,
> can in SACL) */
> > +#defineMAXIMUM_ALLOWED0x02000000/* Maximal
subset of
>GENERIC_ALL*/
> > + /* permissions which
> can be granted */
> > + /* (cannot be in
DACL
> nor SACL) */
> > +#defineGENERIC_ALL0x10000000/* Same as:
>GENERIC_EXECUTE| */
> > + /*
>GENERIC_WRITE| */
> > + /*
>GENERIC_READ| */
> > + /*
>FILE_DELETE_CHILD| */
> > + /*
DELETE |
> */
> > + /*
WRITE_DAC|
> */
> > + /*
>WRITE_OWNER*/
> > + /* SoGENERIC_ALL
> contains all bits */
> > + /* mentioned above
> except these two */
> > + /*SYSTEM_SECURITY
>MAXIMUM_ALLOWED*/
> > +#defineGENERIC_EXECUTE0x20000000/* Same as:
>FILE_EXECUTE| */
> > + /*
>FILE_READ_ATTRIBUTES| */
> > + /*
>READ_CONTROL| */
> > + /*
> SYNCHRONIZE */
> > +#defineGENERIC_WRITE0x40000000/* Same as:
>FILE_WRITE_DATA| */
> > + /*
>FILE_APPEND_DATA| */
> > + /*
>FILE_WRITE_EA| */
> > + /*
>FILE_WRITE_ATTRIBUTES| */
> > + /*
>READ_CONTROL| */
> > + /*
> SYNCHRONIZE */
> > +#defineGENERIC_READ0x80000000/* Same as:
>FILE_READ_DATA| */
> > + /*
>FILE_READ_EA| */
> > + /*
>FILE_READ_ATTRIBUTES| */
> > + /*
>READ_CONTROL| */
> > + /*
> SYNCHRONIZE */
> > +
> > +#defineFILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA|
>FILE_READ_ATTRIBUTES)
> > +#defineFILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > + |FILE_WRITE_EA|
>FILE_WRITE_ATTRIBUTES)
> > +#defineFILE_EXEC_RIGHTS(FILE_EXECUTE)
> > +
> > +#defineCLIENT_SET_FILE_READ_RIGHTS(FILE_READ_DATA|
>FILE_READ_EA|FILE_WRITE_EA\
> > + |FILE_READ_ATTRIBUTES\
> > + |FILE_WRITE_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE)
> > +#defineSERVER_SET_FILE_READ_RIGHTS(FILE_READ_DATA|
FILE_READ_EA\
> > + |FILE_READ_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE)
> > +#defineCLIENT_SET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA|
>FILE_APPEND_DATA\
> > + |FILE_READ_EA|
FILE_WRITE_EA\
> > + |FILE_READ_ATTRIBUTES\
> > + |FILE_WRITE_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE)
> > +#defineSERVER_SET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA|
>FILE_APPEND_DATA\
> > + |FILE_WRITE_EA\
> > + |FILE_DELETE_CHILD\
> > + |FILE_WRITE_ATTRIBUTES\
> > + | DELETE |READ_CONTROL|
WRITE_DAC\
> > + |WRITE_OWNER| SYNCHRONIZE)
> > +#defineSET_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)
> > +#defineSET_MINIMUM_RIGHTS(FILE_READ_EA|
FILE_READ_ATTRIBUTES\
> > + |READ_CONTROL| SYNCHRONIZE)
> > +
> > +/*
> > + * File Attribute flags - see MS-SMB 2.2.1.4.1
> > */
> > #defineATTR_READONLY0x0001
> > #defineATTR_HIDDEN0x0002
> > diff --gita/fs/smb/common/smb2pdu.hb/fs/smb/common/smb2pdu.h
> > indexf79a5165a7cc..f2fbd651ab8f100644
> > ---a/fs/smb/common/smb2pdu.h
> > +++b/fs/smb/common/smb2pdu.h
> > @@ -1149,12 +1149,6 @@ struct
smb2_server_client_notification{
> > #defineFILE_OVERWRITE_IF_LE
cpu_to_le32(0x00000005)
> > #defineFILE_CREATE_MASK_LE
cpu_to_le32(0x00000007)
> >
> > -#defineFILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA\
> > - |FILE_READ_ATTRIBUTES)
> > -#defineFILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_WRITE_EA|
FILE_WRITE_ATTRIBUTES)
> > -#defineFILE_EXEC_RIGHTS(FILE_EXECUTE)
> > -
> > /* CreateOptions Flags */
> > #defineFILE_DIRECTORY_FILE_LE
cpu_to_le32(0x00000001)
> > /* same as #defineCREATE_NOT_FILE_LE
cpu_to_le32(0x00000001)*/
> > diff --gita/fs/smb/server/smb_common.hb/fs/smb/server/
smb_common.h
> > index810fad0303d7..df67b370025d100644
> > ---a/fs/smb/server/smb_common.h
> > +++b/fs/smb/server/smb_common.h
> > @@ -38,61 +38,6 @@
> > #defineF_CREATED2
> > #defineF_OVERWRITTEN3
> >
> > -#defineFILE_READ_DATA0x00000001/* Data can be read
> from the file */
> > -#defineFILE_WRITE_DATA0x00000002/* Data can be
written
> to the file */
> > -#defineFILE_APPEND_DATA0x00000004/* Data can be
> appended to the file */
> > -#defineFILE_READ_EA0x00000008/* Extended
attributes
> associated */
> > -/* with the file can be read */
> > -#defineFILE_WRITE_EA0x00000010/* Extended
attributes
> associated */
> > -/* with the file can be written */
> > -#defineFILE_EXECUTE0x00000020/*Data can be read
> into memory from */
> > -/* the file using system paging I/O */
> > -#defineFILE_DELETE_CHILD0x00000040
> > -#defineFILE_READ_ATTRIBUTES0x00000080/* Attributes
> associated with the */
> > -/* file can be read */
> > -#defineFILE_WRITE_ATTRIBUTES0x00000100/* Attributes
> associated with the */
> > -/* file can be written */
> > -#define DELETE0x00010000/* The file can be
> deleted */
> > -#defineREAD_CONTROL0x00020000/* The access
control
> list and */
> > -/* ownership associated with the */
> > -/* file can be read */
> > -#defineWRITE_DAC0x00040000/* The access
control
> list and */
> > -/* ownership associated with the */
> > -/* file can be written. */
> > -#defineWRITE_OWNER0x00080000/* Ownership
> information associated */
> > -/* with the file can be written */
> > -#define SYNCHRONIZE0x00100000/* The file
handle can
> waited on to */
> > -/* synchronize with the completion */
> > -/* of an input/output request */
> > -#defineGENERIC_ALL0x10000000
> > -#defineGENERIC_EXECUTE0x20000000
> > -#defineGENERIC_WRITE0x40000000
> > -#defineGENERIC_READ0x80000000
> > -/* In summary - Relevant file */
> > -/* access flags from CIFS are */
> > -/*file_read_data,file_write_data*/
> > -/*file_execute, file_read_attributes*/
> > -/*write_dac, and delete. */
> > -
> > -#defineSET_FILE_READ_RIGHTS(FILE_READ_DATA|FILE_READ_EA\
> > - |FILE_READ_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE)
> > -#defineSET_FILE_WRITE_RIGHTS(FILE_WRITE_DATA|
FILE_APPEND_DATA\
> > - |FILE_WRITE_EA\
> > - |FILE_DELETE_CHILD\
> > - |FILE_WRITE_ATTRIBUTES\
> > - | DELETE |READ_CONTROL|WRITE_DAC\
> > - |WRITE_OWNER| SYNCHRONIZE)
> > -#defineSET_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)
> > -
> > -#defineSET_MINIMUM_RIGHTS(FILE_READ_EA|
FILE_READ_ATTRIBUTES\
> > - |READ_CONTROL| SYNCHRONIZE)
> > -
> > /* generic flags for file open */
> > #defineGENERIC_READ_FLAGS(READ_CONTROL|
FILE_READ_DATA| \
> >FILE_READ_ATTRIBUTES| \
> > diff --gita/fs/smb/server/smbacl.cb/fs/smb/server/smbacl.c
> > index5aa7a66334d9..b70ba50f1f10100644
> > ---a/fs/smb/server/smbacl.c
> > +++b/fs/smb/server/smbacl.c
> > @@ -180,7 +180,7 @@ static void mode_to_access_flags(umode_t
> mode,umode_tbits_to_use,
> > * either user or group or other as perbits_to_use
> > */
> > if (mode & 0444)
> > -*pace_flags|=SET_FILE_READ_RIGHTS;
> > +*pace_flags|=SERVER_SET_FILE_READ_RIGHTS;
> > if (mode & 0222)
> >*pace_flags|=FILE_WRITE_RIGHTS;
> > if (mode & 0111)
> > --
> > 2.43.0
> >
>Quoted 4 lines
--
Thanks,
ChenXiaoSong.--
Thanks,
ChenXiaoSong.
Signature · 3 lines
Thanks, Steve
Namjae Jeon
maintainerRe: [PATCH v4 19/24] smb/server: remove create_durable_reconn_req
In reply to [email protected]Quoted 26 lines · On Mon, Oct 27, 2025 at 4:23 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
The fields in struct
create_durable_reconn_reqand structcreate_durableare exactly the same.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb2pdu.h | 12 ------------ 2 files changed, 3 insertions(+), 15 deletions(-)fs/smb/server/smb2pdu.c +1
-1@@ -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 ) {
fs/smb/server/smb2pdu.c static int parse_durable_handle_context(struct ksmbd_work *work, · line 2779
Quoted 5 lines
fs/smb/server/smb2pdu.c +1
-1@@ -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 )) {
Please check the specification, Which structure name is correct? thanks.
Re: [PATCH v4 19/24] smb/server: remove create_durable_reconn_req
They 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 uniformly name them create_durable:
struct create_durable {
...
union {
__u8 Reserved[16]; // DurableRequest of
SMB2_CREATE_DURABLE_HANDLE_REQUEST, A 16-byte field that MUST NOT be used and MUST be reserved. This value MUST be set to 0 by the client and ignored by the server.
struct {
__u64 PersistentFileId; // See 2.2.14.1 SMB2_FILEID
__u64 VolatileFileId; // See 2.2.14.1 SMB2_FILEID
} Fid; // Data of SMB2_CREATE_DURABLE_HANDLE_RECONNECT,
An SMB2_FILEID structure, as specified in section 2.2.14.1, for the open that is being reestablished.
} Data;
} __packed;Thanks,
ChenXiaoSong.
Quoted 34 lines · Namjae Jeon
Quoted 26 lines · On Mon, Oct 27, 2025 at 4:23 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
The fields in struct
create_durable_reconn_reqand structcreate_durableare exactly the same.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/server/smb2pdu.c | 6 +++--- fs/smb/server/smb2pdu.h | 12 ------------ 2 files changed, 3 insertions(+), 15 deletions(-)fs/smb/server/smb2pdu.c +1
-1@@ -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 ) {fs/smb/server/smb2pdu.c static int parse_durable_handle_context(struct ksmbd_work *work, · line 2779
Quoted 5 lines
fs/smb/server/smb2pdu.c +1
-1@@ -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 )) {Please check the specification, Which structure name is correct? thanks.
Re: [PATCH v4 15/24] smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.h
In reply to [email protected]Hi Namjae and Steve,
I couldn’t find the definition of FILE_SYSTEM_POSIX_INFO in any of the following MS documents:
- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.json
Is this structure defined in other MS document?
Quoted 135 lines · On 10/27/25 3:21 PM, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 22 ---------------------- fs/smb/common/smb1pdu.h | 23 +++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 23 ----------------------- 4 files changed, 25 insertions(+), 47 deletions(-)fs/smb/client/cifspdu.h +0
-22@@ -1875,28 +1875,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 0x00000003fs/smb/common/smb1pdu.h +23
-0@@ -327,6 +327,29 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_INFO ;/* size info, level 0x103 */ +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 */ +} __packed FILE_SYSTEM_POSIX_INFO; +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;fs/smb/server/smb2pdu.c +2
-2@@ -5633,14 +5633,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_POSIX_INFORMATION : { -struct filesystem_posix_info *info; +FILE_SYSTEM_POSIX_INFO *info;if (!work->tcon->posix_extensions) {pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" );path_put (&path);return -EOPNOTSUPP ; }else { - info = (struct filesystem_posix_info *)(rsp->Buffer); + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); info->OptimalTransferSize =cpu_to_le32 (stfs.f_bsize); info->BlockSize =cpu_to_le32 (stfs.f_bsize); info->TotalBlocks =cpu_to_le64 (stfs.f_blocks);fs/smb/server/smb_common.h +0
-23@@ -108,29 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct filesystem_posix_info { -/* 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 */ -} __packed; -struct smb_version_ops {u16 (*get_cmd_val)(struct ksmbd_work *swork);int (*init_rsp_hdr)(struct ksmbd_work *swork);
Re: [PATCH v4 15/24] smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.h
Ralph,
Is this link current? or do you have the link to a more current version of the POSIX extensions documentation?
Quoted 154 lines · ChenXiaoSong
Hi Namjae and Steve,
I couldn’t find the definition of
FILE_SYSTEM_POSIX_INFOin any of the following MS documents:- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.jsonIs this structure defined in other MS document?
Quoted 135 lines · On 10/27/25 3:21 PM, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 22 ---------------------- fs/smb/common/smb1pdu.h | 23 +++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 23 ----------------------- 4 files changed, 25 insertions(+), 47 deletions(-)fs/smb/client/cifspdu.h +0
-22@@ -1875,28 +1875,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 0x00000003fs/smb/common/smb1pdu.h +23
-0@@ -327,6 +327,29 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_INFO ;/* size info, level 0x103 */ +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 */ +} __packed FILE_SYSTEM_POSIX_INFO; +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;fs/smb/server/smb2pdu.c +2
-2@@ -5633,14 +5633,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_POSIX_INFORMATION : { -struct filesystem_posix_info *info; +FILE_SYSTEM_POSIX_INFO *info;if (!work->tcon->posix_extensions) {pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" );path_put (&path);return -EOPNOTSUPP ; }else { - info = (struct filesystem_posix_info *)(rsp->Buffer); + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); info->OptimalTransferSize =cpu_to_le32 (stfs.f_bsize); info->BlockSize =cpu_to_le32 (stfs.f_bsize); info->TotalBlocks =cpu_to_le64 (stfs.f_blocks);fs/smb/server/smb_common.h +0
-23@@ -108,29 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct filesystem_posix_info { -/* 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 */ -} __packed; -struct smb_version_ops {u16 (*get_cmd_val)(struct ksmbd_work *swork);int (*init_rsp_hdr)(struct ksmbd_work *swork);
Signature · 3 lines
Thanks, Steve
Re: [PATCH v4 15/24] smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.h
Sorry forgot to attach the link
https://gitlab.com/samba-team/smb3-posix-spec
Quoted 167 lines · Steve French
Ralph,
Is this link current? or do you have the link to a more current version of the POSIX extensions documentation?Quoted 145 lines · ChenXiaoSong
Hi Namjae and Steve,
I couldn’t find the definition of
FILE_SYSTEM_POSIX_INFOin any of the following MS documents:- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.jsonIs this structure defined in other MS document?
Quoted 127 lines · On 10/27/25 3:21 PM, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 22 ---------------------- fs/smb/common/smb1pdu.h | 23 +++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 23 ----------------------- 4 files changed, 25 insertions(+), 47 deletions(-)fs/smb/client/cifspdu.h +0
-22@@ -1875,28 +1875,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 0x00000003fs/smb/common/smb1pdu.h +23
-0@@ -327,6 +327,29 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_INFO ;/* size info, level 0x103 */ +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 */ +} __packed FILE_SYSTEM_POSIX_INFO; +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;fs/smb/server/smb2pdu.c +2
-2@@ -5633,14 +5633,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_POSIX_INFORMATION : { -struct filesystem_posix_info *info; +FILE_SYSTEM_POSIX_INFO *info;if (!work->tcon->posix_extensions) {pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" );path_put (&path);return -EOPNOTSUPP ; }else { - info = (struct filesystem_posix_info *)(rsp->Buffer); + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); info->OptimalTransferSize =cpu_to_le32 (stfs.f_bsize); info->BlockSize =cpu_to_le32 (stfs.f_bsize); info->TotalBlocks =cpu_to_le64 (stfs.f_blocks);fs/smb/server/smb_common.h +0
-18@@ -108,29 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct filesystem_posix_info { -/* 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;Quoted 9 lines
fs/smb/server/smb_common.h struct file_id_both_directory_info { · line 113
Quoted 8 lines
fs/smb/server/smb_common.h +0
-5-__le64 FileSysIdentifier;/* fsid */ -/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ -/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ -} __packed; -struct smb_version_ops {u16 (*get_cmd_val)(struct ksmbd_work *swork);int (*init_rsp_hdr)(struct ksmbd_work *swork);--
Thanks,Steve
Signature · 3 lines
Thanks, Steve
Re: [PATCH v4 15/24] smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.h
Got it, thank you for your answer.
Thanks,
ChenXiaoSong.
Quoted 175 lines · Steve French
Sorry forgot to attach the link
https://gitlab.com/samba-team/smb3-posix-spec
Quoted 167 lines · Steve French
Ralph,
Is this link current? or do you have the link to a more current version of the POSIX extensions documentation?Quoted 145 lines · ChenXiaoSong
Hi Namjae and Steve,
I couldn’t find the definition of
FILE_SYSTEM_POSIX_INFOin any of the following MS documents:- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.jsonIs this structure defined in other MS document?
Quoted 127 lines · On 10/27/25 3:21 PM, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 22 ---------------------- fs/smb/common/smb1pdu.h | 23 +++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 23 ----------------------- 4 files changed, 25 insertions(+), 47 deletions(-)fs/smb/client/cifspdu.h +0
-22@@ -1875,28 +1875,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 0x00000003fs/smb/common/smb1pdu.h +23
-0@@ -327,6 +327,29 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_INFO ;/* size info, level 0x103 */ +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 */ +} __packed FILE_SYSTEM_POSIX_INFO; +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;fs/smb/server/smb2pdu.c +2
-2@@ -5633,14 +5633,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_POSIX_INFORMATION : { -struct filesystem_posix_info *info; +FILE_SYSTEM_POSIX_INFO *info;if (!work->tcon->posix_extensions) {pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" );path_put (&path);return -EOPNOTSUPP ; }else { - info = (struct filesystem_posix_info *)(rsp->Buffer); + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); info->OptimalTransferSize =cpu_to_le32 (stfs.f_bsize); info->BlockSize =cpu_to_le32 (stfs.f_bsize); info->TotalBlocks =cpu_to_le64 (stfs.f_blocks);fs/smb/server/smb_common.h +0
-18@@ -108,29 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct filesystem_posix_info { -/* 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;Quoted 9 lines
fs/smb/server/smb_common.h struct file_id_both_directory_info { · line 113
Quoted 8 lines
fs/smb/server/smb_common.h +0
-5-__le64 FileSysIdentifier;/* fsid */ -/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ -/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ -} __packed; -struct smb_version_ops {u16 (*get_cmd_val)(struct ksmbd_work *swork);int (*init_rsp_hdr)(struct ksmbd_work *swork);--
Thanks,Steve
Re: [PATCH v4 15/24] smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.h
In reply to Steve FrenchThis GitLab repository seems to be more up to date than the one on samba.org: https://git.samba.org/?p=slow/smb3_posix_spec.git;a=shortlog
Thanks,
ChenXiaoSong.
Quoted 175 lines · Steve French
Sorry forgot to attach the link
https://gitlab.com/samba-team/smb3-posix-spec
Quoted 167 lines · Steve French
Ralph,
Is this link current? or do you have the link to a more current version of the POSIX extensions documentation?Quoted 145 lines · ChenXiaoSong
Hi Namjae and Steve,
I couldn’t find the definition of
FILE_SYSTEM_POSIX_INFOin any of the following MS documents:- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.jsonIs this structure defined in other MS document?
Quoted 127 lines · On 10/27/25 3:21 PM, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 22 ---------------------- fs/smb/common/smb1pdu.h | 23 +++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 23 ----------------------- 4 files changed, 25 insertions(+), 47 deletions(-)fs/smb/client/cifspdu.h +0
-22@@ -1875,28 +1875,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 0x00000003fs/smb/common/smb1pdu.h +23
-0@@ -327,6 +327,29 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_INFO ;/* size info, level 0x103 */ +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 */ +} __packed FILE_SYSTEM_POSIX_INFO; +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;fs/smb/server/smb2pdu.c +2
-2@@ -5633,14 +5633,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_POSIX_INFORMATION : { -struct filesystem_posix_info *info; +FILE_SYSTEM_POSIX_INFO *info;if (!work->tcon->posix_extensions) {pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" );path_put (&path);return -EOPNOTSUPP ; }else { - info = (struct filesystem_posix_info *)(rsp->Buffer); + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); info->OptimalTransferSize =cpu_to_le32 (stfs.f_bsize); info->BlockSize =cpu_to_le32 (stfs.f_bsize); info->TotalBlocks =cpu_to_le64 (stfs.f_blocks);fs/smb/server/smb_common.h +0
-18@@ -108,29 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct filesystem_posix_info { -/* 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;Quoted 9 lines
fs/smb/server/smb_common.h struct file_id_both_directory_info { · line 113
Quoted 8 lines
fs/smb/server/smb_common.h +0
-5-__le64 FileSysIdentifier;/* fsid */ -/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ -/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ -} __packed; -struct smb_version_ops {u16 (*get_cmd_val)(struct ksmbd_work *swork);int (*init_rsp_hdr)(struct ksmbd_work *swork);--
Thanks,Steve
Re: [PATCH v4 15/24] smb: move FILE_SYSTEM_POSIX_INFO to common/smb1pdu.h
Yes - agreed. Ralph could give more details on that
Quoted 184 lines · ChenXiaoSong
This GitLab repository seems to be more up to date than the one on samba.org: https://git.samba.org/?p=slow/smb3_posix_spec.git;a=shortlog
Thanks,
ChenXiaoSong.Quoted 175 lines · Steve French
Sorry forgot to attach the link
https://gitlab.com/samba-team/smb3-posix-spec
Quoted 167 lines · Steve French
Ralph,
Is this link current? or do you have the link to a more current version of the POSIX extensions documentation?Quoted 145 lines · ChenXiaoSong
Hi Namjae and Steve,
I couldn’t find the definition of
FILE_SYSTEM_POSIX_INFOin any of the following MS documents:- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.jsonIs this structure defined in other MS document?
Quoted 127 lines · On 10/27/25 3:21 PM, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
Rename "struct
filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO", then move duplicate definitions to common header file.Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/client/cifspdu.h | 22 ---------------------- fs/smb/common/smb1pdu.h | 23 +++++++++++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb_common.h | 23 ----------------------- 4 files changed, 25 insertions(+), 47 deletions(-)fs/smb/client/cifspdu.h +0
-22@@ -1875,28 +1875,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 0x00000003fs/smb/common/smb1pdu.h +23
-0@@ -327,6 +327,29 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_INFO ;/* size info, level 0x103 */ +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 */ +} __packed FILE_SYSTEM_POSIX_INFO; +/* See MS-CIFS 2.2.8.2.5 */ typedef struct { __le32 DeviceType;fs/smb/server/smb2pdu.c +2
-2@@ -5633,14 +5633,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, }case FS_POSIX_INFORMATION : { -struct filesystem_posix_info *info; +FILE_SYSTEM_POSIX_INFO *info;if (!work->tcon->posix_extensions) {pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" );path_put (&path);return -EOPNOTSUPP ; }else { - info = (struct filesystem_posix_info *)(rsp->Buffer); + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); info->OptimalTransferSize =cpu_to_le32 (stfs.f_bsize); info->BlockSize =cpu_to_le32 (stfs.f_bsize); info->TotalBlocks =cpu_to_le64 (stfs.f_blocks);fs/smb/server/smb_common.h +0
-18@@ -108,29 +108,6 @@ struct file_id_both_directory_info {char FileName[]; } __packed; -struct filesystem_posix_info { -/* 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;Quoted 9 lines
fs/smb/server/smb_common.h struct file_id_both_directory_info { · line 113
Quoted 8 lines
fs/smb/server/smb_common.h +0
-5-__le64 FileSysIdentifier;/* fsid */ -/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ -/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ -} __packed; -struct smb_version_ops {u16 (*get_cmd_val)(struct ksmbd_work *swork);int (*init_rsp_hdr)(struct ksmbd_work *swork);--
Thanks,Steve
Signature · 3 lines
Thanks, Steve
ChenXiaoSong
reviewerRe: [PATCH v4 05/24] smb: move some duplicate definitions to common/smb1pdu.h
In reply to [email protected]Greetings,
I couldn't find the definition of ATTR_VOLUME and ATTR_DEVICE in any of the following documents:
- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.json
- smb3-posix-spec: https://gitlab.com/samba-team/smb3-posix-spec
Are these two macro definitions (ATTR_VOLUME and ATTR_DEVICE) defined in other documents?
PS: The following are the document locations I found for the File Attribute flags:
/*
* File Attribute flags
*/
#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 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 0x01000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_BACKUP_SEMANTICS 0x02000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_DELETE_ON_CLOSE 0x04000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_SEQUENTIAL_SCAN 0x08000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_RANDOM_ACCESS 0x10000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_NO_BUFFERING 0x20000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_WRITE_THROUGH 0x80000000 /* See MS-CIFS 2.2.1.2.3 */
Thanks,
ChenXiaoSong.
Quoted 506 lines · On 10/27/25 15:12, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to new common header file.
Signed-off-by ChenXiaoSong <[email protected]>Suggested-by Namjae Jeon <[email protected]>--- fs/smb/client/cifspdu.h | 152 +--------------------------------- fs/smb/common/smb1pdu.h | 163 +++++++++++++++++++++++++++++++++++++ fs/smb/server/smb_common.h | 79 +----------------- 3 files changed, 165 insertions(+), 229 deletions(-)create mode 100644
fs/smb/common/smb1pdu.hfs/smb/client/cifspdu.h +1
-151@@ -12,44 +12,12 @@#include <net/sock.h> #include <linux/unaligned.h> #include "../common/smbfsctl.h" +#include "../common/smb1pdu.h" #define CIFS_PROT 0#define POSIX_PROT (CIFS_PROT+1)#define BAD_PROT 0xFFFF -/* SMB command codes: -* 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 -*/ -#define SMB_COM_CREATE_DIRECTORY 0x00/* trivial response */ -#define SMB_COM_DELETE_DIRECTORY 0x01/* trivial response */ -#define SMB_COM_CLOSE 0x04/* triv req/rsp, timestamp ignored */ -#define SMB_COM_FLUSH 0x05/* triv req/rsp */ -#define SMB_COM_DELETE 0x06/* trivial response */ -#define SMB_COM_RENAME 0x07/* trivial response */ -#define SMB_COM_QUERY_INFORMATION 0x08/* aka getattr */ -#define SMB_COM_SETATTR 0x09/* trivial response */ -#define SMB_COM_LOCKING_ANDX 0x24/* trivial response */ -#define SMB_COM_COPY 0x29/* trivial rsp, fail filename ignrd*/ -#define SMB_COM_ECHO 0x2B/* echo request */ -#define SMB_COM_OPEN_ANDX 0x2D/* Legacy open for old servers */ -#define SMB_COM_READ_ANDX 0x2E -#define SMB_COM_WRITE_ANDX 0x2F -#define SMB_COM_TRANSACTION2 0x32 -#define SMB_COM_TRANSACTION2_SECONDARY 0x33 -#define SMB_COM_FIND_CLOSE2 0x34/* trivial response */ -#define SMB_COM_TREE_DISCONNECT 0x71/* trivial response */ -#define SMB_COM_NEGOTIATE 0x72 -#define SMB_COM_SESSION_SETUP_ANDX 0x73 -#define SMB_COM_LOGOFF_ANDX 0x74/* trivial response */ -#define SMB_COM_TREE_CONNECT_ANDX 0x75 -#define SMB_COM_NT_TRANSACT 0xA0 -#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 -#define SMB_COM_NT_CREATE_ANDX 0xA2 -#define SMB_COM_NT_CANCEL 0xA4/* no response */ -#define SMB_COM_NT_RENAME 0xA5/* trivial response */ -/* Transact2 subcommand codes */ #define TRANS2_OPEN 0x00#define TRANS2_FIND_FIRST 0x01@@ -86,7 +54,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 */ @@ -150,36 +117,6 @@#define SMBOPEN_OTRUNC 0x0002#define SMBOPEN_OAPPEND 0x0001 -/* -* SMB flag definitions -*/ -#define SMBFLG_EXTD_LOCK 0x01/* server supports lock-read write-unlock smb */ -#define SMBFLG_RCV_POSTED 0x02/* obsolete */ -#define SMBFLG_RSVD 0x04 -#define SMBFLG_CASELESS 0x08/* all pathnames treated as caseless (off -implies case sensitive file handling request) */ -#define SMBFLG_CANONICAL_PATH_FORMAT 0x10/* obsolete */ -#define SMBFLG_OLD_OPLOCK 0x20/* obsolete */ -#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40/* obsolete */ -#define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ - -/* -* SMB flag2 definitions -*/ -#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)/* can send long (non-8.3) -path names in response */ -#define SMBFLG2_KNOWS_EAS cpu_to_le16(2) -#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4) -#define SMBFLG2_COMPRESSED (8) -#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10) -#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) -#define SMBFLG2_REPARSE_PATH (0x400) -#define SMBFLG2_EXT_SEC cpu_to_le16(0x800) -#define SMBFLG2_DFS cpu_to_le16(0x1000) -#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000) -#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 @@ -292,7 +229,6 @@#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ | READ_CONTROL | SYNCHRONIZE) -/* * Invalid readdir handle */ @@ -322,33 +258,6 @@#define CIFS_ALIAS_TYPE_FILE 0x0001#define CIFS_SHARE_TYPE_FILE 0x0000 -/* -* 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 -/* ShareAccess flags */ #define FILE_NO_SHARE 0x00000000#define FILE_SHARE_READ 0x00000001@@ -417,38 +326,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)@@ -2239,33 +2116,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/smb1pdu.h new file +163
-0@@ -0,0 +1,163 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ +/* +* +* Copyright (c) International Business Machines Corp., 2002,2009 +* Author(s): Steve French ([email protected]) +* +*/ + +#ifndef _COMMON_SMB1_PDU_H +#define _COMMON_SMB1_PDU_H + +/* SMB command codes: +* 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 +*/ +#define SMB_COM_CREATE_DIRECTORY 0x00/* trivial response */ +#define SMB_COM_DELETE_DIRECTORY 0x01/* trivial response */ +#define SMB_COM_CLOSE 0x04/* triv req/rsp, timestamp ignored */ +#define SMB_COM_FLUSH 0x05/* triv req/rsp */ +#define SMB_COM_DELETE 0x06/* trivial response */ +#define SMB_COM_RENAME 0x07/* trivial response */ +#define SMB_COM_QUERY_INFORMATION 0x08/* aka getattr */ +#define SMB_COM_SETATTR 0x09/* trivial response */ +#define SMB_COM_LOCKING_ANDX 0x24/* trivial response */ +#define SMB_COM_COPY 0x29/* trivial rsp, fail filename ignrd*/ +#define SMB_COM_ECHO 0x2B/* echo request */ +#define SMB_COM_OPEN_ANDX 0x2D/* Legacy open for old servers */ +#define SMB_COM_READ_ANDX 0x2E +#define SMB_COM_WRITE_ANDX 0x2F +#define SMB_COM_TRANSACTION2 0x32 +#define SMB_COM_TRANSACTION2_SECONDARY 0x33 +#define SMB_COM_FIND_CLOSE2 0x34/* trivial response */ +#define SMB_COM_TREE_DISCONNECT 0x71/* trivial response */ +#define SMB_COM_NEGOTIATE 0x72 +#define SMB_COM_SESSION_SETUP_ANDX 0x73 +#define SMB_COM_LOGOFF_ANDX 0x74/* trivial response */ +#define SMB_COM_TREE_CONNECT_ANDX 0x75 +#define SMB_COM_NT_TRANSACT 0xA0 +#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 +#define SMB_COM_NT_CREATE_ANDX 0xA2 +#define SMB_COM_NT_CANCEL 0xA4/* no response */ +#define SMB_COM_NT_RENAME 0xA5/* trivial response */ + +#define MAX_CIFS_SMALL_BUFFER_SIZE 448/* big enough for most */ + +/* +* SMB flag definitions +*/ +#define SMBFLG_EXTD_LOCK 0x01/* server supports lock-read write-unlock smb */ +#define SMBFLG_RCV_POSTED 0x02/* obsolete */ +#define SMBFLG_RSVD 0x04 +#define SMBFLG_CASELESS 0x08/* all pathnames treated as caseless (off +implies case sensitive file handling request) */ +#define SMBFLG_CANONICAL_PATH_FORMAT 0x10/* obsolete */ +#define SMBFLG_OLD_OPLOCK 0x20/* obsolete */ +#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40/* obsolete */ +#define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ + +/* +* SMB flag2 definitions +*/ +#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)/* can send long (non-8.3) +path names in response */ +#define SMBFLG2_KNOWS_EAS cpu_to_le16(2) +#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4) +#define SMBFLG2_COMPRESSED (8) +#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10) +#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) +#define SMBFLG2_REPARSE_PATH (0x400) +#define SMBFLG2_EXT_SEC cpu_to_le16(0x800) +#define SMBFLG2_DFS cpu_to_le16(0x1000) +#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000) +#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000) +#define SMBFLG2_UNICODE cpu_to_le16(0x8000) + +/* +* 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 + +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; + +/* 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 + +#endif /* _COMMON_SMB1_PDU_H */ fs/smb/server/smb_common.h +1
-78@@ -11,6 +11,7 @@#include "glob.h" #include "nterr.h" #include "../common/smbglob.h" +#include "../common/smb1pdu.h" #include "../common/smb2pdu.h" #include "smb2pdu.h" @@ -29,8 +30,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. */ @@ -39,44 +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 - -/* 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 -#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 */ @@ -151,46 +112,8 @@ FILE_EXECUTE | FILE_DELETE_CHILD | \ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) -#define SMB_COM_NEGOTIATE 0x72#define SMB1_CLIENT_GUID_SIZE (16) -#define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ - -#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) -#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 v4 5/24 smb: move some duplicate definitions to common/smb1pdu.h
Use @linux.dev email to forward, to avoid the possibility of the email not being received.
-------- Forwarded Message --------
Subject: Re: [PATCH v4 05/24] smb: move some duplicate definitions to common/smb1pdu.h
Date: Fri, 31 Oct 2025 17:50:17 +0800
From: ChenXiaoSong <[email protected]>
To: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], Ralph Böhme <[email protected]>
CC: [email protected], [email protected]
Greetings,
I couldn't find the definition of ATTR_VOLUME and ATTR_DEVICE in any of the following documents:
- MS-FSCC:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-fscc%2Ftoc.json
- MS-CIFS:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-cifs%2Ftoc.json
- MS-SMB:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb%2Ftoc.json
- MS-SMB2:
https://learn.microsoft.com/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fopenspecs%2Fwindows_protocols%2Fms-smb2%2Ftoc.json
- smb3-posix-spec: https://gitlab.com/samba-team/smb3-posix-spec
Are these two macro definitions (ATTR_VOLUME and ATTR_DEVICE) defined in other documents?
PS: The following are the document locations I found for the File Attribute flags:
/*
* File Attribute flags
*/
#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 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 0x01000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_BACKUP_SEMANTICS 0x02000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_DELETE_ON_CLOSE 0x04000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_SEQUENTIAL_SCAN 0x08000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_RANDOM_ACCESS 0x10000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_NO_BUFFERING 0x20000000 /* See MS-CIFS 2.2.1.2.3 */ #define ATTR_WRITE_THROUGH 0x80000000 /* See MS-CIFS 2.2.1.2.3 */
Thanks,
ChenXiaoSong.
Quoted 506 lines · On 10/27/25 15:12, [email protected] wrote:
From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to new common header file.
Signed-off-by ChenXiaoSong <[email protected]>Suggested-by Namjae Jeon <[email protected]>--- fs/smb/client/cifspdu.h | 152 +--------------------------------- fs/smb/common/smb1pdu.h | 163 +++++++++++++++++++++++++++++++++++++ fs/smb/server/smb_common.h | 79 +----------------- 3 files changed, 165 insertions(+), 229 deletions(-)create mode 100644
fs/smb/common/smb1pdu.hfs/smb/client/cifspdu.h +1
-151@@ -12,44 +12,12 @@#include <net/sock.h> #include <linux/unaligned.h> #include "../common/smbfsctl.h" +#include "../common/smb1pdu.h" #define CIFS_PROT 0#define POSIX_PROT (CIFS_PROT+1)#define BAD_PROT 0xFFFF -/* SMB command codes: -* 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 -*/ -#define SMB_COM_CREATE_DIRECTORY 0x00/* trivial response */ -#define SMB_COM_DELETE_DIRECTORY 0x01/* trivial response */ -#define SMB_COM_CLOSE 0x04/* triv req/rsp, timestamp ignored */ -#define SMB_COM_FLUSH 0x05/* triv req/rsp */ -#define SMB_COM_DELETE 0x06/* trivial response */ -#define SMB_COM_RENAME 0x07/* trivial response */ -#define SMB_COM_QUERY_INFORMATION 0x08/* aka getattr */ -#define SMB_COM_SETATTR 0x09/* trivial response */ -#define SMB_COM_LOCKING_ANDX 0x24/* trivial response */ -#define SMB_COM_COPY 0x29/* trivial rsp, fail filename ignrd*/ -#define SMB_COM_ECHO 0x2B/* echo request */ -#define SMB_COM_OPEN_ANDX 0x2D/* Legacy open for old servers */ -#define SMB_COM_READ_ANDX 0x2E -#define SMB_COM_WRITE_ANDX 0x2F -#define SMB_COM_TRANSACTION2 0x32 -#define SMB_COM_TRANSACTION2_SECONDARY 0x33 -#define SMB_COM_FIND_CLOSE2 0x34/* trivial response */ -#define SMB_COM_TREE_DISCONNECT 0x71/* trivial response */ -#define SMB_COM_NEGOTIATE 0x72 -#define SMB_COM_SESSION_SETUP_ANDX 0x73 -#define SMB_COM_LOGOFF_ANDX 0x74/* trivial response */ -#define SMB_COM_TREE_CONNECT_ANDX 0x75 -#define SMB_COM_NT_TRANSACT 0xA0 -#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 -#define SMB_COM_NT_CREATE_ANDX 0xA2 -#define SMB_COM_NT_CANCEL 0xA4/* no response */ -#define SMB_COM_NT_RENAME 0xA5/* trivial response */ -/* Transact2 subcommand codes */ #define TRANS2_OPEN 0x00#define TRANS2_FIND_FIRST 0x01@@ -86,7 +54,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 */ @@ -150,36 +117,6 @@#define SMBOPEN_OTRUNC 0x0002#define SMBOPEN_OAPPEND 0x0001 -/* -* SMB flag definitions -*/ -#define SMBFLG_EXTD_LOCK 0x01/* server supports lock-read write-unlock smb */ -#define SMBFLG_RCV_POSTED 0x02/* obsolete */ -#define SMBFLG_RSVD 0x04 -#define SMBFLG_CASELESS 0x08/* all pathnames treated as caseless (off -implies case sensitive file handling request) */ -#define SMBFLG_CANONICAL_PATH_FORMAT 0x10/* obsolete */ -#define SMBFLG_OLD_OPLOCK 0x20/* obsolete */ -#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40/* obsolete */ -#define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ - -/* -* SMB flag2 definitions -*/ -#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)/* can send long (non-8.3) -path names in response */ -#define SMBFLG2_KNOWS_EAS cpu_to_le16(2) -#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4) -#define SMBFLG2_COMPRESSED (8) -#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10) -#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) -#define SMBFLG2_REPARSE_PATH (0x400) -#define SMBFLG2_EXT_SEC cpu_to_le16(0x800) -#define SMBFLG2_DFS cpu_to_le16(0x1000) -#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000) -#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 @@ -292,7 +229,6 @@#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ | READ_CONTROL | SYNCHRONIZE) -/* * Invalid readdir handle */ @@ -322,33 +258,6 @@#define CIFS_ALIAS_TYPE_FILE 0x0001#define CIFS_SHARE_TYPE_FILE 0x0000 -/* -* 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 -/* ShareAccess flags */ #define FILE_NO_SHARE 0x00000000#define FILE_SHARE_READ 0x00000001@@ -417,38 +326,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)@@ -2239,33 +2116,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/smb1pdu.h new file +163
-0@@ -0,0 +1,163 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ +/* +* +* Copyright (c) International Business Machines Corp., 2002,2009 +* Author(s): Steve French ([email protected]) +* +*/ + +#ifndef _COMMON_SMB1_PDU_H +#define _COMMON_SMB1_PDU_H + +/* SMB command codes: +* 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 +*/ +#define SMB_COM_CREATE_DIRECTORY 0x00/* trivial response */ +#define SMB_COM_DELETE_DIRECTORY 0x01/* trivial response */ +#define SMB_COM_CLOSE 0x04/* triv req/rsp, timestamp ignored */ +#define SMB_COM_FLUSH 0x05/* triv req/rsp */ +#define SMB_COM_DELETE 0x06/* trivial response */ +#define SMB_COM_RENAME 0x07/* trivial response */ +#define SMB_COM_QUERY_INFORMATION 0x08/* aka getattr */ +#define SMB_COM_SETATTR 0x09/* trivial response */ +#define SMB_COM_LOCKING_ANDX 0x24/* trivial response */ +#define SMB_COM_COPY 0x29/* trivial rsp, fail filename ignrd*/ +#define SMB_COM_ECHO 0x2B/* echo request */ +#define SMB_COM_OPEN_ANDX 0x2D/* Legacy open for old servers */ +#define SMB_COM_READ_ANDX 0x2E +#define SMB_COM_WRITE_ANDX 0x2F +#define SMB_COM_TRANSACTION2 0x32 +#define SMB_COM_TRANSACTION2_SECONDARY 0x33 +#define SMB_COM_FIND_CLOSE2 0x34/* trivial response */ +#define SMB_COM_TREE_DISCONNECT 0x71/* trivial response */ +#define SMB_COM_NEGOTIATE 0x72 +#define SMB_COM_SESSION_SETUP_ANDX 0x73 +#define SMB_COM_LOGOFF_ANDX 0x74/* trivial response */ +#define SMB_COM_TREE_CONNECT_ANDX 0x75 +#define SMB_COM_NT_TRANSACT 0xA0 +#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 +#define SMB_COM_NT_CREATE_ANDX 0xA2 +#define SMB_COM_NT_CANCEL 0xA4/* no response */ +#define SMB_COM_NT_RENAME 0xA5/* trivial response */ + +#define MAX_CIFS_SMALL_BUFFER_SIZE 448/* big enough for most */ + +/* +* SMB flag definitions +*/ +#define SMBFLG_EXTD_LOCK 0x01/* server supports lock-read write-unlock smb */ +#define SMBFLG_RCV_POSTED 0x02/* obsolete */ +#define SMBFLG_RSVD 0x04 +#define SMBFLG_CASELESS 0x08/* all pathnames treated as caseless (off +implies case sensitive file handling request) */ +#define SMBFLG_CANONICAL_PATH_FORMAT 0x10/* obsolete */ +#define SMBFLG_OLD_OPLOCK 0x20/* obsolete */ +#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40/* obsolete */ +#define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ + +/* +* SMB flag2 definitions +*/ +#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)/* can send long (non-8.3) +path names in response */ +#define SMBFLG2_KNOWS_EAS cpu_to_le16(2) +#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4) +#define SMBFLG2_COMPRESSED (8) +#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10) +#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) +#define SMBFLG2_REPARSE_PATH (0x400) +#define SMBFLG2_EXT_SEC cpu_to_le16(0x800) +#define SMBFLG2_DFS cpu_to_le16(0x1000) +#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000) +#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000) +#define SMBFLG2_UNICODE cpu_to_le16(0x8000) + +/* +* 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 + +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; + +/* 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 + +#endif /* _COMMON_SMB1_PDU_H */ fs/smb/server/smb_common.h +1
-78@@ -11,6 +11,7 @@#include "glob.h" #include "nterr.h" #include "../common/smbglob.h" +#include "../common/smb1pdu.h" #include "../common/smb2pdu.h" #include "smb2pdu.h" @@ -29,8 +30,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. */ @@ -39,44 +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 - -/* 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 -#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 */ @@ -151,46 +112,8 @@ FILE_EXECUTE | FILE_DELETE_CHILD | \ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) -#define SMB_COM_NEGOTIATE 0x72#define SMB1_CLIENT_GUID_SIZE (16) -#define SMBFLG_RESPONSE 0x80/* this PDU is a response from server */ - -#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) -#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;