Y'all might be interested in this code I recently copied from
util-linux (originally "public domain") into nbdkit (BSD):
https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/utils/device-size.c...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top