1#!/usr/bin/env bash 2# SPDX-License-Identifier: LGPL-2.1-or-later 3set -eu 4set -o pipefail 5 6cpp="$1" 7filesystems_gperf="$2" 8shift 2 9 10includes="" 11for i in "$@"; do 12 includes="$includes -include $i" 13done 14 15error=false 16 17# shellcheck disable=SC2086 18for fs in $($cpp -dM $includes - </dev/null | \ 19 grep -E '_MAGIC' | \ 20 grep -vE 'LINUX_MAGIC' | \ 21 awk '/^#define[ \t]+[A-Z0-9_]+MAGIC[ \t]+/ { print $2; }'); do 22 if ! grep -E "\{.*$fs.*\}" "$filesystems_gperf" >/dev/null; then 23 # STACK_END_MAGIC doesn't refer to a filesystem 24 # mtd_inode was removed in 2015 25 # futexfs was removed in 2018 26 if [[ "$fs" =~ ^(STACK_END_MAGIC|MTD_INODE_FS_MAGIC|FUTEXFS_SUPER_MAGIC)$ ]]; then 27 continue 28 fi 29 echo "Filesystem found in kernel header but not in $(basename "$filesystems_gperf"): $fs"; 30 error=true 31 fi 32done 33 34if $error; then 35 exit 1 36fi 37