Fix disk_io notification bug

This fixes a bug that makes disk_io stats incorrect and forever increasing, due to the "baseline" stats always being 0.

[This commit](e991e535e4) intended to catch read failures, but actually just always sets x1 to 0. This is because "read" returns 1 if no newline is read, and the code doesn't write a newline to $cache.

Instead, this just always trusts that read works, as x1 is set even if there's no newline. A more robust way might be via cat.
This commit is contained in:
W Scott Johnson 2021-07-10 01:55:14 -04:00 committed by GitHub
commit bfb57bb6c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,7 +62,7 @@ __disk_io() {
if [ $t2 -le $t1 ]; then
rate=0
else
[ -r "$cache" ] && read x1 < "$cache" || x1=0
[ -r "$cache" ] && read x1 < "$cache"
local a1= a2= a3= a4= a5= a6= a7= a8= a9= a10=
read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 other < "/sys/block/$disk/stat"
if [ "$i" = "read" ]; then