tools/perf/trace/beauty/arch_errno_names.sh
Source file repositories/reference/linux-study-clean/tools/perf/trace/beauty/arch_errno_names.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/trace/beauty/arch_errno_names.sh- Extension
.sh- Size
- 2041 bytes
- Lines
- 92
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
string.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Generate C file mapping errno codes to errno names.
#
# Copyright IBM Corp. 2018
# Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
gcc="$1"
toolsdir="$2"
include_path="-I$toolsdir/include/uapi"
arch_string()
{
echo "$1" |sed -e 'y/- /__/' |tr '[[:upper:]]' '[[:lower:]]'
}
asm_errno_file()
{
arch="$1"
header="$toolsdir/arch/$arch/include/uapi/asm/errno.h"
if test -r "$header"; then
echo "$header"
else
echo "$toolsdir/include/uapi/asm-generic/errno.h"
fi
}
create_errno_lookup_func()
{
arch=$(arch_string "$1")
printf "static const char *errno_to_name__%s(int err)\n{\n\tswitch (err) {\n" $arch
while read name nr; do
printf '\tcase %d: return "%s";\n' $nr $name
done
printf '\tdefault: return "(unknown)";\n\t}\n}\n'
}
process_arch()
{
arch="$1"
asm_errno=$(asm_errno_file "$arch")
$gcc $CFLAGS $include_path -E -dM -x c $asm_errno \
|grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
|awk '{ print $2","$3; }' \
|sort -t, -k2 -nu \
|IFS=, create_errno_lookup_func "$arch"
}
create_arch_errno_table_func()
{
archlist="$1"
default="$2"
printf 'static arch_syscalls__strerrno_t *\n'
printf 'arch_syscalls__strerrno_function(const char *arch)\n'
printf '{\n'
for arch in $archlist; do
arch_str=$(arch_string "$arch")
printf '\tif (!strcmp(arch, "%s"))\n' "$arch_str"
printf '\t\treturn errno_to_name__%s;\n' "$arch_str"
done
arch_str=$(arch_string "$default")
printf '\treturn errno_to_name__%s;\n' "$arch_str"
printf '}\n'
Annotation
- Immediate include surface: `string.h`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.