summaryrefslogtreecommitdiffstats
path: root/src/basic/check-filesystems.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /src/basic/check-filesystems.sh
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/basic/check-filesystems.sh')
-rwxr-xr-xsrc/basic/check-filesystems.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/basic/check-filesystems.sh b/src/basic/check-filesystems.sh
new file mode 100755
index 0000000..696ef61
--- /dev/null
+++ b/src/basic/check-filesystems.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -eu
+set -o pipefail
+
+cpp="$1"
+filesystems_gperf="$2"
+shift 2
+
+includes=""
+for i in "$@"; do
+ includes="$includes -include $i"
+done
+
+error=false
+
+# shellcheck disable=SC2086
+for fs in $($cpp -dM $includes - </dev/null | \
+ grep -E '_MAGIC' | \
+ grep -vE 'LINUX_MAGIC' | \
+ awk '/^#define[ \t]+[A-Z0-9_]+MAGIC[ \t]+/ { print $2; }'); do
+ if ! grep -E "\{.*$fs.*\}" "$filesystems_gperf" >/dev/null; then
+ # STACK_END_MAGIC doesn't refer to a filesystem
+ # mtd_inode was removed in 2015
+ # futexfs was removed in 2018
+ if [[ "$fs" =~ ^(STACK_END_MAGIC|MTD_INODE_FS_MAGIC|FUTEXFS_SUPER_MAGIC)$ ]]; then
+ continue
+ fi
+ echo "Filesystem found in kernel header but not in $(basename "$filesystems_gperf"): $fs";
+ error=true
+ fi
+done
+
+if $error; then
+ exit 1
+fi