DF-2427 / gen.sh
#!/bin/sh # gen.sh -- run ON THE GUEST. Concatenates the harness around a # verbatim copy of /usr/src/sys/dev/disk/amd/amd.c and registers it # as a standard kernel source file. # # Notes: # - the generated file lives in dev/disk/amd/ so amd.c's quote-include # #include "amd.h" resolves to the real amd.h in that directory; # - the X86_64_GENERIC kernel does NOT configure "device amd" # (conf/files: "dev/disk/amd/amd.c optional amd"), so the kernel # never compiles amd.c separately; the verbatim copy inside the # harness TU is the only instance. Nothing is renamed; the driver # code is byte-for-byte the source file (sha256-gated by build.sh # against the audit tree). set -e cd /usr/src/sys cp -n dev/disk/amd/amd.c dev/disk/amd/amd.c.orig 2>/dev/null || true cat dev/disk/amd/df_pre.c dev/disk/amd/amd.c dev/disk/amd/df_post.c \ > dev/disk/amd/dfamd_harness.c grep -q 'dfamd_harness' conf/files || \ printf 'dev/disk/amd/dfamd_harness.c\t\tstandard\n' >> conf/files # The kernel config compiles amd.c itself ("device amd"); drop the # kernel's own copy so the verbatim TU inside the harness is the only # instance (same approach as the DF-2269 scsi_cd rig used for "device # cd"). The DRIVER_MODULE inside the harness still registers the # driver; no AMD53c974 hardware exists in this guest. The amdtemp # line is NOT matched (requires whitespace right after "amd"). sed -i '' -E 's/^device([[:space:]]+amd[[:space:]]+#+.*AMD 53C974.*)/#device\1/' \ config/X86_64_GENERIC grep -n 'amd.*AMD 53C974' config/X86_64_GENERIC || true echo "generated dev/disk/amd/dfamd_harness.c" \ "($(wc -l < dev/disk/amd/dfamd_harness.c) lines)" |