# HG changeset patch # User Pascal Bellard # Date 1431674700 -7200 # Node ID 5f5f6496a1151228e3ade511df631d8dd6317cee # Parent e717c691bab952b63f31a0834f21e18f15e5f9a2 hardware.cgi/loop: show size diff -r e717c691bab9 -r 5f5f6496a115 hardware.cgi --- a/hardware.cgi Wed May 13 15:51:06 2015 +0200 +++ b/hardware.cgi Fri May 15 09:25:00 2015 +0200 @@ -530,6 +530,7 @@ $(_ 'Device') $(_ 'Backing file') + $(_ 'Size') $(_ 'Access') $(_ 'Offset') @@ -538,16 +539,20 @@ EOT for devloop in $(ls /dev/*loop[0-9]*); do loop="${devloop#/dev/}" - case "$(cat /sys/block/$loop/ro 2>/dev/null)" in + dir=/sys/block/$loop + case "$(cat $dir/ro 2>/dev/null)" in 0) ro="$(_ "read/write")" ;; 1) ro="$(_ "read only")" ;; *) ro="" ;; esac - set -- $(losetup | grep ^$devloop:) ${ro// / } + size=$(blk2h $(cat $dir/size)) + [ "$size" == "0.0K" ] && size="" && ro="" + set -- $(losetup $devloop) + set -- "${3:-$(cat $dir/loop/backing_file)}" "${2:-$(cat $dir/loop/offset)}" ${ro// / } cat < - $3$4$2 + $1$size$3$2 EOT done