diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch
index 866cdef00..5ee478fb5 100755
--- a/scripts/generate-kernel-patch
+++ b/scripts/generate-kernel-patch
@@ -27,6 +27,7 @@ function usage {
echo "Usage: $0 [-h] [-m] [-p
] [-q] , where: "
echo " -h - show this text"
echo " -m - add mpt target driver"
+ echo " -n - do not delete code disabled via preprocessor statements"
echo " -p - generate multiple patches instead of one big patch into"\
"the specified directory."
echo " -q - add qla2x00t driver"
@@ -102,6 +103,7 @@ function process_patch {
echo "Signed-off-by: ${SIGNED_OFF_BY}"
echo ""
"$(dirname $0)/specialize-patch" \
+ ${specialize_patch_options} \
-v kernel_version="${kernel_version}" \
-v SCSI_EXEC_REQ_FIFO_DEFINED="${scsi_exec_req_fifo_defined}" \
-v SCST_IO_CONTEXT="${scst_io_context}"
@@ -112,6 +114,7 @@ function process_patch {
fi
else
"$(dirname $0)/specialize-patch" \
+ ${specialize_patch_options} \
-v kernel_version="${kernel_version}" \
-v SCSI_EXEC_REQ_FIFO_DEFINED="${scsi_exec_req_fifo_defined}" \
-v SCST_IO_CONTEXT="${scst_io_context}"
@@ -134,19 +137,21 @@ srpt="true"
mpt_scst="false"
multiple_patches="false"
patchdir=""
+specialize_patch_options="-v delete_disabled_code=1"
if [ ! -e scst -o ! -e iscsi-scst -o ! -e srpt -o ! -e scst_local ]; then
echo "Please run this script from inside the SCST subversion source tree."
exit 1
fi
-set -- $(/usr/bin/getopt hlmp:q "$@")
+set -- $(/usr/bin/getopt hlmnp:q "$@")
while [ "$1" != "${1#-}" ]
do
case "$1" in
'-h') usage; exit 1;;
'-l') shift;;
'-m') mpt_scst="true"; shift;;
+ '-n') specialize_patch_options="-v delete_disabled_code=0"; shift;;
'-p') multiple_patches="true"; patchdir="$2"; shift; shift;;
'-q') qla2x00t="true"; shift;;
'--') shift;;
diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests
index 8804c62e9..24b74ec8b 100755
--- a/scripts/run-regression-tests
+++ b/scripts/run-regression-tests
@@ -245,6 +245,7 @@ function generate_kernel_patch {
local scst_dir="${PWD}"
local kver="$(kernel_version $1)"
local patchfile="${outputdir}/scst-$1-kernel.patch"
+ local patchfile_m="${outputdir}/scst-$1-kernel-matching-line-numbers.patch"
SIGNED_OFF_BY="..." \
scripts/generate-kernel-patch \
@@ -252,6 +253,14 @@ function generate_kernel_patch {
$([ "${mpt_scst}" = "true" ] && echo -- "-m") \
$([ "${qla2x00t}" = "true" ] && echo -- "-q") \
${kver} > "${patchfile}"
+
+ SIGNED_OFF_BY="..." \
+ scripts/generate-kernel-patch \
+ -n \
+ $([ "${scst_local}" = "true" ] && echo -- "-l") \
+ $([ "${mpt_scst}" = "true" ] && echo -- "-m") \
+ $([ "${qla2x00t}" = "true" ] && echo -- "-q") \
+ ${kver} > "${patchfile_m}"
}
# Generate a kernel patch through scripts/generate-kernel-patch and test
@@ -300,7 +309,7 @@ function run_checkpatch {
}
function patch_and_configure_kernel {
- local patchfile="${outputdir}/scst-$1-kernel.patch"
+ local patchfile="${outputdir}/scst-$1-kernel-matching-line-numbers.patch"
echo "Patching and configuring kernel ..."
(
diff --git a/scripts/specialize-patch b/scripts/specialize-patch
index f5bb354fd..753bcff97 100755
--- a/scripts/specialize-patch
+++ b/scripts/specialize-patch
@@ -261,7 +261,7 @@ function process_preprocessor_statement() {
if (output)
any_section_output[if_nesting_level] = 1
}
- if (output && (! condition || condition && matching_if !~ "^+#if [01]"))
+ if (delete_disabled_code == 0 || (output && (! condition || condition && matching_if !~ "^+#if [01]")))
{
line[lines++]=$0
}
@@ -325,6 +325,19 @@ BEGIN {
{
+ # Dump continued lines without trying to process these -- the parsing code
+ # in this script cannot handle continued lines yet.
+ if (match($0, "\\\\$"))
+ {
+ line[lines++]=$0
+ do
+ {
+ getline
+ line[lines++]=$0
+ } while (match($0, "\\\\$"))
+ getline
+ }
+
# If the line currently being processed is a hunk header, print all lines
# that were stored in the array line[] since the last hunk header was read.
if (match($0, "^@@ -([0-9]*),([0-9]*) \\+([0-9]*),([0-9]*) @@(.*)$"))
@@ -333,7 +346,7 @@ BEGIN {
dump_lines()
match($0, "^@@ -([0-9]*),([0-9]*) \\+([0-9]*),([0-9]*) @@(.*)$", h)
}
- else if (delete_next_blank_line && match($0, "^+$"))
+ else if (delete_disabled_output && delete_next_blank_line && match($0, "^+$"))
{
lines_deleted++
delete_next_blank_line = 0
@@ -345,7 +358,7 @@ BEGIN {
{
process_preprocessor_statement()
}
- else if (output)
+ else if (delete_disabled_output == 0 || output)
{
# Store the line that was just read.
line[lines++]=$0