DF-2269 / 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_cd.c and registers # it as a standard kernel source file. # # Notes: # - the generated file lives in bus/cam/scsi/ so scsi_cd.c's relative # quote-includes ("../cam.h", "scsi_cd.h", ...) resolve unchanged; # - scsi_cd.c includes <opt_cd.h>, which config(8) only generates when # the cd device is configured; this kernel will no longer configure # it (see below), so an empty opt_cd.h is provided in /usr/src/sys # (guest build tree only -- the audit-side sys/ tree is never # touched) and scsi_cd.c's built-in #ifndef defaults apply; # - the kernel config compiles scsi_cd.c as scsi_cd.o ("device cd"); # 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 CD hardware is used # by this guest; the audit-side sys/ tree is never touched. set -e cd /usr/src/sys cat bus/cam/scsi/df_pre.c bus/cam/scsi/scsi_cd.c bus/cam/scsi/df_post.c \ > bus/cam/scsi/df2269_harness.c grep -q 'df2269_harness' conf/files || \ printf 'bus/cam/scsi/df2269_harness.c\t\tstandard\n' >> conf/files [ -f opt_cd.h ] || : > opt_cd.h sed -i '' -E 's/^device([[:space:]]+cd[[:space:]]*# CD.*)/#device\1/' \ config/X86_64_GENERIC grep -n 'cd.*# CD' config/X86_64_GENERIC || true echo "generated bus/cam/scsi/df2269_harness.c" \ "($(wc -l < bus/cam/scsi/df2269_harness.c) lines)" |