fs/smb/client/gen_smb1_mapping
Source file repositories/reference/linux-study-clean/fs/smb/client/gen_smb1_mapping
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/gen_smb1_mapping- Extension
[no extension]- Size
- 3926 bytes
- Lines
- 125
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: VFS And Filesystem Core
- Status
- atlas-only
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.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
if (/$re/) {
my ($name, $val_str, $class, $code) = ($1, $2, $3, $4);
# Skip duplicate macro names
next if $seen{$name}++;
# Clean up value string (remove parens, spaces)
$val_str =~ s/[\s\(\)]//g;
my $val = 0;
foreach my $part (split(/\|/, $val_str)) {
$val |= hex($part);
}
push @list, { val => $val, name => $name, class => $class, code => $code };
} elsif (/^\s*#define\s+NT_STATUS_.*(?:\/\/|\/\*)/) {
# Error if macro has a comment (// or /*) but fails mapping format
die "Error: Invalid mapping comment format in $in_file: $_";
}
}
} elsif ($in_file =~ /smberr\.h$/) {
while (<$in>) {
# Handle backslash line continuation
$_ .= <$in> while s/\\\s*\n//;
# Detect current error class from header comments (ERRDOS or ERRSRV)
if (/generated with the (\w+) error class/) {
$current_class = $1;
}
# Match #define ERR/Err_... <value> followed by // -POSIX_ERR or /* -POSIX_ERR */
if (/^\s*#define\s+((?:ERR|Err)[A-Za-z0-9_]+)\s+([0-9a-fA-FxX]+)\s*(?:\/\/|\/\*)\s*(-[A-Z0-9_]+)/) {
my ($name, $val_str, $error) = ($1, $2, $3);
my $val = ($val_str =~ /^0x/i) ? hex($val_str) : $val_str;
push @list, { val => $val, name => $name, error => $error, class => $current_class };
} elsif ($current_class && /^\s*#define\s+(?:ERR|Err).*?(?:\/\/|\/\*)/) {
# Error if macro has a comment (// or /*) but fails mapping format
die "Error: Invalid mapping comment format in $in_file: $_";
}
}
}
close($in);
# Fail if no entries were found to avoid broken builds
die "Error: No mapping entries found in $in_file\n" unless @list;
# Sort entries numerically by value
@list = sort { $a->{val} <=> $b->{val} } @list;
# Generate the C mapping table output file
open(my $out, ">", $out_file) or die "Cannot open $out_file: $!";
print $out "/* Autogenerated from $input_name by $script_name */\n\n";
if ($output_name eq "smb1_mapping_table.c") {
# Generate NT status -> DOS error mapping file
my $count = scalar @list;
my $full_names = "";
for (my $i = 0; $i < $count; $i++) {
my $e = $list[$i];
my $val = $e->{val};
$full_names .= $e->{name};
# Merge synonyms
if ($i < $count - 1 && $list[$i + 1]->{val} == $val) {
$full_names .= " or ";
next;
}
printf $out "\t{ %s, %s, 0x%08x, \"%s\" },\n", $e->{class}, $e->{code}, $val, $full_names;
Annotation
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: atlas-only.
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.