Skip to content

Add a common function to find the size of a file or block device

It turns out our existing method was not reliable, at least on some BSDs (where SEEK_END is defined the same as SEEK_SET for block devices).

This method is copied and adapted from https://github.com/util-linux/util-linux/blob/master/lib/blkdev.c

There is no version of this function for Windows. We could add that, as we have the code (plugins/file/winfile.c) but it requires quite a different prototype. At the moment it's best if code which tries to use this function and is compiled on Windows fails hard so we can identify those places and fix them.

This merge request also adds tests and updates several plugins in the second and third commits.

Edited by Eric Blake

Merge request reports