@@ -246,3 +246,34 @@ set_scheduler() {
return 1
fi
}
+
+# Issue dd command with five arguments and record command line in FULL file.
+# args: target device, r/w, start sector, sector len, block size in bytes
+_dd() {
+ local target_dev=${1}
+ local rw=${2}
+ local -i start_sector=${3}
+ local -i start_byte=$(( start_sector * 512 ))
+ local -i sector_count=${4}
+ local -i bs=${5}
+ local -i block_count=$(( sector_count * 512 / bs ))
+
+ local _cmd="dd bs=${bs} count=${block_count}"
+
+ if [[ ${rw} = "read" ]]; then
+ _cmd="${_cmd} if=${target_dev} of=/dev/null"
+ _cmd="${_cmd} iflag=skip_bytes skip=${start_byte}"
+ elif [[ ${rw} = "write" ]]; then
+ _cmd="${_cmd} if=/dev/zero of=${target_dev}"
+ _cmd="${_cmd} oflag=seek_bytes,direct seek=${start_byte}"
+ fi
+
+ echo "${_cmd}" >> "$FULL" 2>&1
+
+ if ! eval "${_cmd}" >> "$FULL" 2>&1 ; then
+ echo "dd command failed"
+ return 1
+ fi
+
+ sync
+}
To analyze dd command failures found by blktests, need to confirm dd command options. Introduce the helper function which executes dd and records dd command options in FULL file for quick analysis. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- common/rc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)