fs/smb/client/smb1transport.c
Source file repositories/reference/linux-study-clean/fs/smb/client/smb1transport.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/smb1transport.c- Extension
.c- Size
- 15994 bytes
- Lines
- 569
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/list.hlinux/gfp.hlinux/wait.hlinux/net.hlinux/delay.hlinux/freezer.hlinux/tcp.hlinux/bvec.hlinux/highmem.hlinux/uaccess.hlinux/processor.hlinux/mempool.hlinux/sched/signal.hlinux/task_io_accounting_ops.hcifsglob.hcifsproto.hsmb1proto.hsmb2proto.hcifs_debug.hsmbdirect.hcompress.h
Detected Declarations
function Copyrightfunction allocate_midfunction cifs_setup_async_requestfunction codefunction cifs_check_receivefunction cifs_setup_requestfunction SendReceive2function SendReceivefunction check2ndT2function coalesce_t2function cifs_check_trans2function check_smb_hdrfunction checkSMB
Annotated Snippet
if (in_buf->Command != SMB_COM_LOGOFF_ANDX) {
spin_unlock(&ses->ses_lock);
return -EAGAIN;
}
/* else ok - we are shutting down session */
}
spin_unlock(&ses->ses_lock);
*ppmidQ = alloc_mid(in_buf, ses->server);
if (*ppmidQ == NULL)
return -ENOMEM;
spin_lock(&ses->server->mid_queue_lock);
list_add_tail(&(*ppmidQ)->qhead, &ses->server->pending_mid_q);
spin_unlock(&ses->server->mid_queue_lock);
return 0;
}
struct mid_q_entry *
cifs_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
{
int rc;
struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
struct mid_q_entry *mid;
/* enable signing if server requires it */
if (server->sign)
hdr->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
mid = alloc_mid(hdr, server);
if (mid == NULL)
return ERR_PTR(-ENOMEM);
rc = cifs_sign_rqst(rqst, server, &mid->sequence_number);
if (rc) {
release_mid(server, mid);
return ERR_PTR(rc);
}
return mid;
}
/*
*
* Send an SMB Request. No response info (other than return code)
* needs to be parsed.
*
* flags indicate the type of request buffer and how long to wait
* and whether to log NT STATUS code (error) before mapping it to POSIX error
*
*/
int
SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
char *in_buf, unsigned int in_len, int flags)
{
int rc;
struct kvec iov[1];
struct kvec rsp_iov;
int resp_buf_type;
iov[0].iov_base = in_buf;
iov[0].iov_len = in_len;
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);
return rc;
}
int
cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
bool log_error)
{
unsigned int len = mid->response_pdu_len;
dump_smb(mid->resp_buf, min_t(u32, 92, len));
/* convert the length into a more usable form */
if (server->sign) {
struct kvec iov[1];
int rc = 0;
struct smb_rqst rqst = { .rq_iov = iov,
.rq_nvec = ARRAY_SIZE(iov) };
iov[0].iov_base = mid->resp_buf;
iov[0].iov_len = len;
rc = cifs_verify_signature(&rqst, server,
mid->sequence_number);
if (rc) {
cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
Annotation
- Immediate include surface: `linux/fs.h`, `linux/list.h`, `linux/gfp.h`, `linux/wait.h`, `linux/net.h`, `linux/delay.h`, `linux/freezer.h`, `linux/tcp.h`.
- Detected declarations: `function Copyright`, `function allocate_mid`, `function cifs_setup_async_request`, `function code`, `function cifs_check_receive`, `function cifs_setup_request`, `function SendReceive2`, `function SendReceive`, `function check2ndT2`, `function coalesce_t2`.
- 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.