DF-2265 / gen.sh
#!/bin/sh # gen.sh -- run ON THE GUEST. Concatenates the harness around a verbatim # copy of /usr/src/sys/bus/cam/scsi/scsi_sa.c and registers it as a # standard kernel source file. # # Notes: # - the generated file lives in bus/cam/scsi/ so scsi_sa.c's relative # quote-includes ("../cam.h", "scsi_all.h", ...) resolve unchanged; # - scsi_sa.c includes <opt_sa.h>, which config(8) only generates when # the sa device is configured; this kernel does not configure it, so # an empty opt_sa.h is provided in /usr/src/sys (guest build tree # only -- the audit-side sys/ tree is never touched) and scsi_sa.c's # built-in #ifndef defaults apply. set -e cd /usr/src/sys cat bus/cam/scsi/df_pre.c bus/cam/scsi/scsi_sa.c bus/cam/scsi/df_post.c \ > bus/cam/scsi/df226x_harness.c grep -q 'df226x_harness' conf/files || \ printf 'bus/cam/scsi/df226x_harness.c\t\tstandard\n' >> conf/files [ -f opt_sa.h ] || : > opt_sa.h # The kernel config compiles scsi_sa.c as scsi_sa.o ("device sa"); the # verbatim copy inside the harness TU would duplicate its public # symbols at link time. Drop the kernel's own copy (the harness TU # contains the complete driver). No tape hardware exists on this # guest; the audit-side sys/ tree is never touched. sed -i '' -E 's/^device([[:space:]]+sa[[:space:]]*# Sequential Access.*)/#device\1/' \ config/X86_64_GENERIC grep -n 'sa.*Sequential Access' config/X86_64_GENERIC || true echo "generated bus/cam/scsi/df226x_harness.c" \ "($(wc -l < bus/cam/scsi/df226x_harness.c) lines)" |