fs/smb/server/smb2pdu.c
Source file repositories/reference/linux-study-clean/fs/smb/server/smb2pdu.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/smb2pdu.c- Extension
.c- Size
- 257467 bytes
- Lines
- 9538
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/utils.hlinux/inetdevice.hnet/addrconf.hlinux/syscalls.hlinux/namei.hlinux/statfs.hlinux/ethtool.hlinux/falloc.hlinux/mount.hlinux/filelock.hlinux/fileattr.hglob.h../common/smbfsctl.hoplock.hsmbacl.hauth.hasn1.hconnection.htransport_ipc.htransport_rdma.hvfs.hvfs_cache.hmisc.hserver.hsmb_common.h../common/smb2status.hksmbd_work.hmgmt/user_config.hmgmt/share_config.hmgmt/tree_connect.hmgmt/user_session.hmgmt/ksmbd_ida.h
Detected Declarations
struct durable_infostruct smb2_query_dir_privatefunction Copyrightfunction check_session_idfunction smb2_get_ksmbd_tconfunction smb2_set_err_rspfunction is_smb2_neg_cmdfunction is_smb2_rspfunction get_smb2_cmd_valfunction set_smb2_rsp_statusfunction init_smb2_neg_rspfunction smb2_set_rsp_creditsfunction init_chained_smb2_rspfunction is_chained_smb2_messagefunction init_smb2_rsp_hdrfunction smb2_allocate_rsp_buffunction smb2_check_user_sessionfunction smb2_get_namefunction setup_async_workfunction release_async_workfunction smb2_send_interim_respfunction smb2_get_reparse_tag_special_filefunction smb2_get_dos_modefunction build_preauth_ctxtfunction build_encrypt_ctxtfunction build_compress_ctxtfunction build_sign_cap_ctxtfunction build_posix_ctxtfunction assemble_neg_contextsfunction decode_preauth_ctxtfunction decode_encrypt_ctxtfunction smb3_encryption_negotiatedfunction decode_compress_ctxtfunction decode_sign_cap_ctxtfunction deassemble_neg_contextsfunction smb2_handle_negotiatefunction alloc_preauth_hashfunction generate_preauth_hashfunction decode_negotiation_tokenfunction ntlm_negotiatefunction ntlm_authenticatefunction krb5_authenticatefunction krb5_authenticatefunction smb2_sess_setupfunction smb2_tree_connectfunction smb2_create_open_flagsfunction smb2_tree_disconnectfunction smb2_session_logoff
Annotated Snippet
struct durable_info {
struct ksmbd_file *fp;
unsigned short int type;
bool persistent;
bool reconnected;
unsigned int timeout;
char *CreateGuid;
};
static int parse_durable_handle_context(struct ksmbd_work *work,
struct smb2_create_req *req,
struct lease_ctx_info *lc,
struct durable_info *dh_info)
{
struct ksmbd_conn *conn = work->conn;
struct create_context *context;
int dh_idx, err = 0;
u64 persistent_id = 0;
int req_op_level;
static const char * const durable_arr[] = {"DH2C", "DHnC", "DH2Q", "DHnQ"};
req_op_level = req->RequestedOplockLevel;
for (dh_idx = DURABLE_RECONN_V2; dh_idx <= ARRAY_SIZE(durable_arr);
dh_idx++) {
context = smb2_find_context_vals(req, durable_arr[dh_idx - 1], 4);
if (IS_ERR(context)) {
err = PTR_ERR(context);
goto out;
}
if (!context)
continue;
switch (dh_idx) {
case DURABLE_RECONN_V2:
{
struct create_durable_handle_reconnect_v2 *recon_v2;
if (dh_info->type == DURABLE_RECONN ||
dh_info->type == DURABLE_REQ_V2) {
err = -EINVAL;
goto out;
}
if (le16_to_cpu(context->DataOffset) +
le32_to_cpu(context->DataLength) <
sizeof(struct create_durable_handle_reconnect_v2)) {
err = -EINVAL;
goto out;
}
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");
err = -EBADF;
goto out;
}
if (memcmp(dh_info->fp->create_guid, recon_v2->dcontext.CreateGuid,
SMB2_CREATE_GUID_SIZE)) {
err = -EBADF;
ksmbd_put_durable_fd(dh_info->fp);
goto out;
}
dh_info->type = dh_idx;
dh_info->reconnected = true;
ksmbd_debug(SMB,
"reconnect v2 Persistent-id from reconnect = %llu\n",
persistent_id);
break;
}
case DURABLE_RECONN:
{
create_durable_reconn_t *recon;
if (dh_info->type == DURABLE_RECONN_V2 ||
dh_info->type == DURABLE_REQ_V2) {
err = -EINVAL;
goto out;
}
if (le16_to_cpu(context->DataOffset) +
le32_to_cpu(context->DataLength) <
sizeof(create_durable_reconn_t)) {
err = -EINVAL;
goto out;
}
Annotation
- Immediate include surface: `crypto/utils.h`, `linux/inetdevice.h`, `net/addrconf.h`, `linux/syscalls.h`, `linux/namei.h`, `linux/statfs.h`, `linux/ethtool.h`, `linux/falloc.h`.
- Detected declarations: `struct durable_info`, `struct smb2_query_dir_private`, `function Copyright`, `function check_session_id`, `function smb2_get_ksmbd_tcon`, `function smb2_set_err_rsp`, `function is_smb2_neg_cmd`, `function is_smb2_rsp`, `function get_smb2_cmd_val`, `function set_smb2_rsp_status`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.