diff --git a/testing.sh b/testing.sh index e8aed88..5b468aa 100755 --- a/testing.sh +++ b/testing.sh @@ -57,6 +57,20 @@ function get_time() { echo "$date" } +function get_inode() { + + case "$OSTYPE" in + darwin*) + inode=$(stat -f "%i" "$1") + ;; + *) + inode=$(stat -c "%i" "$1") + ;; + esac + + echo "$inode" +} + function assertions() { # check error log is empty if grep -q '[^[:space:]]' $log_error_file; then @@ -67,7 +81,7 @@ function assertions() { } function assert_matching_file_hardlinked() { - if ! [ "$(stat -c "%i" "$1")" -eq "$(stat -c "%i" "$2")" ]; then + if ! [ "$(get_inode "$1")" -eq "$(get_inode "$2")" ]; then echo "File '$1' was not hardlinked to '$2' when it should have been!" exit 1 fi diff --git a/zfs-inplace-rebalancing.sh b/zfs-inplace-rebalancing.sh index 3906d15..1c8aed3 100755 --- a/zfs-inplace-rebalancing.sh +++ b/zfs-inplace-rebalancing.sh @@ -282,7 +282,7 @@ if [[ "${OSName}" == "linux-gnu"* ]]; then find "$root_path" -type f -not -path '*/.zfs/*' -exec stat --printf '%d:%i|%n\n' {} \; > files_list.txt elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then # Mac OS and FreeBSD - find "$root_path" -type f -not -path '*/.zfs/*' -exec sh -c 'stat -f "%d:%i|%N" "$0"' {} \; > files_list.txt + find "$root_path" -type f -not -path '*/.zfs/*' -exec stat -f "%d:%i|%N" {} \; > files_list.txt else echo "Unsupported OS type: $OSTYPE" exit 1