mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-04-30 22:13:10 +03:00
ZTS: Fix nonportable use of stat in list_file_blocks
FreeBSD stat uses -f to specify the format string rather than -c. list_file_blocks in blkdev.shlib uses stat -c %i to get a file's object ID for zdb. We already have a library function to do this portably. Use get_objnum to get the file's object ID. Take log_must off of the call to list_free_blocks in corrupt_blocks_at_level, which had masked the error. It was not good to pipe the output of log_must into the while-loop, anyway. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alek Pinchuk <apinchuk@datto.com> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #10572
This commit is contained in:
parent
01a4852ecb
commit
103bc5b957
@ -542,7 +542,7 @@ function list_file_blocks # input_file
|
|||||||
|
|
||||||
typeset ds="$(zfs list -H -o name $input_file)"
|
typeset ds="$(zfs list -H -o name $input_file)"
|
||||||
typeset pool="${ds%%/*}"
|
typeset pool="${ds%%/*}"
|
||||||
typeset inum="$(stat -c '%i' $input_file)"
|
typeset objnum="$(get_objnum $input_file)"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Establish a mapping between vdev ids as shown in a DVA and the
|
# Establish a mapping between vdev ids as shown in a DVA and the
|
||||||
@ -573,7 +573,7 @@ function list_file_blocks # input_file
|
|||||||
#
|
#
|
||||||
log_must zpool sync -f
|
log_must zpool sync -f
|
||||||
typeset level path offset length
|
typeset level path offset length
|
||||||
zdb -ddddd $ds $inum | awk -F: '
|
zdb -ddddd $ds $objnum | awk -F: '
|
||||||
BEGIN { looking = 0 }
|
BEGIN { looking = 0 }
|
||||||
/^Indirect blocks:/ { looking = 1}
|
/^Indirect blocks:/ { looking = 1}
|
||||||
/^\t\tsegment / { looking = 0}
|
/^\t\tsegment / { looking = 0}
|
||||||
@ -602,7 +602,7 @@ function corrupt_blocks_at_level # input_file corrupt_level
|
|||||||
sysctl kern.geom.debugflags=16
|
sysctl kern.geom.debugflags=16
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_must list_file_blocks $input_file | \
|
list_file_blocks $input_file | \
|
||||||
while read level path offset length; do
|
while read level path offset length; do
|
||||||
if [[ $level = $corrupt_level ]]; then
|
if [[ $level = $corrupt_level ]]; then
|
||||||
log_must dd if=/dev/urandom of=$path bs=512 \
|
log_must dd if=/dev/urandom of=$path bs=512 \
|
||||||
|
Loading…
Reference in New Issue
Block a user