fs/smb/client/smb1maperror.c
Source file repositories/reference/linux-study-clean/fs/smb/client/smb1maperror.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/smb1maperror.c- Extension
.c- Size
- 7975 bytes
- Lines
- 287
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bsearch.hcifsproto.hsmb1proto.hsmberr.hnterr.hcifs_debug.hsmb1_err_dos_map.csmb1_err_srv_map.csmb1_mapping_table.c
Detected Declarations
function Copyrightfunction ntstatus_to_dos_cmpfunction search_ntstatus_to_dos_mapfunction search_mapping_table_ERRDOSfunction search_mapping_table_ERRSRVfunction map_smb_to_linux_errorfunction map_and_check_smb_errorfunction smb1_init_maperrorfunction search_ntstatus_to_dos_map_testfunction search_mapping_table_ERRDOS_testfunction search_mapping_table_ERRSRV_test
Annotated Snippet
if (map) {
if ((logErr && err != NT_STATUS_MORE_PROCESSING_REQUIRED) ||
(cifsFYI & CIFS_RC))
pr_notice("Status code returned 0x%08x %s\n",
map->ntstatus, map->nt_errstr);
smberrclass = map->dos_class;
smberrcode = map->dos_code;
} else {
smberrclass = ERRHRD;
smberrcode = ERRgeneral;
}
} else {
smberrclass = smb->Status.DosError.ErrorClass;
smberrcode = le16_to_cpu(smb->Status.DosError.Error);
}
/* old style errors */
if (smberrclass == ERRDOS) {
/* DOS class smb error codes - map DOS */
/* 1 byte field no need to byte reverse */
err_map = search_mapping_table_ERRDOS(smberrcode);
} else if (smberrclass == ERRSRV) {
/* server class of error codes */
err_map = search_mapping_table_ERRSRV(smberrcode);
}
if (err_map)
rc = err_map->posix_code;
/* else ERRHRD class errors or junk - return EIO */
/* special cases for NT status codes which cannot be translated to DOS codes */
if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
__u32 err = le32_to_cpu(smb->Status.CifsError);
if (err == (NT_STATUS_NOT_A_REPARSE_POINT))
rc = -ENODATA;
else if (err == (NT_STATUS_PRIVILEGE_NOT_HELD))
rc = -EPERM;
}
cifs_dbg(FYI, "Mapping smb error code 0x%x to POSIX err %d\n",
le32_to_cpu(smb->Status.CifsError), rc);
/* generic corrective action e.g. reconnect SMB session on
* ERRbaduid could be added */
if (rc == -EIO)
smb_EIO2(smb_eio_trace_smb1_received_error,
le32_to_cpu(smb->Status.CifsError),
le16_to_cpu(smb->Flags2));
return rc;
}
int
map_and_check_smb_error(struct TCP_Server_Info *server,
struct mid_q_entry *mid, bool logErr)
{
int rc;
struct smb_hdr *smb = (struct smb_hdr *)mid->resp_buf;
rc = map_smb_to_linux_error((char *)smb, logErr);
if (rc == -EACCES && !(smb->Flags2 & SMBFLG2_ERR_STATUS)) {
/* possible ERRBaduid */
__u8 class = smb->Status.DosError.ErrorClass;
__u16 code = le16_to_cpu(smb->Status.DosError.Error);
/* switch can be used to handle different errors */
if (class == ERRSRV && code == ERRbaduid) {
cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
code);
cifs_signal_cifsd_for_reconnect(server, false);
}
}
return rc;
}
#define DEFINE_CHECK_SORT_FUNC(__array, __field) \
static int __init __array ## _is_sorted(void) \
{ \
unsigned int i; \
\
/* Check whether the array is sorted in ascending order */ \
for (i = 1; i < ARRAY_SIZE(__array); i++) { \
if (__array[i].__field >= \
__array[i - 1].__field) \
continue; \
\
pr_err(#__array " array order is incorrect\n"); \
return -EINVAL; \
Annotation
- Immediate include surface: `linux/bsearch.h`, `cifsproto.h`, `smb1proto.h`, `smberr.h`, `nterr.h`, `cifs_debug.h`, `smb1_err_dos_map.c`, `smb1_err_srv_map.c`.
- Detected declarations: `function Copyright`, `function ntstatus_to_dos_cmp`, `function search_ntstatus_to_dos_map`, `function search_mapping_table_ERRDOS`, `function search_mapping_table_ERRSRV`, `function map_smb_to_linux_error`, `function map_and_check_smb_error`, `function smb1_init_maperror`, `function search_ntstatus_to_dos_map_test`, `function search_mapping_table_ERRDOS_test`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
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.