scripts/check-uapi.sh

Source file repositories/reference/linux-study-clean/scripts/check-uapi.sh

File Facts

System
Linux kernel
Corpus path
scripts/check-uapi.sh
Extension
.sh
Size
15606 bytes
Lines
579
Domain
Support Tooling And Documentation
Bucket
scripts
Inferred role
Support Tooling And Documentation: scripts
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.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Script to check commits for UAPI backwards compatibility

set -o errexit
set -o pipefail

print_usage() {
	name=$(basename "$0")
	cat << EOF
$name - check for UAPI header stability across Git commits

By default, the script will check to make sure the latest commit (or current
dirty changes) did not introduce ABI changes when compared to HEAD^1. You can
check against additional commit ranges with the -b and -p options.

The script will not check UAPI headers for architectures other than the one
defined in ARCH.

Usage: $name [-b BASE_REF] [-p PAST_REF] [-j N] [-l ERROR_LOG] [-i] [-q] [-v]

Options:
    -b BASE_REF    Base git reference to use for comparison. If unspecified or empty,
                   will use any dirty changes in tree to UAPI files. If there are no
                   dirty changes, HEAD will be used.
    -p PAST_REF    Compare BASE_REF to PAST_REF (e.g. -p v6.1). If unspecified or empty,
                   will use BASE_REF^1. Must be an ancestor of BASE_REF. Only headers
                   that exist on PAST_REF will be checked for compatibility.
    -j JOBS        Number of checks to run in parallel (default: number of CPU cores).
    -l ERROR_LOG   Write error log to file (default: no error log is generated).
    -i             Ignore ambiguous changes that may or may not break UAPI compatibility.
    -q             Quiet operation.
    -v             Verbose operation (print more information about each header being checked).

Environmental args:
    ABIDIFF        Custom path to abidiff binary
    CROSS_COMPILE  Toolchain prefix for compiler
    CC             C compiler (default is "\${CROSS_COMPILE}gcc")
    ARCH           Target architecture for the UAPI check (default is host arch)

Exit codes:
    $SUCCESS) Success
    $FAIL_ABI) ABI difference detected
    $FAIL_PREREQ) Prerequisite not met
EOF
}

readonly SUCCESS=0
readonly FAIL_ABI=1
readonly FAIL_PREREQ=2

# Print to stderr
eprintf() {
	# shellcheck disable=SC2059
	printf "$@" >&2
}

# Expand an array with a specific character (similar to Python string.join())
join() {
	local IFS="$1"
	shift
	printf "%s" "$*"
}

# Create abidiff suppressions
gen_suppressions() {
	# Common enum variant names which we don't want to worry about
	# being shifted when new variants are added.
	local -a enum_regex=(
		".*_AFTER_LAST$"

Annotation

Implementation Notes